swing-如何在Java应用程序的底部创建一个状态栏?
我正在创建Java应用程序,并且想要一个酒吧在应用程序底部,在其中显示文本栏和状态(进度)栏。
只有我似乎无法在NetBeans中找到该控件,我也不知道手动创建的代码。
5个解决方案
102 votes
创建一个带有BorderLayout的JFrame或JPanel,为其提供类似BevelBorder或线条边框的外观,以便将其与其余内容分开,然后在BorderLayout.SOUTH处添加状态面板。
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setSize(200, 200);
// create the status bar panel and shove it down the bottom of the frame
JPanel statusPanel = new JPanel();
statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
frame.add(statusPanel, BorderLayout.SOUTH);
statusPanel.setPreferredSize(new Dimension(frame.getWidth(), 16));
statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
JLabel statusLabel = new JLabel("status");
statusLabel.setHorizontalAlignment(Sw