[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.newcomer] Question regarding visual editor
|
Hi All,
I have what I imagine may seem a very silly question... but I just had the
need for a *very* simple GUI app, and I decided to play with Eclipse's
visual editor tool. You can get to this by adding a "Visual Class" to
your project.
It worked fine, and I set the LayoutManager to null (as I saw in a demo on
eclipse.org), so that I could simply position my widgets wherever I wanted.
That all worked great, and if I hit "run as bean" my app would come up,
and it worked exactly as I wanted.
In order to have it run as a regular Java app I added a public static void
main(String args[]) routine, and had it setup a JFrame, and then add an
instance of my visual class.
That worked fine except that the resulting window (when I ran the app) was
tiny. In order to be able to see any of my windows I had to manually grab
the window handles and resize the window. I couldn't figure out how to
get the window to automatically be the correct size.
I tried using some of the layout managers, and if I did that, then the
window wasn't too small, but I'm struggling with getting things laid out
how I want using the layout managers (I'm new to Java GUI development).
For my purposes I'd rather just position them exactly where I want. I'm
the only one that is ever going to use this app that I'm writing, and if I
ever want it changed, I'll change it.
So basically my question is, can I use the visual editor to design a class
with no layout manager (positioning the widgets precisely where I want),
and use that in an app somehow? If I just add it like this:
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("MyApp");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MyAppGUI app = new MyAppGUI();
frame.getContentPane().add(app);
//Display the window.
frame.pack();
frame.setVisible(true);
Then I wind up with the tiny window that I described...