1 16 package net.sf.jftp.gui.framework; 17 18 import net.sf.jftp.*; 19 20 import java.awt.*; 21 import java.awt.event.*; 22 23 import javax.swing.*; 24 25 26 public class HImageButton extends JButton implements MouseListener 27 { 28 public String label = ""; 29 public ActionListener who = null; 30 private boolean entered = false; 31 private Color cacheBack = GUIDefaults.light; 32 33 private Color swing = new Color(155, 155, 205); 35 36 private String cmd = "default"; 42 private boolean drawBorder = true; 43 private JButton button; 44 45 public HImageButton(String image, String cmd, String label, 46 ActionListener who) 47 { 48 this.cmd = cmd; 50 this.label = label; 51 this.who = who; 52 53 try { 54 setIcon(new ImageIcon(HImage.getImage(this, image))); 58 } 59 catch(Exception ex) { 60 System.out.println("Image file: "+image); 61 ex.printStackTrace(); 62 } 63 addMouseListener(this); 65 66 setVisible(true); 68 setMinimumSize(new Dimension(25, 25)); 69 setPreferredSize(new Dimension(25, 25)); 70 setMaximumSize(new Dimension(25, 25)); 71 } 72 73 94 public void update(Graphics g) 95 { 96 paintComponent(g); 97 } 98 99 public void mouseClicked(MouseEvent e) 100 { 101 } 102 103 public void mousePressed(MouseEvent e) 104 { 105 } 106 107 public void mouseReleased(MouseEvent e) 108 { 109 who.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, 111 cmd)); 112 113 } 115 116 public void mouseEntered(MouseEvent e) 117 { 118 entered = true; 119 setCursor(new Cursor(Cursor.HAND_CURSOR)); 120 121 JFtp.statusP.status(label); 125 } 126 127 public void mouseExited(MouseEvent e) 128 { 129 entered = false; 130 setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); 131 132 JFtp.statusP.status(""); 136 } 137 138 public void setBorder(boolean what) 139 { 140 drawBorder = what; 141 } 142 } 143 | Popular Tags |