How can I create a bar in the bottom of a Java app, like a status bar?

前端 未结 5 868
谎友^
谎友^ 2020-12-12 17:07

I am in the process of creating a Java app and would like to have a bar on the bottom of the app, in which I display a text bar and a status (progress) bar.

Only I c

5条回答
  •  自闭症患者
    2020-12-12 17:51

    For a more modern look than the accepted answer go with a GridBagLayout and a JSeparator:

    JPanel outerPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1;
    gbc.weighty = 0;
    
    JPanel menuJPanel = new JPanel();
    menuJPanel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.RED));
    outerPanel.add(menuJPanel, gbc);
    
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1;
    
    JPanel contentJPanel = new JPanel();
    contentJPanel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLUE));
    outerPanel.add(contentJPanel, gbc);
    
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weighty = 0;
    gbc.insets = new Insets(0, 0, 0, 0);
    
    outerPanel.add(new JSeparator(JSeparator.HORIZONTAL), gbc);
    outerPanel.add(new JPanel(), gbc);
    

提交回复
热议问题