简体   繁体   中英

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

Im currently having trouble Displaying both labels ie text buttons etc and shapes in jframe at same time. What is happening is only the shapes display when i run it.
Can someone tell me how to enable both to be displayed at the same time. Thanks in advance

Below is some of the code for the labels which is in main class the shapes code is in a separate class:

    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();
}

You seem to have forgotten to add panel to the frame. The code should work fine after adding it.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM