|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

07-02-2008, 08:26 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
|
[SOLVED] Hyperlink
Hi All
I havn't idea about hyperlink.How can i set hyperlink on label.
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
|
|

07-02-2008, 08:55 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-02-2008, 09:03 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Eranga
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
|
|

07-02-2008, 09:18 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Eranga
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
|
|

07-02-2008, 09:21 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
On which way you are going to do it?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-02-2008, 09:25 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Eranga
On which way you are going to do it?
here is code..
Plz help me
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, 09:54 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
You are going to use in use of label. First try to implement the click event on the label.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-02-2008, 10:23 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Eranga
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
|
|

07-02-2008, 10:32 AM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
|
Yes a mouseListener
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

07-02-2008, 10:36 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
It's much simple. Simply implements all methods in mouse listener. You have a mouse click event.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-02-2008, 10:39 AM
|
 |
Senior Member
|
|
Join Date: May 2008
Posts: 299
|
|
|
Yes a mouseListener
__________________
To finish sooner, take your own time....
Nivedithaaaa
|
|

07-02-2008, 12:20 PM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Eranga
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
|
|

07-02-2008, 12:37 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-02-2008, 01:07 PM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Eranga
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
|
|

07-03-2008, 05:24 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
Then how did you add all other button events and so on?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-03-2008, 08:06 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Eranga
Then how did you add all other button events and so on?
hello Sir
I need only this..So plz help me
|
|

07-03-2008, 08:18 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
You have to do something like this.
jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
}
});
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-03-2008, 08:34 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Eranga
You have to do something like this.
jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
}
});
Sir i add it..What's a next step
|
|

07-03-2008, 08:36 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
|
|
|
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-03-2008, 08:38 AM
|
|
Senior Member
|
|
Join Date: Mar 2008
Posts: 447
|
|
Originally Posted by Eranga
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..
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posti | | | |