import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestText extends JFrame implements ActionListener{
JTextArea text;
JButton next;
public TestText(){
super("Test Text");
text = new JTextArea("第一题 ");
next = new JButton("下一题");
JPanel pane = new JPanel();
pane.add(text);
pane.add(next);
this.getContentPane().add(pane,BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == next) {
JTextArea a = new JTextArea("第二题");
}
}
public static void main(String args[]) {
TestText tt = new TestText();
tt.setSize(400,300);
tt.setVisible(true);
tt.setVisible(true);
tt.setResizable(false);
tt.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
import java.awt.event.*;
import javax.swing.*;
public class TestText extends JFrame implements ActionListener{
JTextArea text;
JButton next;
public TestText(){
super("Test Text");
text = new JTextArea("第一题 ");
next = new JButton("下一题");
JPanel pane = new JPanel();
pane.add(text);
pane.add(next);
this.getContentPane().add(pane,BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == next) {
JTextArea a = new JTextArea("第二题");
}
}
public static void main(String args[]) {
TestText tt = new TestText();
tt.setSize(400,300);
tt.setVisible(true);
tt.setVisible(true);
tt.setResizable(false);
tt.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
/**
* serialVersionUID of long.
*/
private static final long serialVersionUID = 1L;
JTextArea text;
JButton next; public B() {
super("Test Text");
text = new JTextArea("第一题 ");
next = new JButton("下一题");
JPanel pane = new JPanel();
pane.add(text);
pane.add(next);
this.getContentPane().add(pane, BorderLayout.CENTER);
next.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {
text.setText("第二题");
}
});
} public static void main(String args[]) {
B tt = new B();
tt.setSize(400, 300);
tt.setVisible(true);
tt.setVisible(true);
tt.setResizable(false);
tt.setDefaultCloseOperation(EXIT_ON_CLOSE);
}}
/**
* serialVersionUID of long.
*/
private static final long serialVersionUID = 1L;
JTextArea text;
JButton next; public B() {
super("Test Text");
text = new JTextArea("第一题 ");
next = new JButton("下一题");
JPanel pane = new JPanel();
pane.add(text);
pane.add(next);
this.getContentPane().add(pane, BorderLayout.CENTER);
next.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == next) {
text.setText("第二题");
}
} public static void main(String args[]) {
B tt = new B();
tt.setSize(400, 300);
tt.setVisible(true);
tt.setVisible(true);
tt.setResizable(false);
tt.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}