Page 1 of 5 123 ... LastLast
Results 1 to 20 of 92
  1. #1
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default [SOLVED] Hyperlink

    Hi All

    I havn't idea about hyperlink.How can i set hyperlink on label.

    Java Code:
    getContentPane().add( new JLabel( "                               http://www.google.com"  , JLabel.RIGHT) );
    Now i want to do when some one click on Google then it will open a google page.

    How can i do

    Plz help me

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Actually you can do it, by wrtting your own class to fire the default browser on the click event. Or else you can use a JEdiotPane for this, to do in simple way.

  3. #3
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    Actually you can do it, by wrtting your own class to fire the default browser on the click event. Or else you can use a JEdiotPane for this, to do in simple way.
    sir can you give me some example to do that

  4. #4
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    Actually you can do it, by wrtting your own class to fire the default browser on the click event. Or else you can use a JEdiotPane for this, to do in simple way.
    Sir i make a about dialog form.Now now want to set hyper link..


    Plz help me

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  6. #6
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    On which way you are going to do it?
    here is code..
    Plz help me


    Java Code:
    public class JFrameBg extends JFrame {
    	
    	public JFrameBg() {
    		super() ;
    		setTitle( "Background Image on JFrame or JDialog or JApplet" ) ;
    		setDefaultCloseOperation( EXIT_ON_CLOSE ) ;
    		setContentPane( new MyPanel() ) ;
    		getContentPane().add( new JLabel( "http://www.drpu.com" ,  JLabel.CENTER ) ) ;
    		setSize( 400 , 300 ) ;
    		setVisible( true ) ;
    	}
    	
    	public class MyPanel extends JPanel {
    		private Image img ;
    		public MyPanel() {
    			setLayout( new BorderLayout() ) ;
    			img = new ImageIcon( "D:/Personal/Shilu/rose.jpg" ).getImage() ;
    			if( img == null ) {
    				System.out.println( "Image is null" );
    				System.exit( 1 ) ;
    			}
    			if( img.getHeight(this) <= 0 || img.getWidth( this ) <= 0 ) {
    				System.out.println( "Image width or height must be +ve" );
    				System.exit( 2 ) ;
    			}
    		}
    		public void drawBackground( Graphics g ) {
    			int w = getWidth() ;
    			int h = getHeight() ;
    			int iw = img.getWidth( this ) ;
    			int ih = img.getHeight( this ) ;
    			for( int i = 0 ; i < w ; i+=iw ) {
    				for( int j = 0 ; j < h ; j+= ih ) {
    					g.drawImage( img , i , j , this ) ;
    				}
    			}
    		}
    		protected void paintComponent(Graphics g) {
    			super.paintComponent(g);
    			drawBackground( g ) ;
    		}
    	}
    	
    	public static void main(String[] args) {
    		new JFrameBg() ;
    	}
    }

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  8. #8
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    You are going to use in use of label. First try to implement the click event on the label.
    ok sir i going to do that

  9. #9
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    Yes a mouseListener
    To finish sooner, take your own time....
    Nivedithaaaa

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    It's much simple. Simply implements all methods in mouse listener. You have a mouse click event.

  11. #11
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    Yes a mouseListener
    To finish sooner, take your own time....
    Nivedithaaaa

  12. #12
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    It's much simple. Simply implements all methods in mouse listener. You have a mouse click event.
    Sir i need some code plz help me

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    For what? Adding mouseListener? Did you work on an IDE? Did you know how to add events to controls? If the answer is 'yes' this can't be difficult.

  14. #14
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    For what? Adding mouseListener? Did you work on an IDE? Did you know how to add events to controls? If the answer is 'yes' this can't be difficult.
    No i don't know it's a fact.I am very poor progrram..

    Plz help me

  15. #15
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  16. #16
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    Then how did you add all other button events and so on?
    hello Sir

    I need only this..So plz help me

  17. #17
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    You have to do something like this.

    Java Code:
            jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    
                }
            });

  18. #18
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    You have to do something like this.

    Java Code:
            jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    
                }
            });
    Sir i add it..What's a next step

  19. #19
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Sorry, I can't help you step by step. At least make an attempt. Seems you never wants to learn Java. We all told you that what you have to do. But no sign of any attempt.

  20. #20
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    Sorry, I can't help you step by step. At least make an attempt. Seems you never wants to learn Java. We all told you that what you have to do. But no sign of any attempt.
    ok just you give me way then i attempt..

Page 1 of 5 123 ... LastLast

Similar Threads

  1. Replies: 0
    Last Post: 04-01-2008, 04:14 PM
  2. Hide hyperlink address on status bar
    By simon in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-24-2007, 10:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •