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类的窗口呀?是什么原因啊?可以说说吗?
望高手指点,马上给分!
customer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
showForm();
}
}
private void showForm()
{
InterceptionPanel frm = new InterceptionPanel();
frm.setVisible(true); }
InterceptionPanel这是我那个窗口的类
这样写弹不出InterceptionPanel类的窗口呀?是什么原因啊?可以说说吗?
望高手指点,马上给分!
你要干吗啊?
想点击JButton让InterceptionPanel显示?
frm.setLocation();setLocation可以不用
但setSize一定要的,不然将会当成零,即使有你也看不到
frm.setLocation(int x, int y);
JPanel是轻量级组件 必须放在JFrame JDialog等重量级组件上才能显示
你把你那个InterceptionPanel 改成JDialog试试吧
楼上说的对,JPanel必须加载在JFrame或者JDialog上才能显示
就这个来说,看楼主的程序应该只是想要一个JDialog
是不是要把这个JPanel先放在JDialog里然后在显示呀?
要怎么放?谁可以说下好吗?
我给代码,加我QQ,或给我留邮件也行,谢谢!
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);
}
}