Would you like to react to this message? Create an account in a few clicks or log in to continue.

ҧҧ GUI Swing

Go down

ҧҧ GUI  Swing Empty ҧҧ GUI Swing

ตั้งหัวข้อ  Admin Wed May 28, 2008 12:20 pm

hello.java extends Frame
package simple;

import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class hello extends Frame{

public static int WIDTH =250;
public static int HEIGHT =150;

public hello(String lab){
super(lab);
}

public static void main(String[] args) {

hello frame = new hello("Hello Test");

frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
System.out.print("Exit Program");
System.exit(0);
}
});

frame.setSize(WIDTH,HEIGHT);
frame.add(new HelloPanel()); // Add File HelloPanel Contrainer
frame.show();
}

}




HelloPanel.java extends JPanel
package simple;

import java.awt.Font;
import java.awt.LayoutManager;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class HelloPanel extends JPanel{

public HelloPanel() {
JLabel textHello = new JLabel("Hello World");

textHello.setFont(new Font("Microsoft sans serif",Font.PLAIN,16));

add(textHello);
}


}

Admin
Admin
Admin

จำนวนข้อความ : 112
Registration date : 18/05/2008

http://chawban.chocoforum.com

ขึ้นไปข้างบน Go down

ҧҧ GUI  Swing Empty Re: ҧҧ GUI Swing

ตั้งหัวข้อ  Admin Wed May 28, 2008 12:39 pm

package simple;
import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class hello extends Frame{
public static int WIDTH =550;
public static int HEIGHT =550;

public hello(String lab){
super(lab);
}

public static void main(String[] args) {

hello frame = new hello("Hello Test");

frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
System.out.println("Exit Program");
System.exit(0);
}
public void windowOpened(WindowEvent e){
System.out.println("ʴը");
}
public void windowDeactivated(WindowEvent e){
System.out.println("˹й͹ա");
}
public void windowActivated(WindowEvent e){
System.out.println("");
}
});

frame.setSize(WIDTH,HEIGHT);
frame.add(new HelloPanel());
frame.show();
}
}
Admin
Admin
Admin

จำนวนข้อความ : 112
Registration date : 18/05/2008

http://chawban.chocoforum.com

ขึ้นไปข้างบน Go down

ขึ้นไปข้างบน

- Similar topics

 
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ