Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将JTable添加到分层窗格_Java_Swing_Jtable_Jlayeredpane - Fatal编程技术网

Java 将JTable添加到分层窗格

Java 将JTable添加到分层窗格,java,swing,jtable,jlayeredpane,Java,Swing,Jtable,Jlayeredpane,我们可以在Java中将JTable添加到JLayeredPane吗?非常简单,使用JInternalFrame 使用适当的数据创建表。(例) public static void main(String args[]) { JFrame f = new JFrame("JDesktopPane Sample"); JTable jt = new JTable(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

我们可以在Java中将JTable添加到JLayeredPane吗?

非常简单,使用JInternalFrame

使用适当的数据创建表。(例)

public static void main(String args[]) {

    JFrame f = new JFrame("JDesktopPane Sample");

    JTable jt = new JTable();

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container content = f.getContentPane();

    JLayeredPane desktop = new JDesktopPane();

    Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3"},
        { "Row2-Column1", "Row2-Column2", "Row2-Column3"} };

    Object columnNames[] = { "Column One", "Column Two", "Column Three"};

    JTable table = new JTable(rowData, columnNames);

    desktop.setOpaque(false);
    desktop.add(createLayer2(table),JLayeredPane.POPUP_LAYER);
    content.add(desktop, BorderLayout.CENTER);
    f.setSize(300, 200);
    f.setVisible(true);
}



public static JInternalFrame createLayer2(JTable n) {

    return new SelfInternalFrame2(n);

}


static class SelfInternalFrame2 extends JInternalFrame {

    public SelfInternalFrame2(JTable n) {

        getContentPane().add(n, BorderLayout.CENTER);

        setBounds(50, 50, 100, 100);

        setResizable(true);

        setClosable(true);

        setMaximizable(true);

        setIconifiable(true);

        setVisible(true);

    }

}