2011-08-12 11 views
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); 
    } 
    }); 

    } 

    } 

ボタンをクリックしたときにプログレスバーのフレームが表示されません。

誰でも知っているのはなぜですか?

ありがとう

+0

[プログレスバーの使用方法](http://download.oracle.com/javase/tutorial/uiswing/components/progress.html)も参照してください。 – trashgod

+0

[Java GUI JProgressBarペイントしない]の複製が可能です。(http://stackoverflow.com/questions/3154847/java-gui-jprogressbar-not-painting) – trashgod

+0

実際にコンパイルできるコードを提供するのに適していますか? 。 – sgibly

答えて

1

あなたのコードはコンパイルされません。

これは実際にコンパイルして、進行状況バーを表示します。

import javax.swing.*; 
import java.awt.*; 
import java.awt.event.*; 

public class Pipo extends JFrame{ 

private static JPanel panel1 = null; 
private static JPanel panel2 = null; 

static JProgressBar progressBar = null; 
static JButton button = null; 

static Pipo f1 = null; 
static Pipo f = null; 

public static void main(String[] args) { 

    f = new Pipo(); 

    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(button, BorderLayout.SOUTH); 

    f.setContentPane(panel1); 
    f.setVisible(true); 

    f1 = new Pipo(); 

    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(progressBar, BorderLayout.SOUTH); 

    f1.setContentPane(panel2); 

    button.addActionListener(new ActionListener() { 
     public void actionPerformed(ActionEvent e){ 
      f1.setVisible(true); 
     } 
    }); 

    } 
} 
+0

助けてくれてありがとう!!!!!!!! – dula

関連する問題