0
在我正在開發這些天來顯示一個進度條,當點擊「轉換」按鈕,下面是我的代碼所需要的應用程序,的Java:進度條不顯示時點擊該按鈕
public class Main extends JFrame{
private JPanel panel2 = null;
private JPanel panel2 = null;
JProgressBar progressBar = null;
JButton button = null;
Main f1 = null;
Main f = null;
public static void main(String[] args) {
try
{
UIManager.setLookAndFeel(new SyntheticaBlackEyeLookAndFeel());
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void convert(){
f = new Main();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(700, 400);
f.setLocationRelativeTo(null);
f.setTitle("Fromat Conversion");
panel1 = new JPanel();
panel1.setLayout(new BorderLayout());
panel1.setForeground(Color.white);
button = new JButton();
button.setText("Convert");
panel1.add(panel3, BorderLayout.SOUTH);
f.setContentPane(panel1);
f.setVisible(true);
f1 = new Main();
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f1.setSize(457, 100);
f1.setTitle("Conversion Progress");
f1.setLocationRelativeTo(null);
panel2 = new JPanel();
panel2.setLayout(new BorderLayout());
panel2.setForeground(Color.white);
progressBar = new JProgressBar();
progressBar.setValue(35);
progressBar.setStringPainted(true);
panel2.add(label3, BorderLayout.WEST);
panel2.add(progressBar, BorderLayout.SOUTH);
f1.setContentPane(panel2);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
f1.setVisible(true);
}
});
}
}
但是當我點擊按鈕進度條框不顯示。
有人有想法,爲什麼?
謝謝
另請參閱[如何使用進度條](http://download.oracle.com/javase/tutorial/uiswing/components/progress.html)。 – trashgod
[Java GUI JProgressBar not painting]可能的重複(http://stackoverflow.com/questions/3154847/java-gui-jprogressbar-not-painting) – trashgod
提供實際可以編譯的代碼是一個很好的開始。 – sgibly