1 19 20 package org.netbeans.modules.welcome.content; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Cursor ; 24 import java.awt.event.MouseEvent ; 25 import java.awt.event.MouseListener ; 26 import javax.swing.BorderFactory ; 27 import javax.swing.Icon ; 28 import javax.swing.ImageIcon ; 29 import javax.swing.JLabel ; 30 import javax.swing.JPanel ; 31 import org.openide.util.Utilities; 32 33 37 public class Logo extends JPanel implements Constants, MouseListener { 38 39 private String url; 40 41 public static Logo createSunLogo() { 42 return new Logo( SUN_LOGO_IMAGE, BundleSupport.getURL( "SunLogo" ) ); } 44 45 public static Logo createJavaLogo() { 46 return new Logo( JAVA_LOGO_IMAGE, BundleSupport.getURL( "JavaLogo" ) ); } 48 49 public static Logo createNbLogo() { 50 return new Logo( NB_LOGO_IMAGE, BundleSupport.getURL( "NetBeansLogo" ) ); } 52 53 54 public Logo( String img, String url ) { 55 super( new BorderLayout () ); 56 Icon image = new ImageIcon (Utilities.loadImage(img, true)); 57 JLabel label = new JLabel ( image ); 58 label.setBorder( BorderFactory.createEmptyBorder() ); 59 label.setOpaque( false ); 60 label.addMouseListener( this ); 61 setOpaque( false ); 62 add( label, BorderLayout.CENTER ); 63 setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) ); 64 this.url = url; 65 } 66 67 public void mouseClicked(MouseEvent e) { 68 Utils.showURL( url ); 69 } 70 71 public void mousePressed(MouseEvent e) { 72 } 73 74 public void mouseReleased(MouseEvent e) { 75 } 76 77 public void mouseEntered(MouseEvent e) { 78 } 79 80 public void mouseExited(MouseEvent e) { 81 } 82 } 83 | Popular Tags |