1 package jimm.datavision.gui; 2 import java.awt.Font ; 3 import java.awt.Color ; 4 import java.awt.event.MouseAdapter ; 5 import java.awt.event.MouseEvent ; 6 import javax.swing.*; 7 8 15 class SectionNameLabel extends JLabel { 16 17 protected static Font DEFAULT_FONT = new Font ("Serif", Font.PLAIN, 10); 18 19 protected SectionWidget sectionWidget; 20 21 24 class PopupListener extends MouseAdapter { 25 public void mousePressed(MouseEvent e) { maybeShowPopup(e); } 26 public void mouseReleased(MouseEvent e) { maybeShowPopup(e); } 27 private void maybeShowPopup(MouseEvent e) { 28 if (sectionWidget.designer.isPlacingNewTextField()) 29 sectionWidget.designer.rejectNewTextField(); 30 else if (e.isPopupTrigger()) 31 sectionWidget.showPopup(e); 32 } 33 } 34 35 42 SectionNameLabel(String name, SectionWidget sw) { 43 super(name); 44 sectionWidget = sw; 45 setHorizontalAlignment(JLabel.CENTER); 46 setVerticalAlignment(JLabel.TOP); 47 setFont(DEFAULT_FONT); 48 setForeground(Color.black); 49 50 addMouseListener(new PopupListener()); 51 } 52 53 } 54 | Popular Tags |