view 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
line wrap: on
line source
/*
 *	VPanel.java	
 *
 *	Copyright (c) 2000, Samer Abdallah, King's College London.
 *	All rights reserved.
 *
 *	This software is provided AS iS and WITHOUT ANY WARRANTY; 
 *	without even the implied warranty of MERCHANTABILITY or 
 *	FITNESS FOR A PARTICULAR PURPOSE.
 */

package samer.core.util.heavy;
import  samer.core.util.*;
import  samer.core.*;
import  java.awt.*;

public class VPanel extends JPanel implements Viewer
{
	private Menu		menu=null;
	private Viewer		vwr;
	private Label		label;

	public VPanel() { this(null); }
	public VPanel(Viewer vwr) { super(); this.vwr=vwr; }

	public void setName(String txt) {
		if (txt==null) { if (label!=null) remove(label); return; }
		super.setName(txt);
		if (label!=null) label.setText(txt);
		else {
			label=new Label(txt);
			label.addMouseListener(MouseRetarget.listener); 
			add(label,0);
		}
	}

	public Component getComponent() { return this; }
	public void	attach() {}
	public void	detach() {}
	public void	exposeCommands(Agent agent) { 
		menu=MenuBuilder.showCommands(agent,this,menu); 
	}

	public void addNotify() { super.addNotify(); if (vwr!=null) vwr.attach(); }
	public void removeNotify() { if (vwr!=null) vwr.detach(); super.removeNotify(); }

//	public void add(Component c) { super.add(c); }
	public void add(Viewer v) { add(v.getComponent()); }
	public void add(Viewable v) { add(v.getViewer()); }
}