Hi,
scenario:
i was working on a swing application,which involved placing one panel inside another hence i placed the panel2(layout:borderlayout) inside another panel1(layout: box layout),but when i tryed to change the size of panel2 with the help of setPrefferedsize() method it failed to resize the panel! please provide me any hint on this problem,do you have to use the method setMaximumsize() or sumthing?.
apologies if my english was bad!
class CallMe extends JDialog { public CallMe() { initUI(); } public void initUI() { setTitle("Tip of the Day"); setLocation(350,150); setSize(1000,1000); setDefaultCloseOperation(DISPOSE_ON_CLOSE); JPanel parentpanel=new JPanel(); BoxLayout box=new BoxLayout(parentpanel,BoxLayout.Y_AXIS); parentpanel.setLayout(box); JPanel toppanel=new JPanel(); BorderLayout borderlayout=new BorderLayout(); toppanel.setLayout(borderlayout); [B] toppanel.setPreferredSize(new Dimension(400,50)); [/B] toppanel.setBackground(Color.red); JLabel label=new JLabel("JDeveloper Productivity Hints"); label.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); toppanel.add(label,BorderLayout.WEST); ImageIcon icon=new ImageIcon("c:\\pics\\ship.png"); JLabel label2=new JLabel(icon); label2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 30)); toppanel.add(label2,BorderLayout.EAST); JSeparator seperator=new JSeparator(); seperator.setForeground(Color.gray); toppanel.add(seperator,BorderLayout.SOUTH); [B]parentpanel.add(toppanel);[/B] add(parentpanel); } }
Kind regards,
Manish87