加了滚动条textArea不能用了,怎么改?
加了滚动条textArea是灰色的55555555555555555555555555.......找不到错了
我的代码:
/**
* byq.java
* done by symbol windows风格
*/
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class byq extends JFrame
{
//定义
JButton Button1 = new JButton("开始编译"); //按钮
JTextArea textArea1 = new JTextArea ("在这里写代码",30,60);
JTextArea textArea2 = new JTextArea ("调试信息",30,60);
JLabel label1 = new JLabel("代码输入:"); //不是按钮,是静态文本
JLabel label2 = new JLabel("调试信息"); //不是按钮,是静态文本
//JScrollPane scrollPane1 = new JScrollPane(textArea1);
//JScrollPane scrollPane2 = new JScrollPane(textArea2);
public byq()
{
JScrollPane scrollPane1 = new JScrollPane(textArea1);//不写这里textArea不能用,写了还是不能用
JScrollPane scrollPane2 = new JScrollPane(textArea2);
//初始化
//getContentPane().setLayout(new java.awt.FlowLayout());//大小自动适合
getContentPane().setLayout( null );
textArea1.setLineWrap(true);
textArea2.setLineWrap(true);
getContentPane().add(textArea1);
getContentPane().add(textArea2);
getContentPane().add(Button1);
getContentPane().add(label1);
getContentPane().add(label2);
getContentPane().add(scrollPane1);
getContentPane().add(scrollPane2);
//颜色
getContentPane().setBackground(Color.GREEN);
label1.setForeground(Color.RED);
label2.setForeground(Color.RED);
Button1.setForeground(Color.red);
//方位大小
label1.setBounds(30,30,180,30);
label2.setBounds(30,300,180,30);
Button1.setBounds( 680, 600, 100,60 );
//textArea1.setBounds(30, 60, 700, 200);
//textArea2.setBounds(30, 330, 700, 200);
scrollPane1.setBounds(30, 60, 700, 200);
scrollPane2.setBounds(30, 330, 700, 200);
/* 为一般按钮添加动作监听器 */
Button1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
JOptionPane.showMessageDialog(null,"开始编译","标题",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
});
setSize(800, 700);
System.out.println("this is my first window");
}
public static void main(String[] args)
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch(Exception e)
{
e.printStackTrace();
}
byq win = new byq();
win.show();
}
}
我的代码:
/**
* byq.java
* done by symbol windows风格
*/
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class byq extends JFrame
{
//定义
JButton Button1 = new JButton("开始编译"); //按钮
JTextArea textArea1 = new JTextArea ("在这里写代码",30,60);
JTextArea textArea2 = new JTextArea ("调试信息",30,60);
JLabel label1 = new JLabel("代码输入:"); //不是按钮,是静态文本
JLabel label2 = new JLabel("调试信息"); //不是按钮,是静态文本
//JScrollPane scrollPane1 = new JScrollPane(textArea1);
//JScrollPane scrollPane2 = new JScrollPane(textArea2);
public byq()
{
JScrollPane scrollPane1 = new JScrollPane(textArea1);//不写这里textArea不能用,写了还是不能用
JScrollPane scrollPane2 = new JScrollPane(textArea2);
//初始化
//getContentPane().setLayout(new java.awt.FlowLayout());//大小自动适合
getContentPane().setLayout( null );
textArea1.setLineWrap(true);
textArea2.setLineWrap(true);
getContentPane().add(textArea1);
getContentPane().add(textArea2);
getContentPane().add(Button1);
getContentPane().add(label1);
getContentPane().add(label2);
getContentPane().add(scrollPane1);
getContentPane().add(scrollPane2);
//颜色
getContentPane().setBackground(Color.GREEN);
label1.setForeground(Color.RED);
label2.setForeground(Color.RED);
Button1.setForeground(Color.red);
//方位大小
label1.setBounds(30,30,180,30);
label2.setBounds(30,300,180,30);
Button1.setBounds( 680, 600, 100,60 );
//textArea1.setBounds(30, 60, 700, 200);
//textArea2.setBounds(30, 330, 700, 200);
scrollPane1.setBounds(30, 60, 700, 200);
scrollPane2.setBounds(30, 330, 700, 200);
/* 为一般按钮添加动作监听器 */
Button1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
JOptionPane.showMessageDialog(null,"开始编译","标题",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
});
setSize(800, 700);
System.out.println("this is my first window");
}
public static void main(String[] args)
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch(Exception e)
{
e.printStackTrace();
}
byq win = new byq();
win.show();
}
}
...全文
相关推荐
textArea滚动条样式
js实现textArea滚动条样式,兼容多种浏览器
JavaScript中Textarea滚动条不能拖动的解决方法
主要介绍了JavaScript中Textarea滚动条不能拖动的解决方法,主要针对IE浏览器中Textarea滚动条绑定了onfocus事件时分析对应的处理方法,需要的朋友可以参考下
css textarea 高度自适应,无滚动条
用css控制textarea文本域的高度随内容的变化而变化,不出现滚动条.
textarea自适应高度标签,去除难看的滚动条
这是一个令textarea高度自适应的插件,使用jquery 去掉令人非常讨厌的滚动条;
textarea去掉滚动条 textarea横向或纵向滚动条的去掉方法
在IE下文本框textarea会显示滚动条(如下:) 去掉textarea横向或纵向滚动条办法: <textarea style="overflow:hidden"></textarea> 可以通过overflow-x:hidden和overflow-y:hidden控制横向和纵向滚动条 要设置textarea文本域的滚动条是否开启,使用style.overflow-x属性来控制。如:如果要隐藏该文本域的横向滚动条,在style属性中增加overflow-x属性控制,如下: <textarea id=txtComments style="overflow-x:hidden"></textare


Java SE
