簡體   English   中英

同時在jframe中顯示標簽,即文本等和形狀

[英]Displaying both labels ie text etc and shapes in jframe at same time

我當前遇到問題同時顯示兩個標簽,即文本按鈕等和jframe中的形狀。 發生的事情只是我運行時顯示的形狀。
有人可以告訴我如何同時顯示兩者。 提前致謝

下面是一些標簽的代碼,在主類中,形狀代碼在一個單獨的類中:

    JLabel label1 = new JLabel (" some text wont display\n for some reason");
    c.gridx = 0;
    c.gridy = 0;

    panel.add(label1,c);

    JButton button1 = new JButton ("4");
    c.gridx = 15;
    c.gridy = 0;
    panel.add(button1,c);

    //now to call from the shapes class to have a couple of shapes.

    GuiDog object= new GuiDog();
    frame.add(object);

    object.drawing();
}

您似乎忘記了將面板添加到框架中。 添加后代碼應該可以正常工作。

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM