Article View: cn.bbs.comp.lang.java
Article #13006һ�������е�С���⣬��ѧ����Ц:)
From: ���ֵĴ�
Date: Sat, 10 Jul 2004 12:09
Date: Sat, 10 Jul 2004 12:09
76 lines
3487 bytes
3487 bytes
����52�е�ButtonTest.this��ΪʲôҪ��ôд��this���ò�������ڶ�����˵����
javadoc��������˵�ģ�
public static void showMessageDialog(Component parentComponent,
Object message,
String title,
int messageType)
parentComponent - determines the Frame in which the dialog is displayed; if
null, or if the parentComponent has no Frame, a default Frame is used
����ط��ܾ�����Щת��������ϣ����ֽ�������һЩ��
���⣬����������֮��������.class�ļ���
ButtonTest.class
ButtonTest$ButtonHandler.class
ButtonTest$1.class
���һ���Dz���һ�������ڲ��ָࣿ���dz����е��ĸ��ط���
// Fig. 13.10: ButtonTest.java
// Creating JButtons.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ButtonTest extends JFrame {
private JButton plainButton, fancyButton;
// set up GUI
public ButtonTest()
{
super( "Testing Buttons" );
// get content pane and set its layout
Container container = getContentPane();
container.setLayout( new FlowLayout() );
// create buttons
plainButton = new JButton( "Plain Button" );
container.add( plainButton );
Icon bug1 = new ImageIcon( "bug1.gif" );
Icon bug2 = new ImageIcon( "bug2.gif" );
fancyButton = new JButton( "Fancy Button", bug1 );
fancyButton.setRolloverIcon( bug2 );
container.add( fancyButton );
// create an instance of inner class ButtonHandler
// to use for button event handling
ButtonHandler handler = new ButtonHandler();
fancyButton.addActionListener( handler );
plainButton.addActionListener( handler );
setSize( 275, 100 );
setVisible( true );
} // end ButtonTest constructor
public static void main( String args[] )
{
ButtonTest application = new ButtonTest();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
// inner class for button event handling
private class ButtonHandler implements ActionListener {
// handle button event
public void actionPerformed( ActionEvent event )
{
JOptionPane.showMessageDialog( ButtonTest.this,
//???????????????????
"You pressed: " + event.getActionCommand() );
}
} // end private inner class ButtonHandler
} // end class ButtonTest
--
[m[1;31m�� ��Դ:���Ұ��Ͽ�վ nkbbs.org��[FROM: 10.21.2.74][m
Technical Details
Message-ID:
<4DB8DY$AWU@bbs.nankai.edu.cn>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!63.223.20.72!sjc1.usenetserver.com!news.usenetserver.com!news.bylinux.net!maily.cic.tsinghua.edu.cn!news2.happynet.org!NanKaiShow Full Headers
Complete Article Headers
X-Google-Thread: f6cb0,bb672dec3b19338,start X-Google-Attributes: gidf6cb0,public X-Google-Language: Chinese,GB Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!63.223.20.72!sjc1.usenetserver.com!news.usenetserver.com!news.bylinux.net!maily.cic.tsinghua.edu.cn!news2.happynet.org!NanKai From: khadgar.bbs@bbs.nankai.edu.cn (���ֵĴ�) Newsgroups: cn.bbs.comp.lang.java Subject: һ�������е�С���⣬��ѧ����Ц:) Date: 10 Jul 2004 12:09:06 GMT Organization: �Ұ��Ͽ�վ Message-ID: <4DB8DY$AWU@bbs.nankai.edu.cn> X-Filename: Java/M.1089460882.A Lines: 76