f=new JFrame();
f.setTitle("标题");
f.setBounds(0, 0, 400, 600);
p1=new JPanel();
p1.setPreferredSize(new Dimension(300,50));
p1.setBackground(new Color(225,225,225));
p3=new JPanel();
p3.setPreferredSize(new Dimension(300,300));
//Container c=f.getContentPane();
lb=new JLabel("请输入:");
p1.add(lb);
tf=new JTextField(15);
tf.setHorizontalAlignment(JTextField.CENTER );
p1.add(tf); //添加文本行
tf.setEditable(true);
bc1=new JButton("确定");
bc1.setEnabled(true);
p1.add(bc1);
textArea=new JTextArea(50,35);
textArea.setBackground(new Color(200,100,60));
textArea.setLineWrap(true);
JScrollPane scroll = new JScrollPane(textArea);
scroll.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scroll.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
p3.setLayout(new BorderLayout());
p3.add(scroll, BorderLayout.CENTER);
p3.add(textArea);
bc1.addActionListener(this);
f.addWindowListener(this);
f.add(p1,BorderLayout.NORTH);
f.add(p3,BorderLayout.CENTER);
f.setVisible(true); 这样设置滚动条不出来,改要怎么样弄呢??
另外求一个网址的正则表达式。
f.setTitle("标题");
f.setBounds(0, 0, 400, 600);
p1=new JPanel();
p1.setPreferredSize(new Dimension(300,50));
p1.setBackground(new Color(225,225,225));
p3=new JPanel();
p3.setPreferredSize(new Dimension(300,300));
//Container c=f.getContentPane();
lb=new JLabel("请输入:");
p1.add(lb);
tf=new JTextField(15);
tf.setHorizontalAlignment(JTextField.CENTER );
p1.add(tf); //添加文本行
tf.setEditable(true);
bc1=new JButton("确定");
bc1.setEnabled(true);
p1.add(bc1);
textArea=new JTextArea(50,35);
textArea.setBackground(new Color(200,100,60));
textArea.setLineWrap(true);
JScrollPane scroll = new JScrollPane(textArea);
scroll.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scroll.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
p3.setLayout(new BorderLayout());
p3.add(scroll, BorderLayout.CENTER);
p3.add(textArea);
bc1.addActionListener(this);
f.addWindowListener(this);
f.add(p1,BorderLayout.NORTH);
f.add(p3,BorderLayout.CENTER);
f.setVisible(true); 这样设置滚动条不出来,改要怎么样弄呢??
另外求一个网址的正则表达式。
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
在这句代码下面加一下这句,后面的NORTH 可以自己改 试试看行不行
getContentPane().add(scroll,BorderLayout.NORTH);