Results 41 to 60 of 92
Thread: [SOLVED] Hyperlink
- 07-04-2008, 06:44 AM #41
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
ok Tim
I got your point.But problem is that i am not expert in java.First i have face a loat problem to set picture and label on dialog.Then "Niveditha" help me to solve that problem.Now if i change that code and worki in new style then i have again more problem.So i want to know how i can add backgroung picture on HyperLabel. Or Can i do work of hyperlink on same code. "Niveditha" code is here
I am doing work on About form. And i promiss to all of you i learn java after monday,becouse my project is just over next day.So plz help meJava Code:import javax.swing.*; import java.awt.*; import java.awt.event.*; public class ProgressSample2 { public static void main(String args[]) { final JProgressBar aJProgressBar = new JProgressBar(0, 100); aJProgressBar.setIndeterminate(true); JButton aJButton = new JButton("Toggle"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { boolean indeterminate = aJProgressBar.isIndeterminate(); aJProgressBar.setIndeterminate(!indeterminate); } }; aJButton.addActionListener(actionListener); JFrame theFrame = new JFrame("Indeterminate"); theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = theFrame.getContentPane(); contentPane.add(aJProgressBar, BorderLayout.NORTH); contentPane.add(aJButton, BorderLayout.SOUTH); theFrame.setSize(300, 100); theFrame.show(); } }
- 07-04-2008, 06:46 AM #42
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-04-2008, 07:21 AM #43
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes, it's better. Try something. And also before use any code you get try to identify what exactly it's done, and also how it's related to your question and last how to integrate in to your code without any issue at all.
- 07-04-2008, 07:26 AM #44
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-04-2008, 07:29 AM #45
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Basically what you have to do is, change the component to label that referring on click. Can't you find that?
- 07-04-2008, 07:32 AM #46
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-04-2008, 07:48 AM #47
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Put your code here in the forum. So all others can see it too.
- 07-04-2008, 08:01 AM #48
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-04-2008, 08:14 AM #49
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You are asking same thing again and again. That is because you working on the dialog, not on the label you want.
- 07-04-2008, 08:30 AM #50
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
Ok Sir Here is Code plz see it and give me advice to work on right way..
Java Code:public class AboutDlg extends JDialog implements MouseListener { private String URL = "http://www.yahoo.com"; public String getURL() { return URL; } public void setURL(String URL) { this.URL = URL; this.setCursor(new Cursor(Cursor.HAND_CURSOR)); this.setForeground(Color.BLUE); } public AboutDlg(Frame parent) { super(); JLabel Dru = new JLabel( " Email : info@yahoo.com" , JLabel.LEFT); JLabel Drw = new JLabel( " http://www.yahoo.com" , JLabel.LEFT); this.setURL(URL); Drw.addMouseListener(this); Drw.setCursor(new Cursor(Cursor.HAND_CURSOR)); Drw.setForeground(Color.BLUE); Dru.addMouseListener(this); Drw.setCursor(new Cursor(Cursor.HAND_CURSOR)); Dru.setForeground(Color.BLUE); Drpu.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); Font f3= new Font("Terminal", Font.PLAIN, 12); Drpu.setFont(f3); Ver.setFont(f3); Cop.setFont(f3); Drs.setFont(f3); Dru.setFont(f3); Drw.setFont(f3); setTitle( "About " ) ; setContentPane( new MyPanel() ) ; getContentPane().setLayout(new FlowLayout()); getContentPane().add(Dru ); getContentPane().add(Drw ); getContentPane().add( new Button(" OK ")); setSize( 300 ,225 ) ; setVisible( true ) ; setResizable(false); // Point fatherLocation = parent.location(); // move(fatherLocation.x + 150,fatherLocation.y + 200); // show(); } public void mouseClicked(MouseEvent e){ try{ String command = "start " + this.URL; Process process = Runtime.getRuntime().exec("cmd /c \"" + command + "\""); } catch (Exception exception){ System.out.println("Exception caught : " + exception.getMessage()); } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void paint(Graphics graphis){ super.paint(graphis); graphis.setColor(this.getForeground()); graphis.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1); } public class MyPanel extends JPanel { private Image img ; public MyPanel() { setLayout( new BorderLayout() ) ; img = new ImageIcon("log.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 ,0,9 , this ) ; } } } protected void paintComponent(Graphics g) { super.paintComponent(g); drawBackground( g ) ; } } public boolean action (Event evt, Object arg) { if (evt.target instanceof Button) { hide(); dispose(); return true; } return false; } private boolean updateDB() { hide(); dispose(); return true; } public boolean handleEvent (Event event) { switch (event.id) { case Event.WINDOW_DESTROY: dispose(); return true; default: return super.handleEvent(event); } } }
- 07-04-2008, 09:13 AM #51
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-04-2008, 09:43 AM #52
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-04-2008, 09:44 AM #53
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
Sir it is working but some thing error in Event...When i click mouse on url Label then web page is open and also open a outlook. And same thing is happen in Outlook Label.So plz tell how can i open one by one click event.
Plz help me
Java Code:public void mouseClicked(MouseEvent e){ try{ String command = "start " + this.URL; Process process = Runtime.getRuntime().exec("cmd /c \"" + command + "\""); //Following line works as it should. Runtime.getRuntime().exec("cmd.exe /c start mailto:abc@yahoo.com"); } catch (Exception exception){ System.out.println("Exception caught : " + exception.getMessage()); } }
- 07-04-2008, 10:26 AM #54
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Comment the following line and see.
Java Code:Runtime.getRuntime().exec("cmd.exe /c start mailto:abc@yahoo.com");
- 07-04-2008, 11:05 AM #55
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-04-2008, 11:58 AM #56
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-07-2008, 04:25 AM #57
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You mean that you don't know how to comment this line? Amazing pal. Stop working with Java, actually working with any language in programming.
- 07-07-2008, 06:09 AM #58
Senior Member
- Join Date
- Mar 2008
- Posts
- 447
- Rep Power
- 6
- 07-07-2008, 06:21 AM #59
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You sending what? and where to? I didn't get anything from you at all.
- 07-07-2008, 06:31 AM #60
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