我的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自己搞的 同样的命令在命令行里好使 但是在Runtime.getRuntime().exec(cmd);中执行无效果? 合并排序算法问题 〓〓大家来看看,用完list后需要做善后处理吗???〓〓 JNA的ByReference的使用 如何再JEditorPane中设置其中文字字体和颜色。 一个class里面可否写两个样式名?? 同步 异步 还有并发的概念 一个百思不得其解的问题 极菜问题:在JButton上加Icon 静态变量 静态函数 继承问题 各位大哥大姐进来看看 【菜鸟求解】判断给定字符串的内容是否全部都是英文字母,若其中包含其它字符,则抛出一个异常
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自己搞的