5

私は swing アプリケーションを持っていて、JTextArea の背景色を変更するコードを書きました。ただし、例外があります。

コードは次のとおりです。

//1.JtextArea will work after maximize.
//2.on typing text,background  will slowly transform to black line by line.

import java.awt.*;
import javax.swing.*;

public class TextArea {

    JTextArea area;
    JFrame frame;

    public static void main(String args[])                     
    {
        TextArea x = new TextArea();
        x.execute();                                                       
    }               

    void execute()
    {
        frame = new JFrame();
        frame.setVisible(true);
        frame.setSize(600,600);
        frame.setTitle("Temp Area");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        area = new JTextArea();
        frame.add(area,BorderLayout.CENTER);

        Color c = new Color(0,0,0,100);
        area.setBackground(c);
    }
}
4

2 に答える 2