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