on button click,new window(internal frame)should open,what's wrong with my code? 有人可以解釋desktopane和內部框架之間的關係,只是 常規contentpane?on button click,new window(internal frame)should open,what's wrong with my code?
import javax.swing.*;
import java.awt.event.*;
public class tuna extends JFrame{
private JButton button1;
JDesktopPane desktop;
JInternalFrame internalFrame;
public tuna(){
super("iLyrics");
desktop = new JDesktopPane();
add(desktop);
button1 = new JButton("Open Internal Frame");
add(button1);
button1.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JInternalFrame internalFrame = new JInternalFrame("Internal Frame", true, true, true, true);
internalFrame.setBounds(110, 130, 105, 70);
desktop.add(internalFrame, JLayeredPane.DEFAULT_LAYER);
//desktop.add(internalFrame);
internalFrame.setVisible(true);
}
});
}
}
}
取而代之的是什麼? – cdeszaq
@cdeszaq什麼都沒有 –
你把尺寸設置爲JInternalFrame還是pack()呢?默認大小是0x0。 –