简体   繁体   English

程序窗口不显示在框架中

[英]Program Window Doesn't Show In Frame

I have a program that has a login window, a register window and a program window. 我有一个具有登录窗口,注册窗口和程序窗口的程序。 When I run the program the login window pops up first and everything is good. 当我运行该程序时,将首先弹出登录窗口,一切正常。 I click register and that window pops up and everything is good, but when I click login, the program window will open but nothing will show in the frame. 我单击注册,然后弹出该窗口,一切正常,但是当我单击登录时,程序窗口将打开,但框架中将不显示任何内容。 I have all my components stored in a JTabbedPane and I store the JTabbedPane in a JPanel so that I can use it in the JFrame, but when I open the program window it shows a blank frame. 我将所有组件存储在JTabbedPane中,并将JTabbedPane存储在JPanel中,以便可以在JFrame中使用它,但是当我打开程序窗口时,它会显示一个空白框架。 The only thing is if you hover over a position where a textField is, it will show the text cursor and if you click it will bring up the text field! 唯一的事情是,如果将鼠标悬停在textField所在的位置,它将显示文本光标,如果单击它,将弹出文本字段! How do I get it to show all the components in the panel when the window opens? 窗口打开时,如何显示面板中的所有组件?

public JPanel panelProgram()
{
    programPanel.setLayout(null);

    tabbedPane = new JTabbedPane();
    tabbedPane.setBounds(0, 10, programW - 10, programH - 10);
    tabbedPane.setVisible(true);
    ImageIcon icon = new ImageIcon("src/cpt/admin/images/middle.gif");

    proPanTab1 = showInputScreen();
    tabbedPane.addTab("Input Accounts", icon, proPanTab1, "Input New Acocunts");

    proPanTab2 = showSearchScreen();
    tabbedPane.addTab("Search Accounts", icon, proPanTab2, "Search Through Accounts");

    proPanTab3 = showEmailScreen();
    tabbedPane.addTab("Send Email", icon, proPanTab3, "Send an Email to Accounts");

    tabbedPane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);

    programPanel.add(tabbedPane);

    return programPanel;
}

Using programPanel.setLayout(null); 使用programPanel.setLayout(null); will set the components in that panel to zero and thus will not show. 会将该面板中的组件设置为零,因此不会显示。 You can get the size of the components by calling getPreferredSize() . 您可以通过调用getPreferredSize()获得组件的大小。

You should use a LayoutManager for better layout alternatives. 您应该使用LayoutManager以获得更好的布局选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM