How to Create a Jdialog class that returns a boolean parameter

I'm trying to subclass a jdialog to return a boolean to another callling class, the parameter is return when the jdialog closes, how do i declare such a class and what method do i call on the windowclosed event
I'm new to java so need some code sample, the program is to implement a login and password verification.
thanks in advance for any assistance.

Here's another way (a third way is to make the dialog form an inner class)
in this eg, the password is hard-coded as java
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class MainWindow extends JFrame
  JLabel lbl = new JLabel("JLabel");
  JButton btn = new JButton("JButton");
  boolean loggedInOK = false;
  public MainWindow()
    new FTILogin_Jdia2(this, true).show();
    if(!loggedInOK) System.exit(0);
    buildGUI();
  public void buildGUI()
    setLocation(400,300);
    setSize(150,85);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JPanel jp = new JPanel(new BorderLayout());
    jp.add(lbl,BorderLayout.NORTH);
    jp.add(btn,BorderLayout.SOUTH);
    getContentPane().add(jp);
    setVisible(true);
  public static void main(String[] args){new MainWindow();}
class FTILogin_Jdia2 extends javax.swing.JDialog implements ActionListener
  JTextField tf = new JTextField(10);
  String password = "java";
  MainWindow mainWindow;
  public FTILogin_Jdia2(MainWindow parent, boolean modal)
    setModal(modal);
    mainWindow = parent;
    initComponents();
  public void initComponents()
    setLocation(400,300);
    getContentPane().setLayout(new BorderLayout());
    JPanel top = new JPanel();
    top.add(new JLabel("Password: "));
    top.add(tf);
    getContentPane().add(top,BorderLayout.NORTH);
    JButton btn = new JButton("OK");
    btn.addActionListener(this);
    getContentPane().add(btn,BorderLayout.SOUTH);
    pack();
  public void actionPerformed(ActionEvent e)
    if(tf.getText().equals(password))
      mainWindow.loggedInOK = true;
    dispose();
[/code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Class override, how to create the child class and then the base class

    I started to write a program for a smart DMM, the problem is every version of the DMM the company change the communication commend.
    My idea is to write a child class for every DMM version and every SubVI of the child will override the base class SubVI.
    My problem is, i want first to create one child class and after i will see every thing is work,  start to create the base class. that way i will see if am thinking the right way.
    My question is
    How can i create a child class and then create the base class and configure the SubVi of the child class to be Override of the base class?
    I tried to search in the property of the class but i didn't see nothing.
    Thanks
    Solved!
    Go to Solution.

    This can be done and I've done it on occasion.
    You simply create the base class with the dynamic dispatch methods you require (connector panes need to be identical to thos of the child class).
    Then set the inheritance of the class to inherit from this base class.  If your method is defined as a dynamic dispatch method in the parent, you'll most likely now have some errors (unless your child method was already DD in which case you might just be OK already).
    To change the inheritance of a class, right-click the properties of the class in your project and select properties.  I believe the ineritance tree is at the lower end of the properties.  Click on the "change inheritance" (or something similar) to choose the class from which you now wish to inherit.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • How to create an object class programmatically?

    Guys,
    I need your help. If possible with a simple example of how to do it.
    I need to create an aplication that read an specification of a repository type from a file and then creates it inside my BEA Repository. The problem are few:
    1 - How to Create an Object Class programmaticaly?
    I looked at documentation of ObjectClassOps but havent figured out how to do it.
    2 - How to Create a Property Definition programmaticaly?

    Sorry, ITypeManager only exists in 9.2. If you are working on 8.1, then the previous example becomes:
    RepositoryManager repositoryMgr = RepositoryManagerFactory.create();
    //connect to the repository
    repositoryMgr.connect();
    //get ObjectClassOps
    ObjectClassOps ocops = repositoryMgr.getObjectClassOps();
    ID repId = new ID();
    repId.setRepositoryName(repositoryName);
    PropertyDefinition[] pds = new PropertyDefinition[1];
    pds[0] = new PropertyDefinition(repId, "stringProp", null, Property.STRING, false, false, false, false, false, null);
    ObjectClass oc = new ObjectClass(repId, "myType", null, pds);
    oc = ocops.createObjectClass(oc);

  • How to create a container class for 2 object?

    I use JDK to create 2 objects, one is Customer and one is Book. I need to enqueue these 2 objects, but they canot share the same queue class. Some one told me that I can create a container class for these 2 objects but I don't know how to create it. Can some one tell me how to create the container class?

    I use JDK to create 2 objects, one is Customer and one
    is Book. I need to enqueue these 2 objects, but they
    canot share the same queue class. Some one told me
    that I can create a container class for these 2
    objects but I don't know how to create it. Can some
    one tell me how to create the container class?
    class CustomerBook{
    Book m_book;
    Customer m_customer;
    pulbic CustomerBook (Customer customer, Book book){
    m_book = book;
    m_customer = customer;
    }If you want to create a class that represents one customer and many books, do this:
    class CustomerBooks{
    Vector m_books;
    Customer m_customer;
    pulbic CustomerBook (Customer customer){
    m_books = new Vector();
    m_customer = customer;
    public void addBook (Book book){
    m_books.addElement (book);
    public void displayBooks (){
    //I assume the Book class has a toString method or something similar
    for (int i = 0;i < m_books.size();i++){
      System.out.println ("book: "+((Book)m_books.elementAt(i)).toString());

  • Re: How to create More two class with one object

    haii,
             i have small information How to create More two class with one object,
    bye
    bye
    babu

    Hello
    I assume you want to create multiple instance of your class.
    Assuming that you class is NOT a singleton then simply repeat the CREATE OBJECT statement as many times as you need.
    TYPES: begin of ty_s_class.
    TYPES: instance   TYPE REF TO zcl_myclass.
    TYPES: end of ty_s_class.
    DATA:
      lt_itab      TYPE STANDARD TABLE OF ty_s_class
                     WITH DEFAULT KEY,
      ls_record  TYPE ty_s_class.
      DO 10 TIMES.
        CLEAR: ls_record-instance.
        CREATE OBJECT ls_record-instance.
        APPEND ls_record TO lt_itab.
      ENDDO.
    Regards
      Uwe

  • How to create a standard report that allows filtering?

    Hi Guys and Gals,
    Sometimes, the standard report is great because it gives the user the feeling of a grid. i.e. All of the values are editable on one page, kind of like a spreadsheet. That is sometimes very useful. But if there is a lot of data, a filtering mechanism is necessary.
    So will one of you Apex gurus please tell me how to create a standard report that also allows data filtering?
    Allowing the user to specify the number of rows displayed would be peachy-keen too.
    Thanks,
    Kim
    P.S. I'm running Apex 4.1 with Oracle 11g.

    Kim2012 wrote:
    Your idea sounds very promising, but I apparently need a nudge in the right direction. From "Create Page", I clicked on "Form" and then "Tabular Form". Why would you do this? The advice given was
    create a standard report page using the Create New Page wizardi.e. go to Home > Application Builder > Application > Create Page and click Classic Report, this was suggested because the original post said:
    >
    So will one of you Apex gurus please tell me how to create a standard report that also allows data filtering?
    >
    Nothing about forms. Tabular Forms, Tabular Forms. Despite many enhancements over the last few versions, tabular forms still cause problems, especially for novices trying to go beyond their own competence and the built-in capabilities of wizard-generated tabular forms.
    More good advice: Re: Newbie question-how does the tabular form work?  How to populate prim key? and&mdash;if based on decent database design&mdash;out of the box you have a usable and robust application. Use an Interactive Report or a custom report template and add some CSS and you can get something a lot more powerful, flexible and better looking than any tabular form. Spend the time you haven't wasted on frustrated hacking of tabular forms adding more features and enhancements to your app.

  • I want to know how to create a new script that can be run in batch proces in Photoshop Element 11 ?

    I want to know how to create a new script that can be run in batch proces in Photoshop Element 11 ?

    Have a look at the menu file/process multiple files. You can choose to add your signature (or the caption) to the image and export the new files.
    If that solution is not flexible enough, consider using the very affordable (12$)  Elements+ add-on which offers a 'meta stamp' script :
    http://elementsplus.net/v5/en/meta-stamp.htm
    Otherwise, have a look at other free and good solutions like Faststone Photoresizer, Xnview...

  • How to create an infinite loop that cannot be cancelled?

    Hi , im new around java and i need a program that keeps on repeating after each each input/uses(generally meant for different user) and cannot either stop using "Cancel" or "x" while stopping only using the "stop" button
    I got a few lines of codes that look like this : String arg = "";
    do{
    JOptionPane.showInputDialog("hi");
    }while ( arg != "y" || arg!= "Y");
    and it cannot be stop with both cancel and"x"(which i wanted)
    but when i used this logic with
    Valid validUserInput = new Valid();
    do {
    userInput = validUserInput.validUserInput(a);
    switch(userInput){
    case 1 : validUserInput.optionOne(b);break;
    case 2 : validUserInput.optionTwo(c);break;
    case 3 : validUserInput.optionThree(d,e);break;
    default : validUserInput.validUserInput(f);
    }while(looping != "" || looping != " ");
    it does not really work(while it will keep looping, it can be easily stop by pressing cancelled or "x")
    So is there any logic or method that can prevent the program from being stop?
    Thankyou!

    elricscript wrote:
    "That is helpful. It gives him a direction where he can focus his research. Namely, 'how to run a program in kiosk mode' rather than 'how to create an infinite loop that cannot be cancelled.'"
    No... He already mentioned he wants to "e.g Interactive kiosk", so saying "properly kiosk it" isn't adding any new information. Rather it's just giving the person a dead point of: you're doing it wrong. Pointing out someone is wrong is not a positive enlightenment. Pointing someone in the right direction is more productive.
    >"That is helpful. It gives him a direction where he can focus his research. Namely, 'how to run a program in kiosk mode' rather than 'how to create an infinite loop that cannot be cancelled.'"
    No... He already mentioned he wants to "e.g Interactive kiosk", so saying "properly kiosk it" isn't adding any new information.
    Yes it is. He asked how to do it using some Swing trickery, and I said it won't work. Which is true. The OP didn't already know that, clearly, hence the question. Now he does. That's pretty much new information if you ask me.
    Rather it's just giving the person a dead point of: you're doing it wrong.Right. He is. However, the problem is now no longer related to Java, and not something I can help him with. You should try that: not answering questions you don't know the answer to. It's actually more helpful than posting misleading, wrong answers.
    Pointing out someone is wrong is not a positive enlightenment. I'm giving basic technical help, not yoga lessons.
    Pointing someone in the right direction is more productive.As already stated, I am as ignorant of how to make a Java application into a kiosk app as the OP is. What value can I add in light of that information? I began by answering a question that was not stated to be about kiosks. Once the question moved outside of my area of knowledge, I stopped trying to answer.
    I notice you're not giving him any help, being more interested in admonishing others as you are.

  • How to create a popup window that shows detail information when press submi

    hi,all
    how to create a popup window that shows detail information when press the submit button ?I mean,when I press the button "Sumit"there will appear a popup window that shows the detail information you typed before.it means are u sure to submit,it is like some confirmation window.
    how to do achieve this ?help plz .
    best regards
    hlee
    Edited by: hlee on 2011-4-15 上午1:26

    hey,vee
    thanks for your response,but i had already read this thread before i put up a new question.any way,thanks.
    best regards
    hlee

  • How to create a jdialog with boxlayout

    Hi,
    I was trying to create a jdialog as simple as plsql login dialog. In attempt to learn how should I proceed I downloaded and modified BoxLayoutDemo.java that is available from java's swing tutorial site:
    * BoxLayoutDemo.java is a 1.4 application that requires no other files.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.Border;
    public class BoxLayoutDemo {
        static JDialog jdlg;
        public static void addComponentsToPane(Container pane) {
            pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
            addTextField(pane);
            addAButton("Button 1", pane);
            addAButton("Button 2", pane);
            addAButton("Button 3", pane);
            addAButton("Long-Named Button 4", pane);
            addAButton("5", pane);
        private static void addAButton(String text, Container container) {
            JButton button = new JButton(text);
            button.setAlignmentX(Component.CENTER_ALIGNMENT);
            container.add(button);
        private static void addTextField(Container container) {
            JTextField txt = new JTextField(20);
            //txt.setMaximumSize(new Dimension(100,20));
            txt.setPreferredSize(new Dimension(100,10));
            txt.setAlignmentX(Component.RIGHT_ALIGNMENT);
            //Border padding = BorderFactory.createEmptyBorder(20,20,5,20);
            //txt.setBorder(padding);
            container.add(txt);
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("BoxLayoutDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Set up the content pane.
            jdlg = new JDialog(frame);
            addComponentsToPane(jdlg.getContentPane());
            //Display the window.
            frame.pack();
            frame.setVisible(true);
            jdlg.setPreferredSize(new Dimension(200,200));
            jdlg.pack();
            jdlg.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }The funniest thing is every thing except the text box is ok. With or without the text box the buttons are shown appropriately i mean they dont stretch. But in case of the text field it seems like that the height of the textfield becomes 60 instead of 20. if I use txt.setMaximumsize(new Dimension(100,20)) then everything seems ok.
    Now it seems like swing has some fetish about textfields. Because even if I dont specify the size of the buttions they dont stretch themsleves but even if I specify the size of the text field and make it the first element so that the last element gets stretched if necessary without affecting it, it will defy the size instruction.Layout managers are really amazing!!!!!!!! and so helpful!!!!!!!!!

    not really sure what effect you want, but try this
        private static void addTextField(Container container) {
            JTextField txt = new JTextField(20);
            //txt.setMaximumSize(new Dimension(100,20));
            txt.setPreferredSize(new Dimension(100,10));
            txt.setAlignmentX(Component.RIGHT_ALIGNMENT);
            //Border padding = BorderFactory.createEmptyBorder(20,20,5,20);
            //txt.setBorder(padding);
            JPanel p = new JPanel();//<-------------
            p.add(txt);//<-------------
            //container.add(txt);//<-------------
            container.add(p);//<-------------
        }

  • HOW TO EXECUTE A STORE PROCEDURE THAT RETURN MULTIPLE ROWS FROM A QUERY

    I NEED TO CREATE AND USE A STORE PROCEDURE THAT IS GOING TO DO A SELECT STATEMENT AN THE RESULT OF THE SELECT STATEMENT IS RETURN IN SOME WAY TO THE REQUESTER.
    THIS CALL IS MADE BY AN EXTERNAL LANGUAGE, NOT PL/SQL OR FORMS APPLICATION. USING FOR EXAMPLE ODBC AND VISUAL BASIC. WHAT I NEED TO DO IS ADD A DATA ACCESS LAYER TO MY APPLICATION AND I ALREADY HAVE IT DONE FOR MS SQL SERVER, BUT I NEED THE SAME FUNCTIONALITY ACCESSING AN ORACLE DATABASE.
    FLOW:
    1. VB CREATE A ODBC CONNECTION TO A ORACLE DATABASE
    2. VB EXECUTE A STORE PROCEDURE
    3. THE STORE PROCEDURE RETURNS TO THE VB APPLICATION THE RESULT OF THE QUERY THAT IS INSIDE OF THE STORE PROCEDURE.(I.E. THE STORE PROCEDURE IS A BASIC SELECT, NOTHING COMPLEX)
    4. VB DISPLAY THE RESULT IN A GRID
    FOR SURE I CAN DO THE SELECT DIRECTLY TO ORACLE, BUT FOR PERFORMANCE REASONS AND SCALABILITY, I'LL LIKE IT TO DO IT USING A STORE PROCUDURES
    IS THIS POSIBLE?, HOW?
    THANKS

    Certainly, it's possible. First, define a stored procedure that includes an OUT parameter which is a REF CURSOR. Then, call the stored procedure via ODBC omitting the OUT parameter from the list of parameters. IT will automatically be returned as a result set. Syntax for both is below...
    CREATE PROCEDURE foo (inParam in varchar2, resultSet OUT REF CURSOR )
    In ODBC:
    {call foo( 'someData' )}
    Justin

  • How to create a smart folder that only selects from a specific directory?

    I am trying to create a smart folder that lists all my iPhoto original content in the last few months. I want this so that my wife can connect into the smart folder over the LAN when copying specific photos to her PC.
    I am have trouble working out how to restrict the search to only those files that exists in the iPhoto directory. When I look at info for a photo is states "Where: /Users/Shared/iPhoto Library/iPhoto Library/Data/2009/....etc etc".
    However if I add an filter for "Where from" begins with "/Users/Shared/... etc etc" it returns nothing. Is there a way to do this?

    Find the iPhoto library file.
    Right click -> Show package contents.
    Double click the Originals folder.
    Type anything in the Search box at the top of the Finder window.
    In the top of the Finder window, click "Originals".
    Click the + (plus) sign next to Save.
    Select Kind is Image.
    Click the + (plus) sign again.
    Select *Created date* is *within last 3 months* (or whatever you want).
    Go to the search box and delete what you typed. Don't hit the X to delete the search text.
    Now save the smart search.
    This is saved in ~\Library\Saved searches. Copy or move it to the desktop where your wife can get access to it.

  • How to create new data class in DDIC?

    Hi Friends,
    I want to store 5 custom tables into a particular Table space.
    For that i want to creat a new Dataclass and which has to be mapped to a new table space.
    So what i need is.
    1. How to create a new Customer data class apart from USER1 and USER that is available?
    2. How to map the newly created Dataclass to a Table space?
    Purpose: DBA wants to maintain these tables separately so that this won't disturb other data.
    SAP VERSION - 4.7EE - AIX - DB2
    Any help on this would be highly appreciated.
    Regards,
    Simha

    you can use either usr or usr1 for your  development ... because
    read the belo statment  provided by SAP
    The data class defines the physical area of the database (for ORACLE the TABLESPACE) in which your table is logically stored. If you choose a data class correctly, your table will automatically be assigned to the correct area when it is created on the database.
    The most important data classes are (other than the system data):
    APPL0    Master data
    APPL1    Transaction data
    APPL2    Organizational and customizing data
    Master data is data which is frequently read, but rarely updated. Transaction data is data which is frequently updated. Organizational und customizing data is data which is defined when the system is initialized and then rarely changed.
    There are two more data classes available, USR and USR1. These are reserved for user developments. The tables assigned to these data classes are stored in a tablespace for user developments.
    Note:The data class only has an effect on table storage for the database systems ORACLE and INFORMIX

  • AF TREE:How to Create Method in backing to Return TreeNode Value Selected

    Hi all;
    I use HR Schema
    in ADF Tree example; I created a Special Page for each Emplyee
    so I want to create a new Method called callPage in backing_test1 class to Return FirstName of the Employee at Selecting Employee Node in the Tree
    like my example below :
    <af:tree value="#{bindings.DepartmentsView1.treeModel}" var="node"
    binding="#{backing_test1.tree1}" id="tree1">
    <f:facet name="nodeStamp">
    <h:panelGroup>
    <af:commandLink text="#{node}" partialSubmit="false"
    id="nodeAction1"
    rendered="#{backing_test1.tree1.depth==0}"/>
    <af:commandLink text="#{node}" partialSubmit="false"
    id="nodeAction2"
    action="#{backing_test1.callPage}"
    rendered="#{backing_test1.tree1.depth==1}"
    actionListener="#bindings.setCurrentEmployeesRowWithKey.execute}"/>
    </h:panelGroup>
    </f:facet>
    </af:tree>
    Best Regards

    mail2bansi wrote:
    Please ignore my earlier message . I hit some key mistakenly and it resulted in send messageThere´s an edit button available as long as no one has responded to your message yet.
    if Validation fails on attribute "required=true"
    wouldn't it result in renderResponse phase
    OR
    it still proceeds to render Response phase Uh, validation happens in validations phase (or apply request values phase, when immediate is set to true). After that, if any validation has failed, then it will proceed to the render response phase immediately.
    Also i forgot to mention that we use Ajax4JSF,
    so to clear FacesMessage by ClientId
    if i retrieve ViewRoot it returns AjaxViewRoot thereby it never returns the correct Iterator meaning Iterator.hasNext() is always falseI don't have extensive experience with Ajax4jsf, so I have no idea what to say here.

  • Global Class that returns an internal table

    Hello,
       Is it possible to create a global class (under class builder) that returns an internal table like we used to do in a function module?
        e.g. call function '<Function module name>'
                        tables = i_tab.
    Thanks,
    Jeffrey

    Hi Jeffrey,
      Yeah u can do that by specifying importing parameters
      to method.You can give table type for the parameters.
    Thanks&Regards,
    Siri.

Maybe you are looking for