✎
编程开发网
首页
C语言
C++
面试
Linux
函数
Windows
数据库
下载
搜索
当前位置:
首页
->
AI编程基础
->
JAVA
背景会变得记事本
2014-11-24 07:17:24
·
作者:
·
浏览:
0
标签:
背景
变得
记事本
import java.awt.Color;import java.awt.Frame;import java.awt.Label;import java.awt.Button;import java.awt.Panel;import java.awt.TextArea;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseEvent;import java.awt.event.MouseMotionAdapter;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.util.Random;public class TestTextArea {public static void main(String[]args){int i1 = new Random().nextInt(255);int i2 = new Random().nextInt(255);int i3 = new Random().nextInt(255);Frame f = new Frame("段晋文的留言板");TextArea message =new TextArea("请您留言:");System.out.println(i1);System.out.println(i2);System.out.println(i3);message.setBackground(new Color(i1,i2,i3));//TextArea message =new TextArea(20,20);f.add(message,"Center");Panel p1 = new Panel();GridLayout gl = new GridLayout(1,6);p1.setLayout(gl);String[] buttonLabel ={"剪贴","复制","粘贴","删除","提交","清屏"};String[] buttonActionCommands = {"CUT","COPY","PASTE","DEL","SUB","CLEAR"};Button[] buttons = new Button[6];OuterMonitor11 om = new OuterMonitor11(message,buttons);for(int i=0;i
0);buttons[2].setEnabled(clipped);boolean selected = msgBoard.getSelectionEnd()!=msgBoard.getSelectionStart();buttons[0].setEnabled(selected);buttons[1].setEnabled(selected);buttons[3].setEnabled(selected);}public void mouseDragged(MouseEvent e){this.switchButtons();}/*public void switchButtons(){boolean clipped = (clipBoard!=null) && (clipBoard.length()>0);buttons[2].setEnabled(clipped);boolean selected = msgBoard.getSelectionEnd() != msgBoard.getSelectionStart();buttons[0].setEnabled(selected);buttons[1].setEnabled(selected);buttons[3].setEnabled(selected);}@Overridepublic void mouseDragged(MouseEvent te){this.switchButtons();} */}
摘自 djw10962000的专栏