views:

150

answers:

3

hi

can we use a JInternalFame with a button into the main fram (by JDesktopPane of corz), the button that open up the JInternalFame ? how?

thks

+2  A: 

I don't really understand the question so I will just make some observations.

a) a JInternalFrme is like a frame in that you can add any component to it that you want

b) A JButton works the same whether it is added to an internal frame or a frame

I suggest you start by reading the Swing tutorial for working examples. You might start with the sections on "How to Use Internal Frames" and "How to Use Buttons".

If you still have problems then post your SSCCE that shows what you have tried.

camickr
+2  A: 

I don't know a way to put a JButton directly on a JDesktopPane, but you can use menu items to create and select a JInternalFame. In this example, each menu item uses an Action defined in the JInternalFame to select the corresponding frame.

Addendum: as @camickr suggests, it is technically possible to put a JButton directly on a JDesktopPane, but it might prove difficult to use in practice.

trashgod
A JDesktopPane is just like any panel that uses a "null layout". You can add any component to it as long as you set the bounds of the component. Of course it doesn't make sense to do this since an internal frame can be moved over the button, so a menu, or "toolbar" that sits outside the desktop pane is definitely a better choice.
camickr
@camickr: Thanks for clarifying this.
trashgod
A: 

I tried to put a JButton on the main frame but if i do so the button covers the internalframe or the internalframe covers the button,

I also tried to put a background in the main frame but it is the same problem the image covers the internalframe or the internalframe covers the image,

why I do this?

because the main frame with a gray or white background color is prety ugly this is why i want to put some buttons or background

tuxou
Sounds like your code is completely wrong. A JInternalFrame is added to a JDesktopPane. The background of a desktop pane is white, not gray so I have no idea what you are doing. You've been given a link to the swing tutorial which contains a working example. If you have more problems then you need to post a SSCCE: http://sscce.orgthat demonstrates the problem.
camickr