Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » How to Contruct GUI(How to Constuct GUI from main method)
How to Contruct GUI [message #1694121] Thu, 30 April 2015 17:39 Go to next message
Michael Pelzer is currently offline Michael PelzerFriend
Messages: 1
Registered: April 2015
Junior Member
I am trying to get my main method to call the constructor method for my GUI. How I figure out what to use a parameters. I am finishing my first semester of introductory JAVA and trying to build a side program for fun. But this has got me stuck.

Thanks.

Here is main Method
import org.eclipse.swt.widgets.Composite;


public class CSBuilderMain {

public static void main(String[] args) {

CharBuilderGUI char1 = new CharBuilderGUI(, 1);

}
}

And the GUI
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;


public class CharBuilderGUI extends Composite {
private Text strTextBox;

/**
* Create the composite.
* @param parent
* @param style
*/
public CharBuilderGUI(Composite parent, int style) {
super(parent, style);
setLayout(null);

Label lblStrScore = new Label(this, SWT.NONE);
lblStrScore.setBounds(10, 10, 55, 15);
lblStrScore.setText("Str Score");

strTextBox = new Text(this, SWT.BORDER);
strTextBox.setBounds(78, 10, 76, 21);

Button btnRollStats = new Button(this, SWT.NONE);
btnRollStats.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
rollStats char1 = new rollStats();
int strScore = char1.statScoreGen();
strTextBox.setText("" + strScore);

}
});
btnRollStats.setBounds(281, 10, 75, 25);
btnRollStats.setText("Roll Stats");

}
Re: How to Contruct GUI [message #1694336 is a reply to message #1694121] Mon, 04 May 2015 14:13 Go to previous message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
A Composite is just a container widget. Your UI needs a Shell (window) to start. The Shell can contain the composite (and be its parent).
Previous Topic:windowbuilder and windowtester install for one eclipse version
Next Topic:I'm having trouble with alignment in the window builder. controls Wont snap into place.
Goto Forum:
  


Current Time: Wed Apr 24 21:00:37 GMT 2024

Powered by FUDForum. Page generated in 0.02858 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top