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

前端 未结 5 878
谎友^
谎友^ 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条回答
  •  旧时难觅i
    2020-12-12 17:41

    I have used swing library from L2FProd. The Status bar library they have provided is very good.

    Below is how you would use it:

    1. Download the JAR they are providing and put it in your classpath
    2. The status bar internally divides the bar area into zone. Each zone can contain a Component (JLabel, JButton, etc). Idea is to fill the bar with required zones and the components.

    3. Instantiate the status bar as below....

      import java.awt.Component;
      import javax.swing.BorderFactory;
      import javax.swing.JLabel;
      import com.l2fprod.common.swing.StatusBar;
      
      StatusBar statusBar = new StatusBar();
      statusBar.setZoneBorder(BorderFactory.createLineBorder(Color.GRAY));
      statusBar.setZones(
          new String[] { "first_zone", "second_zone", "remaining_zones" },
          new Component[] {
              new JLabel("first"),
              new JLabel("second"),
              new JLabel("remaining")
          },
          new String[] {"25%", "25%", "*"}
      );
      
    4. Now add the above statusBar to the main panel you have (BorderLayout and set it to the south side).

    See a sample screenshot from one of the apps I am working on here (it has 2 zones). Let me know if you face any issues....

提交回复
热议问题