开发者

How to make the JInternalFrame of the specified size?

开发者 https://www.devze.com 2023-04-09 06:26 出处:网络
I have a JFrame. I have added menu-bar to it. I have set its size and location using following line. frmMain.setBounds(0, 0, 1024, 768);// JFrame

I have a JFrame. I have added menu-bar to it. I have set its size and location using following line.

frmMain.setBounds(0, 0, 1024, 768);  // JFrame 

Next I have added a JInternalFrame to the code for JInternalFrame as follows:

ifActivateProject=new JInternalFrame();
ifActivateProject.setBounds(450, 400, 300, 350);
ifActivateProject.add(pnlActivateProject);
ifActivteProject.setVisible(true);
ifActivateProject.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
frmMain.getContentPane().add(ifActivateProject);

When I executes the program the Internal frame occupies all the remaining area in JFrame. As I have set the location and size of internal frame. It wont appear at that location and of the specified size.

I want to show Internal frame of different sizes depending on menu click means on开发者_运维问答 one menu click one internal frame has shown. After closing that internal frame on another menu click another should be appear in my JFrame. All these internal frames are of different sizes. But the problem is the added internal frame as shown in above code snippet acquires all the space of JFrame.

What's wrong with above code?


A JInternalFrrame should be added to a JDesktopPane, not a JFrame.

See How to Use Internal Frames for more details.

0

精彩评论

暂无评论...
验证码 换一张
取 消