Results 1 to 20 of 92
Thread: [SOLVED] Hyperlink
- 07-02-2008, 06:26 AM #1
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
[SOLVED] Hyperlink
Hi All
I havn't idea about hyperlink.How can i set hyperlink on label.
Now i want to do when some one click on Google then it will open a google page.Java Code:getContentPane().add( new JLabel( " http://www.google.com" , JLabel.RIGHT) );
How can i do
Plz help me
- 07-02-2008, 06:55 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
- 07-02-2008, 07:03 AM #3
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-02-2008, 07:18 AM #4
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-02-2008, 07:21 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
On which way you are going to do it?
- 07-02-2008, 07:25 AM #6
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
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() ; } }
- 07-02-2008, 07:54 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You are going to use in use of label. First try to implement the click event on the label.
- 07-02-2008, 08:23 AM #8
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-02-2008, 08:32 AM #9
Yes a mouseListener
To finish sooner, take your own time....
Nivedithaaaa
- 07-02-2008, 08:36 AM #10
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
It's much simple. Simply implements all methods in mouse listener. You have a mouse click event.
- 07-02-2008, 08:39 AM #11
Yes a mouseListener
To finish sooner, take your own time....
Nivedithaaaa
- 07-02-2008, 10:20 AM #12
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-02-2008, 10:37 AM #13
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
- 07-02-2008, 11:07 AM #14
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-03-2008, 03:24 AM #15
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Then how did you add all other button events and so on?
- 07-03-2008, 06:06 AM #16
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-03-2008, 06:18 AM #17
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You have to do something like this.
Java Code:jLabel1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { } });
- 07-03-2008, 06:34 AM #18
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-03-2008, 06:36 AM #19
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
- 07-03-2008, 06:38 AM #20
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
Similar Threads
-
have to make the bookisbn column values as hyperlink to a page name bookinfo.jsp whi
By koushika in forum New To JavaReplies: 0Last Post: 04-01-2008, 04:14 PM -
Hide hyperlink address on status bar
By simon in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 07-24-2007, 10:34 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks