/Users/lyon/j4p/src/gui/mouse/MoveLabel.java

1    package gui.mouse; 
2     
3     
4    import gui.ClosableJFrame; 
5     
6    public class MoveLabel extends javax.swing.JLabel { 
7        public MoveLabel(String text) { 
8            this(text, null, LEFT); 
9        } 
10    
11       public MoveLabel(String text, javax.swing.Icon icon, int horizontalAlignment) { 
12           super(text, icon, horizontalAlignment); 
13           new MouseComponentMover(this) { 
14               public void doubleClicked(java.awt.Point p) { 
15                   setText(utils.IO.getString(getText())); 
16               } 
17           }; 
18    
19       } 
20    
21       public MoveLabel(javax.swing.Icon image, int horizontalAlignment) { 
22           this(null, image, horizontalAlignment); 
23       } 
24    
25       public MoveLabel(javax.swing.Icon image) { 
26           this(null, image, CENTER); 
27       } 
28    
29       public MoveLabel() { 
30           this("", null, LEFT); 
31       } 
32    
33       public static void main(String args[]) { 
34           ClosableJFrame cf = new ClosableJFrame(); 
35           java.awt.Container c = cf.getContentPane(); 
36           cf.setSize(200, 200); 
37           c.setLayout(null); 
38           MoveLabel ml = new MoveLabel("hello move label"); 
39           ml.setSize(150, 10); 
40           ml.setLocation(20, 30); 
41           c.add(ml); 
42           cf.setVisible(true); 
43       } 
44   }