JTextFiled
JTextFiled
JTextFiled
JTextFiled
而不是这样:
JTextFiled JTextFiled JTextFiled JTextFiled
应该如何设置? 谢谢!
9 个解决方案
#1
就没人知道?? 真没人知道??
#2
用布局模式控制吧。
JPanel jpl1 = new JPanel(new GridLayout(;根据你的窗口大小设置下吧。
JPanel jpl1 = new JPanel(new GridLayout(;根据你的窗口大小设置下吧。
#3
使用网格布局
import java.awt.GridLayout;
import javax.swing.*;
public class Test extends JFrame{
JTextField f1 = new JTextField(12);
JTextField f2= new JTextField(12);
JTextField f3 = new JTextField(12);
JPanel jp = new JPanel();
public Test(){
//panel 使用网格布局
jp.setLayout(new GridLayout(3,1)); //网格布局 3行1列
jp.add(f1);
jp.add(f2);
jp.add(f3);
this.add(jp);
this.pack();
this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Test();
}
}
#4
LZ,用下布局吧,就像楼上的那样,现在最好去看下java界面的布局管理器,很简单的,以后写java界面都需要的。。
#5
import javax.swing.*;
import java.awt.*;
public class Box
{
JFrame mainFrame ;
JTextField[] text ;
Container con;
public Box()
{
mainFrame = new JFrame();
con = mainFrame.getContentPane();
BoxLayout box = new BoxLayout(con,BoxLayout.Y_AXIS);
con.setLayout(box);
text = new JTextField[6];
for(int i=0;i<6;i++)
{
text[i] = new JTextField(8);
con.add(text[i]);
}
mainFrame.setSize(300,300);
mainFrame.setVisible(true);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
new Box();
}
}
#6
import javax.swing.*;
import java.awt.*;
public class Box
{
JFrame mainFrame ;
JTextField[] text ;
JPanel panel;
Container con;
public Box()
{
mainFrame = new JFrame();
con = mainFrame.getContentPane();
con.setLayout(new BorderLayout());
panel = new JPanel();
BoxLayout box = new BoxLayout(panel,BoxLayout.Y_AXIS);
panel.setLayout(box);
text = new JTextField[6];
for(int i=0;i<6;i++)
{
text[i] = new JTextField(8);
panel.add(text[i]);
}
con.add(panel,BorderLayout.NORTH);
mainFrame.setSize(300,300);
mainFrame.setVisible(true);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
new Box();
}
}
#7
用GridLayout 布局就可以实现
import java.awt.*;
import javax.swing.*;
public class testLayout extends JFrame{
private JTextField filed1=new JTextField(9);
private JTextField filed2=new JTextField(9);
private JTextField filed3=new JTextField(9);
private JTextField filed4=new JTextField(9);
public testLayout(){
Container c=getContentPane();
c.setLayout(new GridLayout(4,1));
c.add(filed1);
c.add(filed2);
c.add(filed3);
c.add(filed4);
}
public static void main(String[] args){
testLayout test1=new testLayout();
test1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test1.setSize(400,300);
test1.setVisible(true);
test1.setTitle("Test Layout");
}
}
#8
import java.awt.*;
import javax.swing.*;
public class testLayout extends JFrame{
private JTextField filed1=new JTextField(9);
private JTextField filed2=new JTextField(9);
private JTextField filed3=new JTextField(9);
private JTextField filed4=new JTextField(9);
public testLayout(){
Container c=getContentPane();
c.setLayout(new GridLayout(4,1));
c.add(filed1);
c.add(filed2);
c.add(filed3);
c.add(filed4);
}
public static void main(String[] args){
testLayout test1=new testLayout();
test1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test1.setSize(400,200);
test1.setVisible(true);
test1.setTitle("Test Layout");
}
}
import javax.swing.*;
public class testLayout extends JFrame{
private JTextField filed1=new JTextField(9);
private JTextField filed2=new JTextField(9);
private JTextField filed3=new JTextField(9);
private JTextField filed4=new JTextField(9);
public testLayout(){
Container c=getContentPane();
c.setLayout(new GridLayout(4,1));
c.add(filed1);
c.add(filed2);
c.add(filed3);
c.add(filed4);
}
public static void main(String[] args){
testLayout test1=new testLayout();
test1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test1.setSize(400,200);
test1.setVisible(true);
test1.setTitle("Test Layout");
}
}
#9
看代码费时间 直接说比较简单
用布局管理器
JPanel jp = new JPanel();
jp.setLayout(null);
jp.setLayout(new GridLayout(4,1));
用布局管理器
JPanel jp = new JPanel();
jp.setLayout(null);
jp.setLayout(new GridLayout(4,1));
#1
就没人知道?? 真没人知道??
#2
用布局模式控制吧。
JPanel jpl1 = new JPanel(new GridLayout(;根据你的窗口大小设置下吧。
JPanel jpl1 = new JPanel(new GridLayout(;根据你的窗口大小设置下吧。
#3
使用网格布局
import java.awt.GridLayout;
import javax.swing.*;
public class Test extends JFrame{
JTextField f1 = new JTextField(12);
JTextField f2= new JTextField(12);
JTextField f3 = new JTextField(12);
JPanel jp = new JPanel();
public Test(){
//panel 使用网格布局
jp.setLayout(new GridLayout(3,1)); //网格布局 3行1列
jp.add(f1);
jp.add(f2);
jp.add(f3);
this.add(jp);
this.pack();
this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Test();
}
}
#4
LZ,用下布局吧,就像楼上的那样,现在最好去看下java界面的布局管理器,很简单的,以后写java界面都需要的。。
#5
import javax.swing.*;
import java.awt.*;
public class Box
{
JFrame mainFrame ;
JTextField[] text ;
Container con;
public Box()
{
mainFrame = new JFrame();
con = mainFrame.getContentPane();
BoxLayout box = new BoxLayout(con,BoxLayout.Y_AXIS);
con.setLayout(box);
text = new JTextField[6];
for(int i=0;i<6;i++)
{
text[i] = new JTextField(8);
con.add(text[i]);
}
mainFrame.setSize(300,300);
mainFrame.setVisible(true);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
new Box();
}
}
#6
import javax.swing.*;
import java.awt.*;
public class Box
{
JFrame mainFrame ;
JTextField[] text ;
JPanel panel;
Container con;
public Box()
{
mainFrame = new JFrame();
con = mainFrame.getContentPane();
con.setLayout(new BorderLayout());
panel = new JPanel();
BoxLayout box = new BoxLayout(panel,BoxLayout.Y_AXIS);
panel.setLayout(box);
text = new JTextField[6];
for(int i=0;i<6;i++)
{
text[i] = new JTextField(8);
panel.add(text[i]);
}
con.add(panel,BorderLayout.NORTH);
mainFrame.setSize(300,300);
mainFrame.setVisible(true);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
new Box();
}
}
#7
用GridLayout 布局就可以实现
import java.awt.*;
import javax.swing.*;
public class testLayout extends JFrame{
private JTextField filed1=new JTextField(9);
private JTextField filed2=new JTextField(9);
private JTextField filed3=new JTextField(9);
private JTextField filed4=new JTextField(9);
public testLayout(){
Container c=getContentPane();
c.setLayout(new GridLayout(4,1));
c.add(filed1);
c.add(filed2);
c.add(filed3);
c.add(filed4);
}
public static void main(String[] args){
testLayout test1=new testLayout();
test1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test1.setSize(400,300);
test1.setVisible(true);
test1.setTitle("Test Layout");
}
}
#8
import java.awt.*;
import javax.swing.*;
public class testLayout extends JFrame{
private JTextField filed1=new JTextField(9);
private JTextField filed2=new JTextField(9);
private JTextField filed3=new JTextField(9);
private JTextField filed4=new JTextField(9);
public testLayout(){
Container c=getContentPane();
c.setLayout(new GridLayout(4,1));
c.add(filed1);
c.add(filed2);
c.add(filed3);
c.add(filed4);
}
public static void main(String[] args){
testLayout test1=new testLayout();
test1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test1.setSize(400,200);
test1.setVisible(true);
test1.setTitle("Test Layout");
}
}
import javax.swing.*;
public class testLayout extends JFrame{
private JTextField filed1=new JTextField(9);
private JTextField filed2=new JTextField(9);
private JTextField filed3=new JTextField(9);
private JTextField filed4=new JTextField(9);
public testLayout(){
Container c=getContentPane();
c.setLayout(new GridLayout(4,1));
c.add(filed1);
c.add(filed2);
c.add(filed3);
c.add(filed4);
}
public static void main(String[] args){
testLayout test1=new testLayout();
test1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test1.setSize(400,200);
test1.setVisible(true);
test1.setTitle("Test Layout");
}
}
#9
看代码费时间 直接说比较简单
用布局管理器
JPanel jp = new JPanel();
jp.setLayout(null);
jp.setLayout(new GridLayout(4,1));
用布局管理器
JPanel jp = new JPanel();
jp.setLayout(null);
jp.setLayout(new GridLayout(4,1));