Java Swing - 如何使用GridBagLayout設(shè)置高度百分比...
我們想知道如何使用GridBagLayout設(shè)置高度百分比。...
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JProgressBar bar = new JProgressBar(JProgressBar.VERTICAL);
bar.setEnabled(true);
bar.setBackground(Color.YELLOW);
bar.setForeground(Color.GREEN);
bar.setStringPainted(true);
bar.setString("2000 g");
bar.setValue(65);
frame.setLayout(new BorderLayout());
frame.add(bar, BorderLayout.CENTER);
frame.setSize(500, 400);
frame.setVisible(true);
}
}