Results 1 to 2 of 2
- 11-25-2009, 05:35 AM #1
Member
- Join Date
- Aug 2008
- Posts
- 13
- Rep Power
- 0
how to link first form to second form?
Hai all,
i use swt framework. i create to form using swt in eclipse. in my first form i have a button. when the button is clicked, i want the second form is show and the first form is disposed. can you help me please??.
First Class
public class Swtapp {
private Shell shell;
SecondForm form;
public Swtapp(Display display) {
shell = new Shell(display);
shell.setText("Button");
initUI();
shell.setSize(250, 200);
shell.setLocation(300, 300);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
public void initUI() {
Button quit = new Button(shell, SWT.PUSH);
quit.setText("Quit");
quit.setBounds(50, 50, 80, 30);
quit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
form.display.sleep();
shell.getDisplay().dispose();
//System.exit(0);
}
});
}
public static void main(String[] args) {
Display display = new Display();
new Swtapp(display);
display.dispose();
}
}
second class
public class SecondForm {
public Shell shell;
public static Display display;
public SecondForm()
{
}
public SecondForm(Display display) {
shell = new Shell(display);
shell.setText("Button");
shell.setSize(250, 200);
shell.setLocation(300, 300);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
public static void main(String[] args)
{
display = new Display();
new SecondForm(display);
}
}Last edited by i4ba1; 11-25-2009 at 06:02 AM.
-
Wrong forum as this should be posted in the SWT forum, not the Swing forum. Moving.
Similar Threads
-
use Servlet submit the form to receive a form for the Chinese but it shows the garble
By dmt198704 in forum Java ServletReplies: 0Last Post: 10-31-2009, 09:24 AM -
Dynamic fields in form using Form Bean
By janu.c in forum Java SoftwareReplies: 1Last Post: 09-23-2009, 04:26 AM -
want to generate a html form page with dynamic data and submit this form to a url
By vishalkrsrivastava in forum Java AppletsReplies: 10Last Post: 08-12-2009, 04:02 PM -
[SOLVED] How to close the current form when i open a new form?
By tpyq in forum NetBeansReplies: 6Last Post: 11-28-2008, 06:55 AM -
Jtree link to JFrame Form
By daniel50096230 in forum NetBeansReplies: 4Last Post: 09-16-2008, 06:53 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks