close

class test
{
public static void main(String[] args)
{
;
}
}

1427437110-2327037667_n  

 

 

 

 

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

 

public class JButtonDemo2 {

 

JFrame jtfMainFrame;
JButton jbnButton1, jbnButton2;
JTextField jtfInput;
JPanel jplPanel;
public JButtonDemo2() {
jtfMainFrame = new JFrame("Frame1");
jtfMainFrame.setSize(50, 50);
jbnButton1 = new JButton("Button 1");
jbnButton2 = new JButton("Button 2");
jtfInput = new JTextField(20);
jplPanel = new JPanel();
jbnButton1.setMnemonic(KeyEvent.VK_I); 
jbnButton1.addActionListener(new ActionListener() {

 

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Hello!");
}
});
jbnButton2.setMnemonic(KeyEvent.VK_I);
jbnButton2.addActionListener(new ActionListener() {

 

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Hey!");
}
});
jplPanel.setLayout(new FlowLayout());
jplPanel.add(jtfInput);
jplPanel.add(jbnButton1);
jplPanel.add(jbnButton2);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jtfMainFrame.pack();
jtfMainFrame.setVisible(true);
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager
.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
}
JButtonDemo2 application = new JButtonDemo2();
}
}

1  

 

arrow
arrow
    全站熱搜

    a30021456 發表在 痞客邦 留言(0) 人氣()