Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-25-2009, 06:35 AM
Member
 
Join Date: Aug 2008
Posts: 5
Rep Power: 0
i4ba1 is on a distinguished road
Question 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 07:02 AM.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-25-2009, 06:47 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 5,968
Rep Power: 7
Fubarable is on a distinguished road
Default
Wrong forum as this should be posted in the SWT forum, not the Swing forum. Moving.
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
use Servlet submit the form to receive a form for the Chinese but it shows the garble dmt198704 Java Servlet 0 10-31-2009 10:24 AM
Dynamic fields in form using Form Bean janu.c Java Announcements 1 09-23-2009 05:26 AM
want to generate a html form page with dynamic data and submit this form to a url vishalkrsrivastava Java Applets 10 08-12-2009 05:02 PM
[SOLVED] How to close the current form when i open a new form? tpyq NetBeans 6 11-28-2008 07:55 AM
Jtree link to JFrame Form daniel50096230 NetBeans 4 09-16-2008 07:53 AM


All times are GMT +2. The time now is 05:53 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org