简体   繁体   English

调整JFrame内的JPanel大小

[英]Resizing a JPanel inside a JFrame

I am new to Java, started learning swing and have a problem with resizing a JPanel inside a JFrame. 我是Java的新手,开始学习swing并且在JFrame中调整JPanel的大小有问题。 I am following this tutorial: 我正在关注本教程:

http://vincentramdhanie.blogspot.com/2009/11/cardlayout-with-netbeans.html http://vincentramdhanie.blogspot.com/2009/11/cardlayout-with-netbeans.html

because ultimately I am learning each of the different layouts and have come to the CardLayout now. 因为最终我正在学习每种不同的布局,现在就来到了CardLayout。 In the above, there is a JPanel being used for a status panel. 在上文中,有一个JPanel用于状态面板。 That is what I want to do as well, but when I drag a JPanel onto my blank JForm it takes up all the space and I don't see any resizing handles for it like I would if I were using a .NET panel. 这也是我想要做的,但是当我将JPanel拖到我的空白JForm上时,它占用了所有空间,我没有看到任何调整大小的句柄,就像我使用.NET面板一样。 Changing preferredSize in the properties window also does nothing. 在属性窗口中更改preferredSize也不会执行任何操作。 What am I missing here? 我在这里错过了什么? I feel like a complete noob for asking such a basic question but I really can't find any way to resize this thing.. :-| 我觉得这是一个完整的菜鸟问这样一个基本的问题,但我真的找不到任何方法来调整这个东西..: - |

EDIT: 编辑:

I forgot to mention; 我忘了提; I am using NetBeans IDE 我正在使用NetBeans IDE

You can't resize the JComponent because you've select CardLayout . 您无法调整JComponent大小,因为您选择了CardLayout The CardLayout can holds/manages one or more components that share the same display space. CardLayout可以保存/管理共享相同显示空间的一个或多个组件。

What you need to read documentation and good tutorials . 您需要阅读文档和良好的教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM