我的JFrame的大小是1024*768,但其中的JPanel我想设为200*100就可以了,怎样设呢? jpanel.setPreferredSize(int x,int y) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 很简单呀,将JFrame容器蛇成x,y坐标系统以后,JPanel你想设成多少就设成多少。最简单的方法,拿鼠标拖就是了。 jdbcodbcPanel = new JPanel(); contentPanel.setLayout(new BorderLayout()); JLabel label1 = new JLabel("username"); JLabel label2 = new JLabel("password"); JLabel label3 = new JLabel("sex"); JLabel label4 = new JLabel("location"); JTextField TextUser = new JTextField(""); JTextField TextPassword = new JTextField(""); JTextField TextSex = new JTextField(""); JTextField TextLocation = new JTextField(""); TextUser.setColumns(10); TextPassword.setColumns(10); TextSex.setColumns(10); TextLocation.setColumns(10); jdbcodbcPanel.add(label1); jdbcodbcPanel.add(TextUser); jdbcodbcPanel.add(label2); jdbcodbcPanel.add(TextPassword); jdbcodbcPanel.add(label3); jdbcodbcPanel.add(TextSex); jdbcodbcPanel.add(label4); jdbcodbcPanel.add(TextLocation); contentPanel.add(jdbcodbcPanel,BorderLayout.WEST);所有控件并排,怎样换行? jdbcodbcPanel 没有使用layout , 要使用某个layout来布局的然后在用相应的add方法 JFrame frame=new JFrame("mainFrame");frame.setLayout(new FlowLayout()); 也可以用绝对坐标来布局的setLayout(null);然后每一个控件都要绑定位置用setBounds(int x, int y, int width, int height);然后直接add就好了也蛮方便的VAJ就是这样做的xyLayout是borland自己搞的 一个关于线程的问题:线程停止以后,就会被回收吗? 求教:C++忘得干干净净了 有一道经典的面试题,求解答! 关于jtable 和JPanel背景图片的问题? String.split()的疑惑 给大家讨论下java写的qq中遇到的一个问题 eXtremeTable找不到相关图片 为什么打出来的是乱码?在线等待。 为什么将集合变成数组后输出不成功? Access数据库的连接方法 各位大哥大姐进来看看 【菜鸟求解】判断给定字符串的内容是否全部都是英文字母,若其中包含其它字符,则抛出一个异常
contentPanel.setLayout(new BorderLayout());
JLabel label1 = new JLabel("username");
JLabel label2 = new JLabel("password");
JLabel label3 = new JLabel("sex");
JLabel label4 = new JLabel("location");
JTextField TextUser = new JTextField("");
JTextField TextPassword = new JTextField("");
JTextField TextSex = new JTextField("");
JTextField TextLocation = new JTextField("");
TextUser.setColumns(10);
TextPassword.setColumns(10);
TextSex.setColumns(10);
TextLocation.setColumns(10);
jdbcodbcPanel.add(label1);
jdbcodbcPanel.add(TextUser);
jdbcodbcPanel.add(label2);
jdbcodbcPanel.add(TextPassword);
jdbcodbcPanel.add(label3);
jdbcodbcPanel.add(TextSex);
jdbcodbcPanel.add(label4);
jdbcodbcPanel.add(TextLocation); contentPanel.add(jdbcodbcPanel,BorderLayout.WEST);
所有控件并排,怎样换行?
然后在用相应的add方法
frame.setLayout(new FlowLayout());
setLayout(null);
然后每一个控件都要绑定位置
用setBounds(int x, int y, int width, int height);
然后直接add就好了
也蛮方便的VAJ就是这样做的
xyLayout是borland自己搞的