出了什么问题 发出来啊
还有代码
代码如下:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Untitled1
extends JFrame implements ActionListener {
JFrame jf;
JPanel jp1;
JPanel jp2;
JButton jb1;
JLabel jl;
JLabel jll;
BorderLayout br;
public void test() {
setTitle("1234");
br = new BorderLayout();
jp1 = (JPanel) getContentPane();
jp2 = (JPanel) getContentPane();
jl = new JLabel("12345");
jll = new JLabel("54321");
jb1 = new JButton("点我啊");
jb1.add(jp1);
jl.add(jp1);
jll.add(jp2);
this.setVisible(true);
jp1.setVisible(true);
jp2.setVisible(false);
setSize(400, 300);
jb1.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
this.setVisible(true);
jp1.setVisible(false);
jp2.setVisible(true);
}
public static void main(String[] args) {
Untitled1 ts = new Untitled1();
}
}
能够通过编译,可是运行下来什么都没有!要怎么改啊??
太粗心了
可是为什么出来的面板上什么都没有啊???
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Untitled1
extends JFrame implements ActionListener {
JFrame jf;
JPanel jp1;
JPanel jp2;
JButton jb1;
JLabel jl;
JLabel jll;
BorderLayout br;
public void test() {
setTitle("1234");
br = new BorderLayout();
jp1 = (JPanel) getContentPane();
jp2 = (JPanel) getContentPane();
jl = new JLabel("12345");
jll = new JLabel("54321");
jb1 = new JButton("点我啊");
jp1.add(jl, java.awt.BorderLayout.CENTER);
jp1.add(jb1, java.awt.BorderLayout.WEST);
jp2.add(jll, java.awt.BorderLayout.CENTER);
jp1.setVisible(true);
jp2.setVisible(false);
setSize(400, 300);
setVisible(true);
jb1.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
jp1.setVisible(false);
jp2.setVisible(true);
}
public static void main(String[] args) {
Untitled1 ts = new Untitled1();
ts.setDefaultCloseOperation(EXIT_ON_CLOSE);
ts.test();
}
}