Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding Buttons in JDesktoPane  RSS feed

 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

i am lost in adding Buttons to JDesktoPane i need help this is wat i did for adding the buttons but the buttons doesn't show.

private Container cpane;
privateJDesktopPane desktopPane = new JDesktopPane() ;

desktopPane.setBackground(Color.lightGray);
cpane = getContentPane();
cpane.setLayout(new FlowLayout());

JButton button = new JButton("Locker 1");

desktopPane.add(button);
cpane.add(desktopPane);

show()

this is wat i did for adding the button to a JDesktopPane.

If i am wrong pls guide me thanks you very much

also i need help in sloving this problem thanks

regards
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JDesktopPane is new to me, but after looking at the API and writing some test code, it appears that...
  • You still need to add the JDesktopPane to a top-level container, like a JFrame.
  • You add JInternalFrames to the JDesktopPane.
  • You can then add JButtons directly to the JInternalFrame (unless you want a JPanel).
  • Here's my test code...
    I think the bigger question is: Are you sure it's a JDesktopPane that you want?
    [ November 10, 2005: Message edited by: marc weber ]
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!