|
文本编辑器源文件(java语言)(49) { dispose(); return true; } if(evt.target== up) { dire=-1; } if(evt.target== down) { dire= 1; } if(evt.target== boxc) { } return super.action(evt, arg); } } //*///======================================= class outlinePanel extends Panel { CheckboxGroup cbg; int yposn; Vector cblist; //-------------------------------------- public outlinePanel() { super(); cbg = new CheckboxGroup(); //for radio buttons setLayout(null); yposn = 3; cblist = new Vector(); } //-------------------------------------- public void reshape(int x, int y, int w, int h) { super.reshape(x,y,w,h); for (int i=0; i< cblist.size(); i++) { Component c = (Component)cblist.elementAt(i); c.reshape(c.location().x, c.location().y, w-6, c.size().height); } } //-------------------------------------- public Component add(Component c) { super.add(c); return c; } //-------------------------------------- public Checkbox addCheckbox(String s, boolean checked) { Checkbox cb = new Checkbox(s, cbg, checked); add(cb); cblist.addElement(cb); cb.reshape(3, yposn, 50, 12); yposn += 15; return cb; } //-------------------------------------- public void paint(Graphics g) { Dimension sz = size(); Point pt = location(); g.setColor(Color.darkGray); // graw rectangle g.drawRect(0, 0, sz.width-2, sz.height-2); //outline gray rectangle with 2 white inner lines g.setColor(Color.white); g.drawLine(1, 1, sz.width-3, 1);
|