2015-05-07 32 views
0

的對話框代碼:Netbeans的:一個JButton按鈕設置斜面可見

d1=new JDialog(this,"Help Menu",true); 
    // Set size 
    d1.setSize(500,180); 

    // Set some layout 
    d1.setLayout(new FlowLayout()); 

    d1.add(new JLabel("<html>Thank you for using the poster ordering system. <br> To begin, please select your desired poster size using the option menu provided. <br> Next, choose your desired poster style. <br> Now you can choose your quantity and background colour for your poster. <br> you are now finished! Your price will be displayed at the bottom right of the screen. <br> The pricing will show prices with and without VAT for your convenience.<br></html>")); 
    JButton button = new JButton("close"); 
    d1.setVisible(true); 




    button.addActionListener(new java.awt.event.ActionListener() { 
     @Override 
     public void actionPerformed(java.awt.event.ActionEvent evt) { 
      dispose(); 

     } 

    }); 

它說,它已經達到了文件的末尾解析之前,並不會顯示在幫助對話框中的「關閉」按鈕。當我添加「JButton.setVisible(true);」它說:「非靜態方法setVisible(布爾)不能從靜態上下文引用」

任何建議將不勝感激。 我是Java新手,現在讓我感到困惑!這一個

JButton button = new JButton("close"); 

回答

0

你沒有你的按鈕添加到的JDialog:

d1.add(button); 
+0

太好了!非常感謝,仍然在底部())掙扎; ),因爲它說:「解析之前到達文件的結尾? –

+0

@PhilMarsh你關閉了你的類與」}「? –

1

將以下代碼

static JButton button = new JButton("close"); 
+0

感謝您的任何想法」達到解析前結束文件「? –

+0

」非法開始表達「當我嘗試那個時出現! –

相關問題