use*_*635 1 java swing jpanel jframe layout-manager
我是Swing的新用户,我有按坐标绘制组件的问题.请看这段代码:
JFrame frame=new JFrame();
frame.setBounds(new Rectangle(0, 0, 700, 600));
frame.getContentPane().setBackground(Color.yellow);
frame.setVisible(true);
JPanel graph=new JPanel();
graph.setBounds(new Rectangle(0, 0, 700, 300));
graph.setBackground(Color.white);
graph.setOpaque(true);
frame.getContentPane().add(graph);
Run Code Online (Sandbox Code Playgroud)
我需要JPanel从JFrame关闭50%,但现在它关闭100%,JFrame背景为白色.我该如何解决这个错误?另外,使用百分比设置宽度和高度是否有任何意义?例如,宽度为50%.或者可能存在我的问题的任何容器?谢谢
| 归档时间: |
|
| 查看次数: |
725 次 |
| 最近记录: |