computer °æ (¾«»ªÇø)
·¢ÐÅÈË: arbo (arbo), ÐÅÇø: program
±ê Ìâ: java ±Ê¼Ç6
·¢ÐÅÕ¾: ÌýÌÎÕ¾ (2001Äê09ÔÂ17ÈÕ10:47:17 ÐÇÆÚÒ»), Õ¾ÄÚÐżþ
ÌÐò½»»¥)
Swing (JFCÖ÷Òª½¹µã£©
Swing, the Pluggable look and feel , just like Unix environment
Swing Êǽ¨ÖþÔÚÒ»¸öÐÔµÄcomponent, JComponentÉÏ
JApplet, Jbutton, JCombobox, JOptionPane,
Jlist, JLabel,JScrollPane, JTable,JScrollBar, JSlider, JTooltip, JTree
next will give a basic swing application
It create a HelloSwing Frame, with a button, when click, it will
count the click number.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.accessibility.*;
public class t implements ActionListener{
private JFrame jFrame;
private JLabel jLabel;
private JPanel jPanel;
private JButton jButton;
private AccessibleContext accContext;
private String labelPrefix= "Number of clicks:";
private int numClicks=0;
public void go(){
jFrame=new JFrame("HelloSwing");
jlabel=new JLabel(labelPrefix+"0");
jButton=new JButton("I am a swing button");
jButton.setMnemonic('i');
jButton.addActionListener(this);
accContext=jButton.getAccessibleContext();
accContext.setAccessibleDescription("Press this button increments "+
"the number of button clicks");
jPane=new jPanel();
jPanel.setBorder(BorderFactory.createEmptyBorder(30,30,10,30));
jPanel.setLayout(new GridLayout(0,1));
jPanel.add(jButton);
jPanel.add(jLabel);
jFrame.setContentpane(jPanel);
WindowListener w1=new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
};
jFrame.addWindowListener(w1);
jFrame.pack();
jFrame.setVisible(true);
}
public void actionPerformed(ActionEvent e){
numClicks++;
jLabel.setText(labelPrefix+numClicks);
}
public static void main(String a[]){
HelloSwing helloSwing =new HelloSwing ();
helloSwing.go();
}
}
--
--
¡ù À´Ô´:¡¤ÌýÌÎÕ¾ tingtao.dhs.org¡¤[FROM: ÄäÃûÌìʹµÄ¼Ò]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
Ò³ÃæÖ´ÐÐʱ¼ä£º0.840ºÁÃë