Results 1 to 9 of 9
- 09-30-2011, 04:07 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 12
- Rep Power
- 0
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
- 09-30-2011, 04:14 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
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,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 09-30-2011, 04:19 PM #3
Member
- Join Date
- Sep 2011
- Posts
- 12
- Rep Power
- 0
- 09-30-2011, 04:26 PM #4
Member
- Join Date
- Sep 2011
- Posts
- 12
- Rep Power
- 0
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.
-
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.
- 09-30-2011, 10:55 PM #6
Member
- Join Date
- Sep 2011
- Posts
- 12
- Rep Power
- 0
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
-
Re: JFrame, Jdialog or Application Window
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.
- 09-30-2011, 11:20 PM #8
Member
- Join Date
- Sep 2011
- Posts
- 12
- Rep Power
- 0
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
-
Re: JFrame, Jdialog or Application Window
No problem, check here first: Using Swing Components.
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).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).
Similar Threads
-
How to show JDialog is a JFrame ?
By xuanhung123 in forum AWT / SwingReplies: 6Last Post: 07-21-2010, 03:32 PM -
JTextField & JTextArea won't receive focus in a modal JDialog window
By javaexplorer in forum AWT / SwingReplies: 9Last Post: 06-16-2010, 03:42 AM -
Communicate JFrame with JDialog
By BeRniTo in forum AWT / SwingReplies: 2Last Post: 08-31-2009, 02:07 PM -
Returning data from a JFrame/JDialog?!
By Joe2003 in forum AWT / SwingReplies: 6Last Post: 01-08-2009, 12:14 AM -
problems with jDialog in a JFrame
By bbq in forum AWT / SwingReplies: 1Last Post: 07-05-2007, 04:14 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks