2017-04-25 24 views
0

私は、割り当てのための小さなGUIの作業を開始したばかりですが、起動時にタイトルから離れたものは表示されません。JFrameにコンテンツが表示されない

マイコード:

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



public class Property extends JFrame 
{ 
/*private String propertyType; 
private String propertyAddress; 
private double propertyArea; 
private int numOfBedrooms; 
private int numOfGarages; 
private int numOfToilets; 
private String ownerGivenName; 
private String ownerSurname; 
private String ownerdateOfBirth;*/ 

    JButton PropertySaleButton = new JButton("Add New Property"); 
JButton PurchaseOfferButton = new JButton("Submit Purchase Offer"); 



public Property() 
    { 
    setLayout (new FlowLayout()); 

      add(PropertySaleButton); 
    add(PurchaseOfferButton); 
} 

      public static void main(String[] args) 
    { 
     EventQueue.invokeLater(() -> 
     { 
      JFrame frame = new JFrame("CQ Real Estate"); 
      /*Image img = new ImageIcon("icon.gif").getImage(); 
      setIconImage(img);*/ 
      frame.setSize(450, 500); 
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
      frame.setVisible(true); 

     }); 
} 
} 

誰もが、私はそれをいただければ幸いです欠けているものを私に伝えることができます。

+3

、あなたは' Property'インスタンスを作成しないでください。 'JFrame frame = new Property();'を少なくとも使ってください。 (答えとして追加されました) – AxelH

+0

あなたは 'new Property()'を呼び出さない –

答えて

0

Propertyは、「GUIデザイン」を保持するクラスですが、使用しませんでした。 JFrameを作成します。代わりに、あなたは少しあなたのコードを適応する必要がありますProperty

JFrame frame = new Property(); 

instace(タイトルを追加する)を作成します。

+0

ありがとうございます:) – DivineMeliodas

1

することにコードを変更してみてください:あなたが唯一の空の `JFrame`を作成

this.getContentPane.add(PropertySaleButton); 
this.getContentPane.add(PurchaseOfferButton); 
関連する問題