问题描述
- JTabbedPane中添加了JPanel,然后在Jpanel中如何添加JInternalFrame
-
代码如下
public class TestInternalFrame {
private JFrame frame = new JFrame("JInternalFrame");
// private JTabbedPane tab = new JTabbedPane();
private JPanel mainPanel = (JPanel) frame.getContentPane();
private JDesktopPane desk = new JDesktopPane();
private JInternalFrame internalFrame = new JInternalFrame();
private JPanel internalPanel = new JPanel();
public TestInternalFrame()
{internalPanel.add(new JLabel(new ImageIcon("D:/java/mylove.jpg"))); internalFrame.add(internalPanel); desk.add(internalFrame); mainPanel.add(desk,BorderLayout.CENTER); internalFrame.pack(); internalFrame.setVisible(true);
// frame.add(tab);
// tab.addTab("图片", mainPanel);frame.setVisible(true); frame.setSize(500,500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { new TestInternalFrame(); }
解决方案
看看你的“D:/java/mylove.jpg”引用的图片路径是否有问题,代码是对的。
时间: 2024-12-03 06:49:23