Ihaveafnddx(3, 2 ) as follows with美丽的朋友、 2 jtextfieldsandajbutton.iaddthemasshowninthepicorcode.everythingisjustfinebutthejtextfieldsizeistoobigandittobeas showhowhtttthetthettthettheas avetriedsayingjtf3. setpreferredsize (新维) x,y ); but it didn ' tchangethedimensionatall.oneothersolutionwastomakethefnddxsomewhatfnddx (3,2,1,50 ) for example (by ading Thanks a lot
copying _ panel.set layout (newfnddx (3,2 );
copying _ panel.set background (new color (200,221,242 );
jlabelJL4=newjlabel('from: ',SwingConstants.CENTER );
JTextField jtf3=new JTextField (;
jlabelJL5=newjlabel('to: ',SwingConstants.CENTER );
JTextField jtf4=new JTextField (;
JLabel jl6=new JLabel (;
JbuttonJB2=newJbutton('go );
copying_Panel.add(JL4;
copying_Panel.add(JTF3;
copying_Panel.add(JL5;
copying_Panel.add(JTF4;
copying_Panel.add(JL6;
copying_Panel.add(JB2;
That's how fnddx works,itprovidesequalspacetoallthecomponents.instead,considerusingagridbaglayoutinstead。
copying _ panel.set layout (newgridbaglayout ) );
copying _ panel.set background (new color (200,221,242 );
jlabelJL4=newjlabel('from: ',SwingConstants.CENTER );
jextfieldJTF3=newjtextfield(10;
jlabelJL5=newjlabel('to: ',SwingConstants.CENTER );
jextfieldJTF4=newjtextfield(10;
JbuttonJB2=newJbutton('go );
gridbagconstraintsgbc=newgridbagconstraints (;
gbc.gridx=0;
gbc.gridy=0;
copying_Panel.add(JL4,gbc );
gbc.gridy;
copying_Panel.add(JL5,gbc );
gbc.anchor=gridbag constraints.east;
gbc.fill=gridbag constraints.horizontal;
gbc.gridx;
gbc.gridy=0;
copying_Panel.add(JTF3,gbc );
gbc.gridy;
copying_Panel.add(JTF4,gbc );
gbc.anchor=gridbag constraints.west;
gbc.fill=gridbag constraints.none;
gbc.gridy;
copying_Panel.add(JB2,gbc );