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("Show Personal Settings"));
66 dxann = new Menu("DXannounce");
67 dxann.add(new MenuItem("DXannounce"));
70 mailbox = new Menu("Mailbox");
71 mailbox.add(new MenuItem("Last 50 Msgs"));
72 mailbox.add(new MenuItem("List DX Bulletins"));
81 this.setMenuBar(menubar);
83 setLayout(new BorderLayout());
85 Panel p1 = new Panel();
86 p1.setLayout(new BorderLayout());
88 output = new TextArea();
89 output.setEditable(false);
91 p1.add("Center", output);
92 input = new TextArea(2,80);
93 input.setEditable(false);
94 p1.add("South", input);
98 Panel p2 = new Panel();
99 p2.setLayout(new FlowLayout());
100 connectButton.enable();
101 p2.add(connectButton);
103 disconnectButton.disable();
104 p2.add(disconnectButton);
108 Panel p3 = new Panel();
109 GridBagLayout gbl = new GridBagLayout();
112 GridBagConstraints gbc = new GridBagConstraints();
115 gbc.fill = GridBagConstraints.HORIZONTAL;
116 gbc.anchor = GridBagConstraints.CENTER;
118 add(p3,DateLabel,gbl, gbc, 0, 0, 1, 1);
119 add(p3,IdleLabel, gbl, gbc, 2, 0, 2, 1);
120 add(p3,connectState,gbl, gbc, 4, 0, 2, 1);
127 setDate time = new setDate(this);
128 idle = new idleTime(this);
133 private void add(Panel p,Component c, GridBagLayout gbl,
134 GridBagConstraints gbc,
135 int x, int y, int w, int h) {
141 gbl.setConstraints(c, gbc);
145 public void setColors() {
146 output.setBackground(OutBackgroundColor);
147 output.setForeground(OutForegroundColor);
148 input.setBackground(InBackgroundColor);
149 input.setForeground(InForegroundColor);
152 public void setFonts() {
153 output.setFont(OutFont);
154 input.setFont(InFont);
157 public void initPrintStream(PrintStream out) {
161 public void setText(String s) {
164 for (i=0; i < s.length(); i++) {
165 if (s.charAt(i) == '\007')
168 output.appendText(s +'\n');
172 public void setCall(String s) {
176 public void setPrefix(String s) {
182 public void setCall2(String s) {
186 public void setFreq(String s) {
191 public void setRemarks(String s) {
198 public void setTime(String s) {
199 DateLabel.setText(s);
202 public void setIdle(String s) {
203 IdleLabel.setText(s);
206 public String getCall() {
210 public String setPrefix(){
214 public String setCall2(){
218 public String setFreq(){
222 public String setRemarks(){
230 public void setFullname(String s) {
232 if (Call.equals("NOCALL"))
233 connect_menuitem.disable();
235 connect_menuitem.enable();
238 public String getFullname() {
242 public void setHostname(String s) {
246 public String getHostname() {
250 public void setPort(String s) {
254 public String getPort() {
258 public void setChannel(String s) {
262 public String getChannel() {
266 // public void login() {
267 // PersonalPreferences pp = new PersonalPreferences(this, Call, Fullname, OutFont);
270 public void antrichtung () {
271 beam pp = new beam (this, Prefix,OutFont);
274 public void dxannounce () {
275 dxannounce pp = new dxannounce (this, Call2, Freq, Remarks, OutFont);
283 public boolean handleEvent(Event evt) {
284 if (evt.id == Event.KEY_PRESS) {
285 if (evt.key == '\n') {
290 output.appendText(input.getText()+'\n');
291 out.println(input.getText());
294 if (MaxInputPos < 255) {
300 for(int i=0; i < 254; i++) {
301 InputBuffer[i] = new String(InputBuffer[i+1]);
306 InputBuffer[InputPos-1] = new String(input.getText());
310 } else if (evt.id == Event.KEY_ACTION) {
311 if (evt.key == Event.UP) {
314 input.setText(InputBuffer[InputPos]);
318 else if (evt.key == Event.DOWN) {
319 if (InputPos < MaxInputPos) {
321 input.setText(InputBuffer[InputPos]);
331 return super.handleEvent(evt);
334 public synchronized void show() {
339 public void setUserColor(Color c, String whichColor) {
340 if (whichColor.equals("Output Background ...")) {
341 OutBackgroundColor = c;
343 else if (whichColor.equals("Output Foreground ...")) {
344 OutForegroundColor = c;
345 } else if (whichColor.equals("Input Background ...")) {
346 InBackgroundColor = c;
348 else if (whichColor.equals("Input Foreground ...")) {
349 InForegroundColor = c;
350 } else if (whichColor.equals("Output own text ...")) {
358 public void connected() {
359 connect_menuitem.setLabel("Disconnect");
360 connectState.setText("Connected to "+Hostname+":"+Port);
361 input.setEditable(true);
362 copy_menuitem.enable();
364 connectButton.disable();
365 disconnectButton.enable();
368 public void disconnected() {
370 connect_menuitem.setLabel("Connect");
371 connectState.setText("Disconnected from "+Hostname);
372 input.setEditable(false);
373 copy_menuitem.disable();
374 paste_menuitem.disable();
375 connectButton.enable();
376 disconnectButton.disable();
379 public void setUserFont(String name, int size, int style,
381 if (whichFont.equals("Area ...")) {
382 OutFont = new Font(name, style, size);
384 else if (whichFont.equals("Input Line ...")) {
385 InFont = new Font(name, style, size);
392 public void getSelectedText() {
393 CopyPaste = new String(output.getSelectedText());
394 paste_menuitem.enable();
397 public boolean action(Event evt, Object arg) {
398 if (evt.target instanceof MenuItem) {
399 if (arg.equals("Quit")) {
401 // } else if (arg.equals("Personal preferences ...")) {
402 // PersonalPreferences pp = new PersonalPreferences(this,
403 // Call, Fullname, OutFont);
404 } else if (arg.equals("Connect")) {
406 } else if (arg.equals("Disconnect")) {
407 parent.dodisconnect();
408 } else if (arg.equals("About")) {
409 InfoDialog id = new InfoDialog(this, "About",
410 "JAVA Spider Webclient 0.6b\nPA4AB\n" +
411 "pa4ab@pa4ab.net \n" +
413 "Based on source of the CLX Client from dl6dbh" );
417 } else if (arg.equals("Copy")) {
419 } else if (arg.equals("Paste")) {
420 input.insertText(CopyPaste,input.getSelectionStart());
421 } else if (arg.equals("Bye")) {
422 if (Connected) out.println("bye");
423 } else if (arg.equals("Help")) {
424 if (Connected) out.println("help overview");
425 } else if (arg.equals("Show Last DX")) {
426 if (Connected) out.println("sh/dx");
427 } else if (arg.equals("Status")) {
428 if (Connected) out.println("sh/conf");
429 } else if (arg.equals("Show WWV")) {
430 if (Connected) out.println("sh/wwv");
431 } else if (arg.equals("Show Beam Direction")) {
432 beam pp = new beam(this, Prefix, OutFont);
433 if (Connected) out.println ("sh/heading " + Prefix );
434 } else if (arg.equals("search DX")) {
435 beam pp = new beam(this, Prefix, OutFont);
436 if (Connected) out.println ("sh/dx " + Prefix );
438 } else if (arg.equals("Search QSL Info")) {
439 beam pp = new beam(this, Prefix, OutFont);
440 if (Connected) out.println ("sh/qsl " + Prefix );
443 } else if (arg.equals("search Adress")) {
444 beam pp = new beam(this, Prefix, OutFont);
445 if (Connected) out.println ("sh/qrz " + Prefix );
448 } else if (arg.equals("search qsl Manager")) {
449 beam pp = new beam(this, Prefix, OutFont);
450 if (Connected) out.println ("sh/qsl " + Prefix );
453 } else if (arg.equals("search DXCC")) {
454 beam pp = new beam(this, Prefix, OutFont);
455 if (Connected) out.println ("sh/dxcc " + Prefix );
459 } else if (arg.equals("Set Beep")) {
460 if (Connected) out.println("set/Beep");
462 }else if (arg.equals("Set QTH / City")) {
463 beam pp = new beam(this, Prefix, OutFont);
464 if (Connected) out.println ("set/qth " + Prefix );
467 }else if (arg.equals("Set Name")) {
468 beam pp = new beam(this, Prefix, OutFont);
469 if (Connected) out.println ("set/name " + Prefix );
472 else if (arg.equals("Set Locator")) {
473 beam pp = new beam(this, Prefix, OutFont);
474 if (Connected) out.println ("set/loc " + Prefix );
478 else if (arg.equals("Show Personal Settings")) {
479 if (Connected) out.println ("show/sta " + Call );
486 else if (arg.equals("DXannounce")) {
487 dxannounce pp = new dxannounce(this, Call2, Freq, Remarks, OutFont);
488 if (Connected) out.println ("dx " + Call2 + " " + Freq + " " + Remarks );
492 else if (arg.equals("last 50 Msgs")) {
493 if (Connected) out.println ("dir/50 " );
495 else if (arg.equals("list DX Bulletins")) {
496 if (Connected) out.println ("dir/bul " );
498 else if (arg.equals("new Msgs")) {
499 if (Connected) out.println ("dir/new " );
501 else if (arg.equals("own Msgs")) {
502 if (Connected) out.println ("dir/own " );
509 else if (evt.target instanceof Button) {
510 if (arg.equals("Connect")) {
514 } else if (arg.equals("Disconnect")) {
516 parent.dodisconnect();
526 private idleTime idle;
528 private TextArea input;
529 private TextArea output;
530 private MenuBar menubar;
533 private Menu settings;
536 private Menu commands;
540 private Menu mailbox;
543 private MenuItem connect_menuitem = new MenuItem("Connect");
544 private MenuItem copy_menuitem = new MenuItem("Copy");
545 private MenuItem paste_menuitem = new MenuItem("Paste");
547 private Button connectButton = new java.awt.Button("Connect");
548 private Button disconnectButton = new java.awt.Button("Disconnect");
550 private Date today = new Date();
551 private Label DateLabel = new Label(today.toLocaleString());
552 private Label IdleLabel = new Label("00:00");
553 private Label connectState = new Label("not connected");
556 private Color OutBackgroundColor = new Color(0,0,66);
557 private Color OutForegroundColor = new Color(255,255,0);
558 private Color OutOwnColor = Color.red;
559 private Color InBackgroundColor = new Color(234,199,135);
560 private Color InForegroundColor = Color.red;
562 private Font OutFont = new Font("Courier", Font.PLAIN, 13);
563 private Font InFont = new Font("Courier", Font.BOLD, 13);
565 private String Call = new String("NOCALL");
566 private String Fullname = new String("NOBODY");
567 private String Hostname = new String("localhost");
568 private String Port = new String("3600");
569 private String Channel = new String("0");
572 private String Prefix = new String ("");
573 private String Call2 = new String ("");
574 private String Freq = new String ("");
575 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;
597 class setDate extends Thread {
601 public setDate(spiderframe cf) {
608 try { sleep(1000); } catch (InterruptedException e) {}
610 cf.setTime(today.toLocaleString());
614 private Date today = new Date();
619 class idleTime extends Thread {
624 public idleTime(spiderframe cf) {
630 public void resetTimer() {
637 try { sleep(1000); } catch (InterruptedException e) {}
639 String sec = new Format("%02d").form(count % 60);
640 String min = new Format("%02d").form(count / 60);
641 cf.setIdle("Idle: "+min+":"+sec);