How to Contruct GUI [message #1694121] |
Thu, 30 April 2015 17:39 |
Michael Pelzer 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");
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.02858 seconds