Results 1 to 9 of 9
  1. #1
    pamm is offline Member
    Join Date
    Sep 2011
    Posts
    12
    Rep Power
    0

    Question JFrame, Jdialog or Application Window

    Hi!

    I'm working with Eclipse, and I want to start a new swing application.
    I don't know witch to choose...JFrame, Jdialog or Application Window. My guess is Application Window...
    Can someone explain me the difference between them? They are all windows... :P


    Thanks

    Paula

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,519
    Blog Entries
    7
    Rep Power
    20

    Default Re: JFrame, Jdialog or Application Window

    I can't find any ApplicationWindow class in the JSE core distribution, so I'd say pick a JFrame ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    pamm is offline Member
    Join Date
    Sep 2011
    Posts
    12
    Rep Power
    0

    Default Re: JFrame, Jdialog or Application Window

    Ok! I'm starting with JFrame! :)
    Keep it simple!
    Thanks!

    Paula

    Quote Originally Posted by JosAH View Post
    I can't find any ApplicationWindow class in the JSE core distribution, so I'd say pick a JFrame ...

    kind regards,

    Jos

  4. #4
    pamm is offline Member
    Join Date
    Sep 2011
    Posts
    12
    Rep Power
    0

    Default Re: JFrame, Jdialog or Application Window

    Above the two classes created by Eclipse...
    What sould I pick? :)
    Paula

    JFrame

    import java.awt.BorderLayout;
    import java.awt.EventQueue;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.border.EmptyBorder;


    public class Testframe extends JFrame {

    private JPanel contentPane;

    /**
    * Launch the application.
    */
    public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
    public void run() {
    try {
    Testframe frame = new Testframe();
    frame.setVisible(true);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    });
    }

    /**
    * Create the frame.
    */
    public Testframe() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 450, 300);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);
    }

    }

    Application window

    import java.awt.EventQueue;
    import javax.swing.JFrame;


    public class TestWindow {

    private JFrame frame;

    /**
    * Launch the application.
    */
    public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
    public void run() {
    try {
    TestWindow window = new TestWindow();
    window.frame.setVisible(true);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    });
    }

    /**
    * Create the application.
    */
    public TestWindow() {
    initialize();
    }

    /**
    * Initialize the contents of the frame.
    */
    private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
    }

    }
    Last edited by pamm; 09-30-2011 at 04:38 PM.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JFrame, Jdialog or Application Window

    Your questions suggest that you may be Swing tutorial deficient. Please do yourself a favor and read the Swing tutorial regarding top level containers, JFrames, and JPanels to start with. Otherwise you're in for a very bumpy and frustrating ride.

  6. #6
    pamm is offline Member
    Join Date
    Sep 2011
    Posts
    12
    Rep Power
    0

    Default Re: JFrame, Jdialog or Application Window

    I know the difference between JFrame an JPanel. I know I have much to learn, perhaps I'm "Swing tutorial deficient". I'm going to follow your advice and read a little more about it (I have much to learn), but... since I have these options in Eclipse and I have to start with something... I want to know more about it.
    I think they are basically the same (I may be wrong), that's why I asked for your opinion!
    If you want to give it it's ok, if you don't, I just have to discover myself why they put this two options when creating a swing class in Eclipse.

    Thank you

    Paula

    Quote Originally Posted by Fubarable View Post
    Your questions suggest that you may be Swing tutorial deficient. Please do yourself a favor and read the Swing tutorial regarding top level containers, JFrames, and JPanels to start with. Otherwise you're in for a very bumpy and frustrating ride.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JFrame, Jdialog or Application Window

    Quote Originally Posted by pamm View Post
    I know the difference between JFrame an JPanel. I know I have much to learn, perhaps I'm "Swing tutorial deficient". I'm going to follow your advice and read a little more about it (I have much to learn), but... since I have these options in Eclipse and I have to start with something... I want to know more about it.
    I think they are basically the same (I may be wrong), that's why I asked for your opinion!
    They are not the same, not at all -- and the tutorials will tell you all this, and much better than we can.

    Are you using a drag and drop code builder with Eclipse to build your Swing application? If so I strongly advise you not to do this until you know Swing well as they can cause more problems initially then help.

  8. #8
    pamm is offline Member
    Join Date
    Sep 2011
    Posts
    12
    Rep Power
    0

    Default Re: JFrame, Jdialog or Application Window

    Can you give me a name of a good book or link to a good tutorial.
    I can create a frame from scratch, but I don't have much experience.
    Some friend told me that's the easy and fastest way to create a swing application (drag and drop), usually I write the code myself without any help (drag and drop).

    Thanks

    Paula

    Quote Originally Posted by Fubarable View Post
    They are not the same, not at all -- and the tutorials will tell you all this, and much better than we can.

    Are you using a drag and drop code builder with Eclipse to build your Swing application? If so I strongly advise you not to do this until you know Swing well as they can cause more problems initially then help.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JFrame, Jdialog or Application Window

    Quote Originally Posted by pamm View Post
    Can you give me a name of a good book or link to a good tutorial.
    No problem, check here first: Using Swing Components.

    I can create a frame from scratch, but I don't have much experience.
    Some friend told me that's the easy and fastest way to create a swing application (drag and drop), usually I write the code myself without any help (drag and drop).
    It's the quickest way to get a quick and dirty very simple application together yes, but once you get beyond the most basic and try to modify it, it can get very tricky especially if you're new to Swing. I recommend it for prototyping or general use if you're adept with Swing, but if you're learning Swing, it will increase your struggling and won't help you learn it (these code generators usually produce ugly code).

Similar Threads

  1. How to show JDialog is a JFrame ?
    By xuanhung123 in forum AWT / Swing
    Replies: 6
    Last Post: 07-21-2010, 03:32 PM
  2. Replies: 9
    Last Post: 06-16-2010, 03:42 AM
  3. Communicate JFrame with JDialog
    By BeRniTo in forum AWT / Swing
    Replies: 2
    Last Post: 08-31-2009, 02:07 PM
  4. Returning data from a JFrame/JDialog?!
    By Joe2003 in forum AWT / Swing
    Replies: 6
    Last Post: 01-08-2009, 12:14 AM
  5. problems with jDialog in a JFrame
    By bbq in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 04:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •