@@ -22,7 +22,7 @@ public class NetrekFrame extends Frame {
22
22
public InfoPanel server_info ;
23
23
public LocalPanel local ;
24
24
public GalacticPanel galactic ;
25
- public Dashboard dashboard ;
25
+ public Dashboard dashboard ; // also known as tstat i think
26
26
public WarningPanel warning ;
27
27
public MessagePanel message ;
28
28
public PlayerListPanel player_list ;
@@ -56,6 +56,7 @@ public class NetrekFrame extends Frame {
56
56
public FeatureList feature_list ;
57
57
public Beeplite beeplite ;
58
58
public boolean quit = false ;
59
+ private NetrekFrame netrekFrame ;
59
60
60
61
public NetrekFrame (Communications comm , Universe data ) {
61
62
super ("Netrek" );
@@ -65,6 +66,8 @@ public NetrekFrame(Communications comm, Universe data) {
65
66
setBackground (Color .black );
66
67
setIconImage (ICON_IMAGE );
67
68
69
+ netrekFrame = this ;
70
+
68
71
// install the message handlers
69
72
dmessage = new IncomingMessageHandler (this , data , comm );
70
73
smessage = new SendMessage (this , data , comm );
@@ -216,6 +219,80 @@ public void windowClosing(WindowEvent e) {
216
219
detached_motd .addKeyListener (key_handler );
217
220
detached_motd .detachWindow (null ).addKeyListener (key_handler );
218
221
setupBasePanel (detached_motd );
222
+
223
+ this .addComponentListener (new ComponentAdapter () {
224
+ public void componentResized (ComponentEvent e ) {
225
+ // This is only called when the user releases the mouse button.
226
+ System .out .println ("componentResized" );
227
+ netrekFrame .resizeWindows ();
228
+ }
229
+ });
230
+
231
+ }
232
+
233
+ void resizeWindows () {
234
+ int windowWidth = this .getWidth ();
235
+ int windowHeight = this .getHeight ();
236
+
237
+ int leftYPosition = 0 ;
238
+ int rightYPosition = 0 ;
239
+ int halfWidth = windowWidth / 2 ;
240
+
241
+ int mapDimension = Math .min (halfWidth , windowHeight * 742 / 1008 ); //keep maps square
242
+
243
+ // overlapping front windows
244
+
245
+ entry .setBounds (0 , 0 , mapDimension , mapDimension );
246
+ if (login != null ) {
247
+ login .setBounds (0 , 0 , mapDimension , mapDimension );
248
+ }
249
+ information .setBounds (0 , 0 , mapDimension , mapDimension );
250
+ attached_motd .setBounds (halfWidth , 0 , mapDimension , mapDimension );
251
+ options .setBounds (halfWidth , 0 , mapDimension , mapDimension );
252
+
253
+ // left column
254
+
255
+ local .setBounds (0 ,0 ,mapDimension , mapDimension );
256
+ leftYPosition += mapDimension ;
257
+
258
+ dashboard .setBounds (0 , leftYPosition , halfWidth , 51 );;
259
+ leftYPosition += 51 ;
260
+
261
+ // reviews seem to overlap
262
+ review .setBounds (0 ,leftYPosition , halfWidth , windowHeight / 4 );
263
+ leftYPosition += windowHeight / 4 ;
264
+
265
+ review_all .setBounds (0 ,leftYPosition , halfWidth , windowHeight / 8 );
266
+ leftYPosition += windowHeight / 8 ;
267
+
268
+ review_team .setBounds (0 ,leftYPosition , halfWidth , windowHeight / 8 );
269
+ leftYPosition += windowHeight / 8 ;
270
+
271
+ review_your .setBounds (0 , leftYPosition , halfWidth , windowHeight / 8 );
272
+ leftYPosition += windowHeight / 8 ;
273
+
274
+ review_kill .setBounds (0 , leftYPosition , halfWidth , windowHeight / 8 );
275
+ leftYPosition += windowHeight / 8 ;
276
+
277
+ review_phaser .setBounds (0 , leftYPosition , halfWidth , windowHeight / 8 );
278
+ leftYPosition += windowHeight / 8 ;
279
+
280
+ // right column
281
+
282
+ galactic .setBounds (halfWidth , 0 , mapDimension , mapDimension );
283
+ rightYPosition += mapDimension ;
284
+
285
+ warning .setBounds (halfWidth , rightYPosition , halfWidth , windowHeight / 28 );
286
+ rightYPosition += windowHeight / 28 ;
287
+
288
+ message .setBounds (halfWidth , rightYPosition , windowWidth /2 , windowHeight / 28 );
289
+ rightYPosition += windowHeight / 28 ;
290
+
291
+ player_list .setBounds (halfWidth , rightYPosition , windowWidth / 2 , windowHeight /4 );
292
+ rightYPosition += windowHeight / 4 ;
293
+
294
+
295
+
219
296
}
220
297
221
298
void shutDown () {
@@ -268,6 +345,7 @@ public void slotFound() {
268
345
// z-order of dialogs don't stay over this frame correctly
269
346
addNotify ();
270
347
addWindows ();
348
+ //newWindowSetup();
271
349
Insets insets = getInsets ();
272
350
Rectangle rect = Defaults .getWindowGeometry ("netrek" );
273
351
rect .width += insets .left + insets .right ;
@@ -278,6 +356,43 @@ public void slotFound() {
278
356
requestFocus ();
279
357
}
280
358
359
+ /*public void newWindowSetup() {
360
+
361
+ this.setBounds(0,0,1008,742);
362
+
363
+ add(information);
364
+
365
+ BasePanel login = (BasePanel) getWindow("login");
366
+ login.setVisible(false);
367
+ Container netrekWindow = getWindow("netrek");
368
+ GridBagConstraints constraints = new GridBagConstraints();
369
+
370
+ constraints.gridx = 0;
371
+ constraints.gridy = 0;
372
+ constraints.anchor = GridBagConstraints.NORTHWEST;
373
+ netrekWindow.add(login,constraints);
374
+
375
+ BasePanel local = (BasePanel) getWindow("local");
376
+ local.setMinimumSize(new Dimension(508,508));
377
+ local.setBounds(0, 0, 500, 500);
378
+ constraints.gridx = 0;
379
+ constraints.gridy = 0;
380
+ constraints.anchor = GridBagConstraints.NORTHWEST;
381
+ netrekWindow.add(local,constraints);
382
+ local.setVisible(true);
383
+
384
+
385
+ BasePanel entry = (BasePanel) getWindow("entry");
386
+ entry.setVisible(false);
387
+
388
+ constraints.gridx = 0;
389
+ constraints.gridy = 0;
390
+ constraints.anchor = GridBagConstraints.NORTHWEST;
391
+ netrekWindow.add(entry,constraints);
392
+
393
+ }
394
+ */
395
+
281
396
public void showLogin () {
282
397
local .setVisible (true );
283
398
galactic .setVisible (true );
@@ -312,7 +427,14 @@ else if(parent_name.equalsIgnoreCase("none")) {
312
427
parent = this ;
313
428
}
314
429
try {
315
- parent .add (panel );
430
+ //GridBagConstraints constraints = getConstraints(panel);
431
+ setSize (panel );
432
+ //if (constraints != null) {
433
+ // parent.add(panel,constraints);
434
+ //} else {
435
+ parent .add (panel );
436
+ //}
437
+ panel .setVisible (Defaults .getWindowVisible (panel .name ));
316
438
}
317
439
catch (IllegalArgumentException e ) {
318
440
System .err .println ("Error adding window \" " + panel .getName () + "\" to parent, " + e .getMessage ());
@@ -328,6 +450,7 @@ void setupWindows() {
328
450
setupBasePanel (windows [w ]);
329
451
}
330
452
}
453
+
331
454
332
455
/** setupBasePanel */
333
456
void setupBasePanel (BasePanel panel ) {
@@ -342,6 +465,67 @@ void setupBasePanel(BasePanel panel) {
342
465
panel .setVisible (Defaults .getWindowVisible (panel .name ));
343
466
}
344
467
468
+ /*private GridBagConstraints getConstraints(BasePanel panel) {
469
+ GridBagConstraints constraints = new GridBagConstraints();
470
+ if (panel.name.equals("local")) {
471
+ constraints.gridx = 0;
472
+ constraints.gridy = 0;
473
+ constraints.anchor = GridBagConstraints.NORTHWEST;
474
+ return constraints;
475
+ } else if (panel.name.equals("map")) {
476
+ constraints.gridx = 0;
477
+ constraints.gridy = 1;
478
+ constraints.anchor = GridBagConstraints.NORTHEAST;
479
+ return constraints;
480
+ } else {
481
+ return null;
482
+ }
483
+ }*/
484
+
485
+ void setSize (BasePanel panel ) {
486
+ if (panel .getParent () != null ) {
487
+ Rectangle geometry = Defaults .getWindowGeometry (panel .name );
488
+ if (geometry .x < 0 ) {
489
+ geometry .x = 0 ;
490
+ }
491
+ if (geometry .y < 0 ) {
492
+ geometry .y = 0 ;
493
+ }
494
+ panel .setBounds (geometry );
495
+ }
496
+ }
497
+ /**
498
+ * New attempt to setup windows for netrek 0.9.7 to allow resizing
499
+ * @param panel
500
+ */
501
+ /*void setupBasePanel2(BasePanel panel) {
502
+ GridBagConstraints constraints = new GridBagConstraints();
503
+
504
+ if (panel.name.equals("local")) {
505
+ constraints.gridx = 0;
506
+ constraints.gridy = 0;
507
+ constraints.anchor = GridBagConstraints.NORTHWEST;
508
+ panel.setSize(508, 508);
509
+ panel.setVisible(true);
510
+ } else if (panel.name.equals("map")) {
511
+ constraints.gridx = 0;
512
+ constraints.gridy = 1;
513
+ constraints.anchor = GridBagConstraints.NORTHEAST;
514
+ panel.setSize(508, 508);
515
+ panel.setVisible(true);
516
+ } else {
517
+ if(panel.getParent() != null) {
518
+ Rectangle geometry = Defaults.getWindowGeometry(panel.name);
519
+ if(panel.getParent() == this) {
520
+ Insets i = getInsets();
521
+ geometry.translate(i.left, i.top);
522
+ }
523
+ panel.setBounds(geometry);
524
+ }
525
+ panel.setVisible(Defaults.getWindowVisible(panel.name));
526
+ }
527
+ }*/
528
+
345
529
/** loginComplete */
346
530
public void loginComplete () {
347
531
login .getParent ().remove (login );
0 commit comments