Do I use JFrame or JDialog?

Hi,
I wanted to create a dialog which allows me to have two JTextArea's. In one list I list possible selection for the user. In the other text area, all the files the user selected will be in the text area. There will be two buttons for removal/addition of these items from the second text area. When you hit the OK button the owner of the dialog needs to grab that info.
Can an extension of a JDialog do this? Would it be suited for this? Or should I use an extension of a JFrame?
thanks for any help in advance,
Geoff

I would use a JList. The Swing tutorial on "How to Use Lists" gives an example of how to add/remove items from a single list. Changing this to work with two lists should be easy:
http://java.sun.com/docs/books/tutorial/uiswing/components/list.html#mutable

Similar Messages

  • Getting the Parent JFrame or JDialog

    I am trying to get the parent JFrame or JDialog so I can change the cursor. Right now I am doing it in a stupid way by doing this:
    private void changeCursorQuestion(){
              JFrame frame=(JFrame) getParent().getParent().getParent().getParent().getParent().getParent().getParent();
              Cursor cursor=new Cursor(Cursor.HAND_CURSOR);
              frame.setCursor(cursor);
         }//end changeCursorQuestionBut is there an easier and of course better way of getting the frame or jdialog that a panel is in?

    I am trying to get the parent JFrame or JDialog so I can change the cursor. You can change the cursor of the JPanel ( in fact any Container) so why use that getParent() thing....
    Also, if you want to have quick refrence to JFrame object from JPanel, extend JPanel to make a new class and have a refrence to that JFrame/JDialog in that class, that way you can access it quickly.
    Thanks!

  • What is the difference between JFrame and JDialog?

    Is there any difference between JFrame and JDialog except that the JDialog can be modal?
    Is there any reason to use JFrame at all if i can achive the exactly the same with a JDialog?

    API wise they are basically the same, but they are usually built on top of different heavyweight components. Some platforms treat frames quite a bit differently than they do dialogs.

  • HELP Create Extenstion using JFrame instead of JPanel (10.1.3 Release 3)

    Hi,
    I manage to create a custom GUI editor in JDev but if i switch it to JFrame, JDev GUI Designer display nothing but an invinsible frame.
    I'm using sample from customeditor in extension sdk
    Any ideas ?
    Thanks

    It seems that you are trying to use a JFrame as the GUI of your custom editor. The JFrame is a heavy weight component (has a real window behind it). In JDeveloper custom editors must not use JFrames or AWT Frames as their root GUIs. The windows of these frames will paint on top of other editors even if they are behind in the component stacking order.

  • Status Bar using JFrame

    Hi All,
    I have a window which displays a map. This is done using JFrame. Now, I need to display the status bar at the bottom of the window using JFrame. How do i do it?
    Please let me know asap.
    Regards
    Abhi

    Read the Swing tutorial on "Using Layout Managers".
    http://java.sun.com/docs/books/tutorial/uiswing/TOC.html
    You add your "map" panel to the center and your "status" panel to the south.
    In the future, Swing related questions should be posted in the Swing forum.

  • How to make a jframe or jdialog on top of all other applications

    I just want to know if there a way to make a jframe or jdialog on top of an application like games?
    Thanks in advance...

    Try searching the forum?

  • Inserting a Gui program using JFrames and JPanel

    I'm trying to insert a chat program into a game that I've created! The chat program is using JFrames and JPanels. I want to insert this into a GridLayout and Panel. How can I go about doing this?

    whatever is in the frame's contentPane now, you add to a separate JPanel.
    you also add your chat stuff to the separate panel
    the separate panel is added to the frame as the content pane

  • Advice needed about JFrame and JDialog (moved from java programming)

    My main class in my application is a page where the user can choose to register or login. This class is a JFrame. If the user chooses to register, my register dialog is called up and the parent JFrame passed to the dialog:
    private void btnRegister_actionPerformed()
                    new Register(this);
              }Same happens for login. If the user chooses to login, my login dialog comes up and my main class JFrame is set as its parent. This is all fine because all the calling up is done in my main class, so i can just use 'this' to pass the JFrame.
    Now here is my problem. If the user successfully logs in, they should have access to control some events. Now i am not sure if it will be ok to make this new events class another JFrame, as it is practically the start of a new section in my application.
    Thats my first question. My second question is if i do make this events class a JDialog, is it bad coding not to give it a parent frame? Or would this be acceptable? My worries is passing the main class JFrame to a class which is only accessable by going through two other classes.
    Cheers for the advice

    It's Simple dude,
    Advice: Use JIternalFrame, for your purpose.
    And if u want to go with JDialog than u can do that in main method. Like when u call JDialog
    Register dialog = new Register(this);Check for login in Register class or what ever u want. Create new method like success
    private boolean isSuccess() {
    return success;
    } at Register Class. After Registeration change the variable boolean success value to true or false as per logic
    And add
    Register dialog = new Register(this);
    if(dialog.isSuccess()) {
    // Show loginDialg(this) or else
    }Regards,

  • Problem with refreshing JFrames and JDialogs

    My program is based on few JDialogs and one JFrame. I'm still changing them, one time one of the JDialogs is visible, other time JFrame. During this change I call dispose() for one window or frame and I create (if it wasn't created before) other component and call setVisible(true) for it. Problem is that sometimes (only sometimes! like 5% of calls) my windows appears but they are not refreshing (not showing new objects added to their lists or sth like that) until I resize my window by dragging mouse on the edge of it. Is there anyway to ensure that window will be displayed properly?

    I ran into this problem about a year ago...so I don't really remember but I think a call to validate(), or paint() or repaint() or something like that should do the trick (forgive me for not knowing the exact one but as I said it has been a while). Its been about that year since I stopped coding in java and moved to c#. You want the window to redraw its self what ever that is.

  • How to use JFrame's setLayeredPane() method?

    I want to custom JFrame's LayeredPane by setLayeredPane() method,but it does't work.
    Anyone who can help me?
    The code as follows:
    import javax.swing.*;
    import java.awt.*;
    public class LayeredTest{
        public static void main(String[] args){
            SwingUtilities.invokeLater(new Runnable(){
                public void run(){
                    new MyFrame().setVisible(true);
    class MyFrame extends JFrame{
        public MyFrame(){
            super("LayeredTest");
            setLayeredPane(new JLayeredPane());           //this line, I want to set the LayeredPane myself;
                                                          //but it doesn't work.
            JPanel panel =new JPanel();
            panel.setPreferredSize(new Dimension(320,240));
            panel.add(new JLabel("Label"));
            panel.add(new JButton("Button"));
            add(panel);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            pack();   
    }

    Thanks!
    But the very thing I want to know is "How to set Layered Pane(by setLayeredPane() method)",
    not "How to use Layered Pane".

  • Use jFrames as InternalFrames

    Hi, I have a problem with a jFrames.
    I have a library with some jFrames already defined and programmed, and I have an application project with a MainFrame.
    I need to load the library's jFrames inside the Main jFrame on the application project; something like the internalFrames do. I still can't do that.
    I want to ask if it is possible to show jFrames contained inside other jFrame, or if I can, somehow, cast or convert a jFrame to a internalFrame to do what I need. Or if I will have to recode the library's jFrames to internalFrames?
    thanks for the help you can give me.
    race

    Nope. You cannot cast a JFrame as JInternalFrame or vice versa, nor can you make it a child window in the context of an MDI interface. This is one reason why I recommend that most Swing interface elements be placed on a JFrame that way you can plunk them down in a JFrame, a JInternalFrame or a JDialog as the situation demands.
    BTW ... This actually belongs in the Swing forum ...
    Hope this helps,
    PS.

  • How to use a custom jDialog ?

    Hi to everybody
    I have a little custom jdialog with only a jTextField inside.
    I'd like to know how to call it from another JFrame and then read the text which the user have written.
    Any advices ?
    Thank u in advance and greetings from Italy
    Andrea

    Hi
    textfieldname.getText(); can ues to get the texts in you JTextField
    I can't understand what you mean by "how to call it from another JFrame "..
    thanks

  • JFrame with JDialog question

    Hi
    I have a JFrame that have a JButton on it. This button have an actionlistener which the inner class of JFrame. When user click on the button, it should pop up a JDialog with modal turn on. How can I pass the Frame to the JDialog so that I can set the modal??
    Thanks..

    Keep a reference of the frame in ur class and create the dialog with this reference

  • How to view images which resides in the database using JFrame.

    Hello defts,
    Im developing an application using swings. I need to display a image in a JFrame during an button click event. where that image resides in the database.

    the image shouldn't be in the db, just the path to the image location.
    so, open the db, get the location, close the db, get the image from the location,
    then either add the image to the frame via a JLabel or a JPanel (and its paintComponent()).
    when you add/remove components to the frame you will need to call
    frame.validate();, and possibly also
    frame.repaint();

  • Can we add same JPanel twice??.. on JFrame and JDialog together!!

    Hello Frnds,
    my problem is quite weird!! i will try to explain..as much as I can !!
    My requirement is I want to show same JPanel in JDialog and JFrame at once..!!
    I am adding a
    JPanel A ---> JDialog
    JPanel A ---> JScrollPanel B
    JScrollPane B ---> JFrame.. and making frame and dialog visible together.. but JPanel is visible in dialog only..
    if i dont add in JDialog.. then JPanel is visible in frame.. !!.. but why that??
    JFrame fr = new JFrame();
    JPanel np = new JPanel();      // This JPanel is added Twice
    np.setBounds(0, 0, 128, 128);
    JScrollPane scroll=new JScrollPane(np);      // Once JPanel added here..
    scroll.setPreferredSize(new Dimension(385,385));
    fr.add(scroll);
    JDialog dlg=new JDialog(fr, "Another Panel", false);
    dlg.add(np);                        // Second Time JPanel added here..
    dlg.pack();
    dlg.setVisible(true);
    fr.setVisible(true);

    Let's make it very clear : it is NOT possible to add
    the same instance of a component to two different
    containers.
    Is it possible to have frame with component.. but on closing that frame component shifts to another frame.. and vice versa I will add to the above:
    it is NOT possible to add the same instance of a component to two different containers... at the same time. Does that clarify it?
    Why is it so hard to try it yourself?
    Instead of waiting a couple of hours hoping someone answers the question you could have solved your problem in a couple of minutes.

Maybe you are looking for