JButton customer = new JButton("ID");
      customer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
showForm();
          }
}
private void showForm()
{
  InterceptionPanel frm = new InterceptionPanel();
  frm.setVisible(true); }
InterceptionPanel这是我那个窗口的类
这样写弹不出InterceptionPanel类的窗口呀?是什么原因啊?可以说说吗?
望高手指点,马上给分!

解决方案 »

  1.   

    InterceptionPanel 是JPanel还是JFrame/JDialog?
    你要干吗啊?
    想点击JButton让InterceptionPanel显示?
      

  2.   

    对,InterceptionPanel 继承JPanel
      

  3.   

    frm.setSize(int,int);
    frm.setLocation();setLocation可以不用
    但setSize一定要的,不然将会当成零,即使有你也看不到
      

  4.   

    frm.setSize(int width,int height);
    frm.setLocation(int x, int y);
      

  5.   

    JPanel 能直接显示?好像不能吧
    JPanel是轻量级组件 必须放在JFrame JDialog等重量级组件上才能显示
    你把你那个InterceptionPanel 改成JDialog试试吧
      

  6.   

    晕,我以为是JFrame
    楼上说的对,JPanel必须加载在JFrame或者JDialog上才能显示
    就这个来说,看楼主的程序应该只是想要一个JDialog
      

  7.   

    我就是要在一个JPanel里设置一个按钮,然后点击按钮再弹出一个JPanel
    是不是要把这个JPanel先放在JDialog里然后在显示呀?
    要怎么放?谁可以说下好吗?
    我给代码,加我QQ,或给我留邮件也行,谢谢!
      

  8.   

    public class NewJDialogxx extends javax.swing.JDialog {
    private JPanel add_JP;
    private JButton add_JB;
    public NewJDialogxx(JFrame frame) {
    super(frame);
    initGUI();
    }

    private void initGUI() {
    try {
    {
    add_JP = new JPanel();
    getContentPane().add(add_JP, BorderLayout.NORTH);
    {
    add_JB = new JButton();
    add_JP.add(add_JB);
    add_JB.setText("jButton1");
    }
    }
    setSize(400, 300);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }}pulic class test{
    public static void main(String[] args) {
    JFrame frame = new JFrame();
    NewJDialogxx inst = new NewJDialogxx(frame);
    inst.setVisible(true);
    }
    }
      

  9.   

    Sprite_bei() ( ) 信誉:100    Blog 你的程序好像还没给JButton加侦听器,也没有处理Button的消息函数阿