java制作状态栏,如何在Java应用程序的底部创建一个条形图,如状态栏?

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 can't seem to find the control in NetBeans neither do I know the code to create in manually.

解决方案

Create a JFrame or JPanel with a BorderLayout, give it something like a BevelBorder or line border so it is seperated off from the rest of the content and then add the status panel at 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(SwingConstants.LEFT);

statusPanel.add(statusLabel);

frame.setVisible(true);

Here is the result of the above status bar code on my machine:

ikLft.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值