问题描述
长话短说,应用程序扩展了 JInternalFrame 对象并实现了各种其他行为和动作。
不幸的是,拥有 JInternalFrame 会生成与父窗口相关的大小限制。拥有 JInternalFrame 的“分离”或“浮动”版本会很棒。诚然,基于 JInternalFrame 的含义,该请求有点自相矛盾,但希望有人偶然发现了一个我似乎还没有找到或找到这样做的独特实现的设置。
以下代码示例有 2 个 JFrame 和 2 个 JInternalFrame。 JFrame 1 有 2 个 JInternalFrame。注意 JFrame 1 的大小是固定的。 JFrame 2 应该模仿新的 JInternalFrame,但它只是表明它太大而无法容纳在 JFrame 1 区域内,因为它的大小是固定的。 JFrame 2 是我希望 JInternalFrame 的行为方式。
有人遇到过类似的情况吗?如果是这样,您可以在哪些方面取得进展以强制改变行为?
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class JInteneralFrameTest {
static JFrame f,f2;
static JLabel l,l1;
public static void main(String[] args)
{
f = new JFrame("frame");
f.setLayout(new FlowLayout());
JInternalFrame in = new JInternalFrame("frame 1",true,true);
JInternalFrame in1 = new JInternalFrame("frame 2",true);
JButton b = new JButton("button");
JButton b1 = new JButton("button1");
l = new JLabel("This is a JInternal Frame no 1 ");
l1 = new JLabel("This is a JInternal Frame no 2 ");
JPanel p = new JPanel();
JPanel p1 = new JPanel();
p.add(l);
p.add(b);
p1.add(l1);
p1.add(b1);
in.setVisible(true);
in1.setVisible(true);
in.add(p);
in1.add(p1);
f.add(in);
f.add(in1);
f.setSize(300,300);
f.show();
f.setResizable(false);
f2 = new JFrame("frame 2 ");
JLabel jLabel = new JLabel("I would like my JInternalFrame to be like this");
f2.add(jLabel);
f2.setSize(500,500);
f2.setLocation(50,50);
f2.show();
}
}
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class JInteneralFrameTest extends JFrame {
static JFrame f,f2;
static JLabel l,l1;
public static void main(String[] args)
{
f = new JFrame("frame");
f.setLayout(new FlowLayout());
JInternalFrame in = new JInternalFrame("frame 1",true);
JInternalFrame in1 = new JInternalFrame("frame 2",true);
JButton b = new JButton("button");
JButton b1 = new JButton("button1");
l = new JLabel("This is a JInternal Frame no 1 ");
l1 = new JLabel("This is a JInternal Frame no 2 ");
JPanel p = new JPanel();
JPanel p1 = new JPanel();
p.add(l);
p.add(b);
p1.add(l1);
p1.add(b1);
in.setVisible(true);
in1.setVisible(true);
in.add(p);
in1.add(p1);
f.add(in);
f.add(in1);
f.setSize(300,300);
f.show();
f2 = new JFrame("frame 2 ");
JLabel jLabel = new JLabel("I would like my JInternalFrame to be like this");
f2.add(jLabel);
f2.setSize(300,300);
f2.setLocation(50,50);
f2.show();
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)