close

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

class test
{
public static void main(String[] args)
{
JFrame jtfMainFrame = new JFrame("安安");

jtfMainFrame.setSize(300, 250);

JButton jbnButton1 = new JButton("Button 1");

JButton jbnButton2 = new JButton("Button 2");

JButton jbnButton3 = new JButton("Button 3");

JButton jbnButton4 = new JButton("Button 4");

JButton jbnButton5 = new JButton("Button 5");

JButton jbnButton6 = new JButton("Button 6");

JButton jbnButton7 = new JButton("Button 7");

JButton jbnButton8 = new JButton("Button 8");

JButton jbnButton9 = new JButton("Button 9");

JTextField jtfInput = new JTextField(20);

JPanel jplPanel = new JPanel();

jplPanel.add(jtfInput);

jplPanel.add(jbnButton1);

jbnButton1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Button 1!");
}
});

jplPanel.add(jbnButton2);

jbnButton2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Button 2!");
}
});

jplPanel.add(jbnButton3);

jbnButton3.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Button 3!");
}
});

jplPanel.add(jbnButton4);

jbnButton4.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Button 4!");
}
});

jplPanel.add(jbnButton5);

jbnButton5.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Button 5!");
}
});

jplPanel.add(jbnButton6);

jbnButton6.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Button 6!");
}
});

jplPanel.add(jbnButton7);

jbnButton7.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Button 7!");
}
});

jplPanel.add(jbnButton8);

jbnButton8.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Button 8!");
}
});

jplPanel.add(jbnButton9);

jbnButton9.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
jtfInput.setText("Button 9!");
}
});

jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);

jtfMainFrame.setVisible(true);

System.out.print("Feng-Chia");
}
}

1428649318-3955960257_n  

arrow
arrow
    全站熱搜

    <a href="http:// 發表在 痞客邦 留言(0) 人氣()