0
我想使JScrollPane的文本,文本框中的背景和自己的字体改变颜色,但我的实现不工作 - 我已经看到JScrollPane的默认形式(白色背景,标准的黑色字体)。谁能告诉我为什么它不起作用以及如何解决它?如何更改JScrollPane内容的颜色?
public class TextField extends JFrame
{
\t public TextField()
\t {
\t \t JScrollPane scroll = new JScrollPane(new JTextArea(15, 45));
\t \t scroll.setPreferredSize(new Dimension(500, 300));
\t \t scroll.getViewport().setBackground(Color.BLUE);
\t \t scroll.getViewport().setForeground(Color.YELLOW);
\t \t
\t \t Font font = new Font("Dialog", Font.BOLD + Font.ITALIC, 14);
\t \t scroll.getViewport().setFont(font);
\t \t add(scroll);
\t \t pack();
\t }
}