Initial commit of newLISP.
[newlisp.git] / guiserver / java / aButton.java
blob786fe62a0b5cd5bd92f52a27c828581ce62391ac
1 //
2 // aButton.java
3 // guiserver
4 //
5 // Created by Lutz Mueller on 5/25/07.
6 //
7 //
8 // Copyright (C) 2007 Lutz Mueller
9 //
10 // This program is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, see <http://www.gnu.org/licenses/>.
25 import java.awt.*;
26 import java.awt.event.*;
27 import javax.swing.*;
28 import java.util.*;
30 public class aButton extends gsObject {
32 AbstractButton abutton;
34 public void setText(StringTokenizer tokens)
36 String text = Base64Coder.decodeString(tokens.nextToken());
37 abutton.setText(text);
40 public void appendText(StringTokenizer tokens)
42 String text = Base64Coder.decodeString(tokens.nextToken());
43 String oldtext = abutton.getText();
44 abutton.setText(oldtext + text);
47 public void getText(StringTokenizer params)
49 String action = params.nextToken();
50 String text = abutton.getText();
51 if(text.length() == 0)
52 guiserver.out.println("(" + action + " \"" + id + "\")");
53 else
54 guiserver.out.println("(" + action + " \"" + id + "\" [text]" + Base64Coder.encodeString(text) + "[/text])");
55 guiserver.out.flush();
58 public void clearText(StringTokenizer tokens)
60 abutton.setText("");
63 public void setIcon(StringTokenizer tokens)
65 String path = Base64Coder.decodeString(tokens.nextToken());
66 abutton.setIcon(guiserver.getIconFromPath(path, this.getClass()));
69 public void setPressedIcon(StringTokenizer tokens)
71 String path = Base64Coder.decodeString(tokens.nextToken());
72 abutton.setPressedIcon(guiserver.getIconFromPath(path, this.getClass()));
75 public void setSelected(StringTokenizer tokens)
77 String target;
78 aButton thebutton;
80 abutton.setSelected(tokens.nextToken().equals("true"));
82 while(tokens.hasMoreTokens())
84 target = tokens.nextToken();
85 thebutton = (aButton)gsObject.widgets.get(target);
86 thebutton.abutton.setSelected(tokens.nextToken().equals("true"));
93 // eof //