new Swing project

A

Arne Vajhøj

What is the easiest way to start a new Swing project in Eclipse?

You prefer to write the code yourself => plain Java project.

You prefer GUI builder => install the plugin and then pick Swing project
type.

Arne
 
B

bob smith

You prefer to write the code yourself => plain Java project.



You prefer GUI builder => install the plugin and then pick Swing project

type.



Arne

I don't see a GUI Builder for Eclipse. Can you provide a link please?
 
A

Arne Vajhøj

I don't see a GUI Builder for Eclipse. Can you provide a link please?

It is called WindowBuilder.

You can find it in Eclipse MarketPlace by name.

Arne
 
L

Lew

Arne said:
You prefer to write the code yourself => plain Java project.

You prefer GUI builder => install the plugin and then pick Swing project
type.

I have no evidence that this is the easiest way, but it's the way I first tried
in response to this question:

- Open Eclipse.
- Menu: File New Project
- New project dialog: "Java Project" Next> (I have no Swing plugin)
- Project Name: "Whatever", "Use default location", Next>
- Finish

Context-menu click on project in "Package Explorer" window
- "New" > "Class"
- Package: "com.example.whatever"
- Name: "Example"
- Check "public static void main(String[] args)" and "Generate comments"
- Finish

You get:

/**
* Example.
*/
package com.example.whatever;

/**
* Example.
*
*/
public class Example {

/**
* main.
*
* @param args
*/
public static void main(String[] args) {

}

}

Then start adding Swingish stuff.

public class Example {
private static final String TITLE="Example Swing App";

static final Logger logger = Logger.getLogger(Example.class.getSimpleName());

private final JFrame appWindow = new JFrame(TITLE);

/**
* Constructor.
*/
public Example()
{
appWindow.pack();
}

/**
* Run the screen.
*/
public void run()
{
appWindow.setVisible(true);
}

/**
* main.
*
* @param args String array of arguments.
*/
public static void main(String[] args) {
logger.fine("main()");

Runnable gui = new Runnable()
{
@Override public void run()
{
new Example().run();
}
};
SwingUtilities.invokeLater(gui);
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top