7 public class spiderframe extends Frame {
10 public spiderframe(spiderclient parent) {
12 super("Spider DX Cluster");
14 this.setFont(OutFont);
16 menubar = new MenuBar();
17 file = new Menu("File");
18 file.add(connect_menuitem);
19 file.add(new MenuItem("About"));
20 file.add(new MenuItem("Quit"));
21 if (Call.equals("NOCALL")) connect_menuitem.disable();
24 edit = new Menu("Edit");
25 edit.add(copy_menuitem);
26 edit.add(paste_menuitem);
27 copy_menuitem.disable();
28 paste_menuitem.disable();
33 // settings = new Menu("Preferences");
34 // settings.add(new MenuItem("Personal preferences ..."));
35 // menubar.add(settings);
39 commands = new Menu("Commands");
40 commands.add(new MenuItem("Help"));
41 commands.add(new MenuItem("Bye"));
42 menubar.add(commands);
44 show = new Menu("Show");
45 show.add(new MenuItem("Show Last DX"));
46 show.add(new MenuItem("Show Beam Direction"));
47 show.add(new MenuItem("Show WWV"));
48 show.add(new MenuItem("Search DX"));
49 show.add(new MenuItem("Search Address"));
50 show.add(new MenuItem("Search QSL Manager"));
51 show.add(new MenuItem("Search QSL Info"));
52 show.add(new MenuItem("Search DXCC"));
53 show.add(new MenuItem("Status"));
57 set = new Menu("Settings");
58 set.add(new MenuItem("Set Beep"));
59 set.add(new MenuItem("Set QTH / City"));
60 set.add(new MenuItem("Set Name"));
61 set.add(new MenuItem("Set Locator"));
62 set.add(new MenuItem("Set HomeNode"));
63 set.add(new MenuItem("Show Personal Settings"));
67 dxann = new Menu("DXannounce");
68 dxann.add(new MenuItem("DXannounce"));
71 mailbox = new Menu("Mailbox");
72 mailbox.add(new MenuItem("Last 10 Msgs"));
73 mailbox.add(new MenuItem("Last 50 Msgs"));
74 mailbox.add(new MenuItem("New Messages"));
75 mailbox.add(new MenuItem("Own Messages"));
84 this.setMenuBar(menubar);
86 setLayout(new BorderLayout());
88 Panel p1 = new Panel();
89 p1.setLayout(new BorderLayout());
91 output = new TextArea();
92 output.setEditable(false);
94 p1.add("Center", output);
95 input = new TextArea(2,80);
96 input.setEditable(false);
97 p1.add("South", input);
101 Panel p2 = new Panel();
102 p2.setLayout(new FlowLayout());
103 connectButton.enable();
104 p2.add(connectButton);
106 disconnectButton.disable();
107 p2.add(disconnectButton);
111 Panel p3 = new Panel();
112 GridBagLayout gbl = new GridBagLayout();
115 GridBagConstraints gbc = new GridBagConstraints();
118 gbc.fill = GridBagConstraints.HORIZONTAL;
119 gbc.anchor = GridBagConstraints.CENTER;
121 add(p3,DateLabel,gbl, gbc, 0, 0, 1, 1);
122 add(p3,IdleLabel, gbl, gbc, 2, 0, 2, 1);
123 add(p3,connectState,gbl, gbc, 4, 0, 2, 1);
130 setDate time = new setDate(this);
131 idle = new idleTime(this);
136 private void add(Panel p,Component c, GridBagLayout gbl,
137 GridBagConstraints gbc,
138 int x, int y, int w, int h) {
144 gbl.setConstraints(c, gbc);
148 public void setColors() {
149 output.setBackground(OutBackgroundColor);
150 output.setForeground(OutForegroundColor);
151 input.setBackground(InBackgroundColor);
152 input.setForeground(InForegroundColor);
155 public void setFonts() {
156 output.setFont(OutFont);
157 input.setFont(InFont);
160 public void initPrintStream(PrintStream out) {
164 public void setText(String s) {
167 for (i=0; i < s.length(); i++) {
168 if (s.charAt(i) == '\007')
171 output.appendText(s +'\n');
175 public void setCall(String s) {
179 public void setPassword(String s) {
183 public void setPrefix(String s) {
189 public void setCall2(String s) {
193 public void setFreq(String s) {
198 public void setRemarks(String s) {
205 public void setTime(String s) {
206 DateLabel.setText(s);
209 public void setIdle(String s) {
210 IdleLabel.setText(s);
213 public String getCall() {
217 public String getPassword() {
221 public String setPrefix(){
225 public String setCall2(){
229 public String setFreq(){
233 public String setRemarks(){
241 public void setFullname(String s) {
243 if (Call.equals("NOCALL"))
244 connect_menuitem.disable();
246 connect_menuitem.enable();
249 public String getFullname() {
253 public void setHostname(String s) {
257 public String getHostname() {
261 public void setPort(String s) {
265 public String getPort() {
269 public void setChannel(String s) {
273 public String getChannel() {
277 // public void login() {
278 // PersonalPreferences pp = new PersonalPreferences(this, Call, Fullname, OutFont);
281 public void antrichtung () {
282 beam pp = new beam (this, Prefix,OutFont);
285 public void dxannounce () {
286 dxannounce pp = new dxannounce (this, Call2, Freq, Remarks, OutFont);
294 public boolean handleEvent(Event evt) {
295 if (evt.id == Event.KEY_PRESS) {
296 if (evt.key == '\n') {
301 output.appendText(input.getText()+'\n');
302 out.println(input.getText());
305 if (MaxInputPos < 255) {
311 for(int i=0; i < 254; i++) {
312 InputBuffer[i] = new String(InputBuffer[i+1]);
317 InputBuffer[InputPos-1] = new String(input.getText());
321 } else if (evt.id == Event.KEY_ACTION) {
322 if (evt.key == Event.UP) {
325 input.setText(InputBuffer[InputPos]);
329 else if (evt.key == Event.DOWN) {
330 if (InputPos < MaxInputPos) {
332 input.setText(InputBuffer[InputPos]);
342 return super.handleEvent(evt);
345 public synchronized void show() {
350 public void setUserColor(Color c, String whichColor) {
351 if (whichColor.equals("Output Background ...")) {
352 OutBackgroundColor = c;
354 else if (whichColor.equals("Output Foreground ...")) {
355 OutForegroundColor = c;
356 } else if (whichColor.equals("Input Background ...")) {
357 InBackgroundColor = c;
359 else if (whichColor.equals("Input Foreground ...")) {
360 InForegroundColor = c;
361 } else if (whichColor.equals("Output own text ...")) {
369 public void connected() {
370 connect_menuitem.setLabel("Disconnect");
371 connectState.setText("Connected to "+Hostname+":"+Port);
372 input.setEditable(true);
373 copy_menuitem.enable();
375 connectButton.disable();
376 disconnectButton.enable();
379 public void disconnected() {
381 connect_menuitem.setLabel("Connect");
382 connectState.setText("Disconnected from "+Hostname);
383 input.setEditable(false);
384 copy_menuitem.disable();
385 paste_menuitem.disable();
386 connectButton.enable();
387 disconnectButton.disable();
390 public void setUserFont(String name, int size, int style,
392 if (whichFont.equals("Area ...")) {
393 OutFont = new Font(name, style, size);
395 else if (whichFont.equals("Input Line ...")) {
396 InFont = new Font(name, style, size);
403 public void getSelectedText() {
404 CopyPaste = new String(output.getSelectedText());
405 paste_menuitem.enable();
408 public boolean action(Event evt, Object arg) {
409 if (evt.target instanceof MenuItem) {
410 if (arg.equals("Quit")) {
412 // } else if (arg.equals("Personal preferences ...")) {
413 // PersonalPreferences pp = new PersonalPreferences(this,
414 // Call, Fullname, OutFont);
415 } else if (arg.equals("Connect")) {
417 } else if (arg.equals("Disconnect")) {
418 parent.dodisconnect();
419 } else if (arg.equals("About")) {
420 InfoDialog id = new InfoDialog(this, "About",
421 "JAVA Spider Webclient 0.6b\nPA4AB\n" +
422 "pa4ab@pa4ab.net \n" +
424 "Based on source of the CLX Client from dl6dbh" );
428 } else if (arg.equals("Copy")) {
430 } else if (arg.equals("Paste")) {
431 input.insertText(CopyPaste,input.getSelectionStart());
432 } else if (arg.equals("Bye")) {
433 if (Connected) out.println("bye");
434 } else if (arg.equals("Help")) {
435 if (Connected) out.println("? all");
436 } else if (arg.equals("Show Last DX")) {
437 if (Connected) out.println("sh/dx");
438 } else if (arg.equals("Status")) {
439 if (Connected) out.println("sh/c");
440 } else if (arg.equals("Show WWV")) {
441 if (Connected) out.println("sh/wwv");
442 } else if (arg.equals("Show Beam Direction")) {
443 beam pp = new beam(this, Prefix, OutFont);
444 if (Connected) out.println ("sh/heading " + Prefix );
445 } else if (arg.equals("Search DX")) {
446 beam pp = new beam(this, Prefix, OutFont);
447 if (Connected) out.println ("sh/dx " + Prefix );
449 } else if (arg.equals("Search QSL Info")) {
450 beam pp = new beam(this, Prefix, OutFont);
451 if (Connected) out.println ("sh/qsl " + Prefix );
454 } else if (arg.equals("Search Address")) {
455 beam pp = new beam(this, Prefix, OutFont);
456 if (Connected) out.println ("sh/qrz " + Prefix );
459 } else if (arg.equals("Search QSL Manager")) {
460 beam pp = new beam(this, Prefix, OutFont);
461 if (Connected) out.println ("sh/qsl " + Prefix );
464 } else if (arg.equals("Search DXCC")) {
465 beam pp = new beam(this, Prefix, OutFont);
466 if (Connected) out.println ("sh/pr " + Prefix );
470 } else if (arg.equals("Set Beep")) {
471 if (Connected) out.println("set/beep");
473 }else if (arg.equals("Set QTH / City")) {
474 beam pp = new beam(this, Prefix, OutFont);
475 if (Connected) out.println ("set/qth " + Prefix );
478 }else if (arg.equals("Set Name")) {
479 beam pp = new beam(this, Prefix, OutFont);
480 if (Connected) out.println ("set/name " + Prefix );
483 else if (arg.equals("Set Locator")) {
484 beam pp = new beam(this, Prefix, OutFont);
485 if (Connected) out.println ("set/qra " + Prefix );
488 else if (arg.equals("Set HomeNode")) {
489 if (Connected) out.println ("set/homenode " + Prefix );
492 else if (arg.equals("Show Personal Settings")) {
493 if (Connected) out.println ("sh/sta " + Call );
499 else if (arg.equals("DXannounce")) {
500 dxannounce pp = new dxannounce(this, Call2, Freq, Remarks, OutFont);
501 if (Connected) out.println ("dx " + Freq + " " + Call2 + " " + Remarks );
505 else if (arg.equals("Last 10 Msgs")) {
506 if (Connected) out.println ("dir" );
508 else if (arg.equals("Last 50 Msgs")) {
509 if (Connected) out.println ("dir/50" );
511 else if (arg.equals("New Messages")) {
512 if (Connected) out.println ("dir/new" );
514 else if (arg.equals("Own Messages")) {
515 if (Connected) out.println ("dir/own" );
522 else if (evt.target instanceof Button) {
523 if (arg.equals("Connect")) {
527 } else if (arg.equals("Disconnect")) {
529 parent.dodisconnect();
539 private idleTime idle;
541 private TextArea input;
542 private TextArea output;
543 private MenuBar menubar;
546 private Menu settings;
549 private Menu commands;
553 private Menu mailbox;
556 private MenuItem connect_menuitem = new MenuItem("Connect");
557 private MenuItem copy_menuitem = new MenuItem("Copy");
558 private MenuItem paste_menuitem = new MenuItem("Paste");
560 private Button connectButton = new java.awt.Button("Connect");
561 private Button disconnectButton = new java.awt.Button("Disconnect");
563 private Date today = new Date();
564 private Label DateLabel = new Label(today.toLocaleString());
565 private Label IdleLabel = new Label("00:00");
566 private Label connectState = new Label("not connected");
569 private Color OutBackgroundColor = new Color(0,0,66);
570 private Color OutForegroundColor = new Color(255,255,0);
571 private Color OutOwnColor = Color.red;
572 private Color InBackgroundColor = new Color(234,199,135);
573 private Color InForegroundColor = Color.red;
575 private Font OutFont = new Font("Courier", Font.PLAIN, 13);
576 private Font InFont = new Font("Courier", Font.BOLD, 13);
578 private String Call = new String("NOCALL");
579 private String Password = new String();
580 private String Fullname = new String("NOBODY");
581 private String Hostname = new String("localhost");
582 private String Port = new String("3600");
583 private String Channel = new String("0");
586 private String Prefix = new String ("");
587 private String Call2 = new String ("");
588 private String Freq = new String ("");
589 private String Remarks = new String ("");
597 private PrintStream out = null;
599 private String InputBuffer[] = new String[256];
600 private int InputPos = 0;
601 private int MaxInputPos = 0;
603 private String CopyPaste;
605 private boolean Connected;
607 private spiderclient parent;
611 class setDate extends Thread {
615 public setDate(spiderframe cf) {
622 try { sleep(1000); } catch (InterruptedException e) {}
624 cf.setTime(today.toLocaleString());
628 private Date today = new Date();
633 class idleTime extends Thread {
638 public idleTime(spiderframe cf) {
644 public void resetTimer() {
651 try { sleep(1000); } catch (InterruptedException e) {}
653 String sec = new Format("%02d").form(count % 60);
654 String min = new Format("%02d").form(count / 60);
655 cf.setIdle("Idle: "+min+":"+sec);