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("Show WCY"));
49 show.add(new MenuItem("Search DX"));
50 show.add(new MenuItem("Search Address"));
51 show.add(new MenuItem("Search QSL Manager"));
52 show.add(new MenuItem("Search QSL Info"));
53 show.add(new MenuItem("Search DXCC"));
54 show.add(new MenuItem("Status"));
58 set = new Menu("Settings");
59 set.add(new MenuItem("Set Beep"));
60 set.add(new MenuItem("Set No Beep"));
61 set.add(new MenuItem("Set QTH / City"));
62 set.add(new MenuItem("Set Name"));
63 set.add(new MenuItem("Set Locator"));
64 set.add(new MenuItem("Set HomeNode"));
65 set.add(new MenuItem("Set DX-Grid"));
66 set.add(new MenuItem("Set No DX-Grid"));
67 set.add(new MenuItem("Show Personal Settings"));
71 dxann = new Menu("DXannounce");
72 dxann.add(new MenuItem("DXannounce"));
75 mailbox = new Menu("Mailbox");
76 mailbox.add(new MenuItem("Last 10 Msgs"));
77 mailbox.add(new MenuItem("Last 50 Msgs"));
78 mailbox.add(new MenuItem("New Messages"));
79 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 setNodecall(String s) {
183 public void setPassword(String s) {
187 public void setPrefix(String s) {
191 public void setCall2(String s) {
195 public void setFreq(String s) {
199 public void setRemarks(String s) {
203 public void setTime(String s) {
204 DateLabel.setText(s);
207 public void setIdle(String s) {
208 IdleLabel.setText(s);
211 public String getCall() {
215 public String getPassword() {
219 public String setPrefix(){
223 public String setCall2(){
227 public String setFreq(){
231 public String setRemarks(){
235 public void setFullname(String s) {
237 if (Call.equals("NOCALL"))
238 connect_menuitem.disable();
240 connect_menuitem.enable();
243 public String getFullname() {
247 public void setHostname(String s) {
251 public String getHostname() {
255 public void setPort(String s) {
259 public String getPort() {
263 public void setChannel(String s) {
267 public String getChannel() {
271 // public void login() {
272 // PersonalPreferences pp = new PersonalPreferences(this, Call, Fullname, OutFont);
275 public void antrichtung () {
276 beam pp = new beam (this, Prefix,OutFont);
279 // public void dxannounce () {
280 // dxannounce pp = new dxannounce (this, Call2, Freq, Remarks, OutFont);
284 public boolean handleEvent(Event evt) {
285 if (evt.id == Event.KEY_PRESS) {
286 if (evt.key == '\n') {
289 output.appendText(input.getText()+'\n');
290 out.println(input.getText());
292 if (MaxInputPos < 255) {
298 for(int i=0; i < 254; i++) {
299 InputBuffer[i] = new String(InputBuffer[i+1]);
304 InputBuffer[InputPos-1] = new String(input.getText());
308 } else if (evt.id == Event.KEY_ACTION) {
309 if (evt.key == Event.UP) {
312 input.setText(InputBuffer[InputPos]);
316 else if (evt.key == Event.DOWN) {
317 if (InputPos < MaxInputPos) {
319 input.setText(InputBuffer[InputPos]);
327 return super.handleEvent(evt);
330 public synchronized void show() {
335 public void setUserColor(Color c, String whichColor) {
336 if (whichColor.equals("Output Background ...")) {
337 OutBackgroundColor = c;
339 else if (whichColor.equals("Output Foreground ...")) {
340 OutForegroundColor = c;
341 } else if (whichColor.equals("Input Background ...")) {
342 InBackgroundColor = c;
344 else if (whichColor.equals("Input Foreground ...")) {
345 InForegroundColor = c;
346 } else if (whichColor.equals("Output own text ...")) {
354 public void connected() {
355 connect_menuitem.setLabel("Disconnect");
356 connectState.setText("Connected to " + Nodecall);
357 input.setEditable(true);
358 copy_menuitem.enable();
360 connectButton.disable();
361 disconnectButton.enable();
364 public void disconnected() {
366 connect_menuitem.setLabel("Connect");
367 connectState.setText("Disconnected from " + Nodecall);
368 input.setEditable(false);
369 copy_menuitem.disable();
370 paste_menuitem.disable();
371 connectButton.enable();
372 disconnectButton.disable();
375 public void setUserFont(String name, int size, int style,
377 if (whichFont.equals("Area ...")) {
378 OutFont = new Font(name, style, size);
380 else if (whichFont.equals("Input Line ...")) {
381 InFont = new Font(name, style, size);
388 public void getSelectedText() {
389 CopyPaste = new String(output.getSelectedText());
390 paste_menuitem.enable();
393 public boolean action(Event evt, Object arg) {
395 Prefix = ""; // Make sure that the following variables are empty !
400 if (evt.target instanceof MenuItem) {
401 if (arg.equals("Quit")) {
403 // } else if (arg.equals("Personal preferences ...")) {
404 // PersonalPreferences pp = new PersonalPreferences(this,
405 // Call, Fullname, OutFont);
406 } else if (arg.equals("Connect")) {
408 } else if (arg.equals("Disconnect")) {
409 parent.dodisconnect();
410 } else if (arg.equals("About")) {
411 InfoDialog id = new InfoDialog(this, "About",
412 "JAVA Spider Webclient 1.0\n\nModified by PA4AB, M0AZM and OZ1LQH\n" +
415 "Based on source of the CLX Client from DL6DBH" );
419 } else if (arg.equals("Copy")) {
421 } else if (arg.equals("Paste")) {
422 input.insertText(CopyPaste,input.getSelectionStart());
423 } else if (arg.equals("Bye")) {
424 if (Connected) out.println("bye");
425 } else if (arg.equals("Help")) {
426 if (Connected) out.println("? all");
427 } else if (arg.equals("Show Last DX")) {
428 if (Connected) out.println("sh/dx");
429 } else if (arg.equals("Status")) {
430 if (Connected) out.println("sh/c");
431 } else if (arg.equals("Show WWV")) {
432 if (Connected) out.println("sh/wwv");
433 } else if (arg.equals("Show WCY")) {
434 if (Connected) out.println("sh/wcy");
435 } else if (arg.equals("Show Beam Direction")) {
436 beam pp = new beam(this, Prefix, OutFont);
437 if ((Connected) && !(Prefix.equals(""))) out.println ("sh/heading " + Prefix );
438 } else if (arg.equals("Search DX")) {
439 beam pp = new beam(this, Prefix, OutFont);
440 if ((Connected) && !(Prefix.equals(""))) out.println ("sh/dx " + Prefix );
442 } else if (arg.equals("Search QSL Info")) {
443 beam pp = new beam(this, Prefix, OutFont);
444 if ((Connected) && !(Prefix.equals(""))) out.println ("sh/qsl " + Prefix );
447 } else if (arg.equals("Search Address")) {
448 beam pp = new beam(this, Prefix, OutFont);
449 if ((Connected) && !(Prefix.equals(""))) out.println ("sh/qrz " + Prefix );
452 } else if (arg.equals("Search QSL Manager")) {
453 beam pp = new beam(this, Prefix, OutFont);
454 if ((Connected) && !(Prefix.equals(""))) out.println ("sh/qsl " + Prefix );
457 } else if (arg.equals("Search DXCC")) {
458 beam pp = new beam(this, Prefix, OutFont);
459 if ((Connected) && !(Prefix.equals(""))) out.println ("sh/pr " + Prefix );
463 } else if (arg.equals("Set Beep")) {
464 if (Connected) out.println("set/beep");
466 } else if (arg.equals("Set No Beep")) {
467 if (Connected) out.println("set/nobeep");
469 } else if (arg.equals("Set QTH / City")) {
470 beam pp = new beam(this, Prefix, OutFont);
471 if ((Connected) && !(Prefix.equals(""))) out.println ("set/qth " + Prefix );
473 } else if (arg.equals("Set Name")) {
474 beam pp = new beam(this, Prefix, OutFont);
475 if ((Connected) && !(Prefix.equals(""))) out.println ("set/name " + Prefix );
477 } else if (arg.equals("Set Locator")) {
478 beam pp = new beam(this, Prefix, OutFont);
479 if ((Connected) && !(Prefix.equals(""))) out.println ("set/qra " + Prefix );
481 } else if (arg.equals("Set HomeNode")) {
482 beam pp = new beam(this, Prefix, OutFont);
483 if ((Connected) && !(Prefix.equals(""))) out.println ("set/homenode " + Prefix );
485 } else if (arg.equals("Set DX-Grid")) {
486 if (Connected) out.println("set/dxgrid");
488 } else if (arg.equals("Set No DX-Grid")) {
489 if (Connected) out.println("set/nodxgrid");
491 } else if (arg.equals("Show Personal Settings")) {
492 if (Connected) out.println ("sh/sta " + Call );
497 else if (arg.equals("DXannounce")) {
498 dxannounce pp = new dxannounce(this, Call2, Freq, Remarks, OutFont);
499 if ((Connected) && !(Call2.equals(""))) out.println ("dx " + Freq + " " + Call2 + " " + Remarks );
504 else if (arg.equals("Last 10 Msgs")) {
505 if (Connected) out.println ("dir" );
506 } else if (arg.equals("Last 50 Msgs")) {
507 if (Connected) out.println ("dir/50" );
508 } else if (arg.equals("New Messages")) {
509 if (Connected) out.println ("dir/new" );
510 } else if (arg.equals("Own Messages")) {
511 if (Connected) out.println ("dir/own" );
515 else if (evt.target instanceof Button) {
516 if (arg.equals("Connect")) {
520 } else if (arg.equals("Disconnect")) {
522 parent.dodisconnect();
530 private idleTime idle;
532 private TextArea input;
533 private TextArea output;
534 private MenuBar menubar;
537 private Menu settings;
540 private Menu commands;
544 private Menu mailbox;
547 private MenuItem connect_menuitem = new MenuItem("Connect");
548 private MenuItem copy_menuitem = new MenuItem("Copy");
549 private MenuItem paste_menuitem = new MenuItem("Paste");
551 private Button connectButton = new java.awt.Button("Connect");
552 private Button disconnectButton = new java.awt.Button("Disconnect");
554 private Date today = new Date();
555 private Label DateLabel = new Label(today.toLocaleString());
556 private Label IdleLabel = new Label("00:00");
557 private Label connectState = new Label("not connected");
560 private Color OutBackgroundColor = Color.black;
561 private Color OutForegroundColor = Color.yellow;
562 private Color OutOwnColor = Color.red;
563 private Color InBackgroundColor = new Color(234,199,135);
564 private Color InForegroundColor = Color.red;
566 private Font OutFont = new Font("Courier", Font.PLAIN, 13);
567 private Font InFont = new Font("Courier", Font.BOLD, 13);
569 private String Call = new String("NOCALL");
570 private String Password = new String();
571 private String Fullname = new String("NOBODY");
572 private String Hostname = new String("localhost");
573 private String Port = new String("3600");
574 private String Channel = new String("0");
575 private String Nodecall = new String("nodecall");
577 private String Prefix = new String ("");
578 private String Call2 = new String ("");
579 private String Freq = new String ("");
580 private String Remarks = new String ("");
583 private PrintStream out = null;
585 private String InputBuffer[] = new String[256];
586 private int InputPos = 0;
587 private int MaxInputPos = 0;
589 private String CopyPaste;
591 private boolean Connected;
593 private spiderclient parent;
596 class setDate extends Thread {
600 public setDate(spiderframe cf) {
607 try { sleep(1000); } catch (InterruptedException e) {}
609 cf.setTime(today.toLocaleString());
612 private Date today = new Date();
615 class idleTime extends Thread {
620 public idleTime(spiderframe cf) {
626 public void resetTimer() {
632 try { sleep(1000); } catch (InterruptedException e) {}
634 String sec = new Format("%02d").form(count % 60);
635 String min = new Format("%02d").form(count / 60);
636 cf.setIdle("Idle: "+min+":"+sec);