This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
hello all, I want to set the size for the panel within a frame. When i run the below i get a small pink panel with the buttons at the bottom of the frame, but i am not able to increase the size of the panel. i tried to add the line 14 but does not help. Kindle help me.
import java.awt.*; public class CompLay extends Frame{ public static void main(String argv[]){ CompLay cl = new CompLay();
} CompLay() { Panel p = new Panel(); p.setBackground(Color.pink); p.add(new Button("One")); p.add(new Button("Two")); p.add(new Button("Three")); add("South",p); // setLayout(new FlowLayout()); Line 14//p.setSize(300,300); setSize(600,600); setVisible(true); } } thanks mala
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
Try this, Panel p = new Panel(); p.setBackground(Color.pink); p.add(new Button("One")); p.add(new Button("Two")); p.add(new Button("Three")); setLayout(null); add(p); p.setBounds(100,100,300,300); setSize(600,600); setVisible(true); -------- Note: if you are using a layout manager you can not control the panel's size using setSize() or setBounds()