annotate src/samer/core_/util/heavy/VPanel.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents bf79fb79ee13
children
rev   line source
samer@0 1 /*
samer@0 2 * VPanel.java
samer@0 3 *
samer@0 4 * Copyright (c) 2000, Samer Abdallah, King's College London.
samer@0 5 * All rights reserved.
samer@0 6 *
samer@0 7 * This software is provided AS iS and WITHOUT ANY WARRANTY;
samer@0 8 * without even the implied warranty of MERCHANTABILITY or
samer@0 9 * FITNESS FOR A PARTICULAR PURPOSE.
samer@0 10 */
samer@0 11
samer@0 12 package samer.core.util.heavy;
samer@0 13 import samer.core.util.*;
samer@0 14 import samer.core.*;
samer@0 15 import java.awt.*;
samer@0 16
samer@0 17 public class VPanel extends JPanel implements Viewer
samer@0 18 {
samer@0 19 private Menu menu=null;
samer@0 20 private Viewer vwr;
samer@0 21 private Label label;
samer@0 22
samer@0 23 public VPanel() { this(null); }
samer@0 24 public VPanel(Viewer vwr) { super(); this.vwr=vwr; }
samer@0 25
samer@0 26 public void setName(String txt) {
samer@0 27 if (txt==null) { if (label!=null) remove(label); return; }
samer@0 28 super.setName(txt);
samer@0 29 if (label!=null) label.setText(txt);
samer@0 30 else {
samer@0 31 label=new Label(txt);
samer@0 32 label.addMouseListener(MouseRetarget.listener);
samer@0 33 add(label,0);
samer@0 34 }
samer@0 35 }
samer@0 36
samer@0 37 public Component getComponent() { return this; }
samer@0 38 public void attach() {}
samer@0 39 public void detach() {}
samer@0 40 public void exposeCommands(Agent agent) {
samer@0 41 menu=MenuBuilder.showCommands(agent,this,menu);
samer@0 42 }
samer@0 43
samer@0 44 public void addNotify() { super.addNotify(); if (vwr!=null) vwr.attach(); }
samer@0 45 public void removeNotify() { if (vwr!=null) vwr.detach(); super.removeNotify(); }
samer@0 46
samer@0 47 // public void add(Component c) { super.add(c); }
samer@0 48 public void add(Viewer v) { add(v.getComponent()); }
samer@0 49 public void add(Viewable v) { add(v.getViewer()); }
samer@0 50 }
samer@0 51