Page 3 of 5 FirstFirst 12345 LastLast
Results 41 to 60 of 92
  1. #41
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by tim View Post
    Hello Mir.

    On the Forums, my name is Tim.

    Swearing, daGame, degrades our Forums and I do not agree with the usage of such language on Java Forums. Mir made a simple mistake as we are all human.

    In Java, if you want a GUI component to behave differently than normal, then you must derive a new component from it. It is different from other languages, say Visual Basics or Pascal, where new methods are added for new events for different components. That is why I created HyperLabel. The HyperLabel will handle any special events, a click in this example, without the knowledge of the user. This is called encapsulation, which is another reason I did this.

    Try changing the URL to
    Java Code:
    http://www.google.com
    If this doesn't work then the problem is elsewhere. However, it is strange that you got an error, because it works fine on my machine. ;)

    Good luck Mir :D

    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

    Java 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();
      }
    }
    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 me

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

    Default

    Quote Originally Posted by Eranga View Post
    Mir, you got lots of explanation on this. As Tim, Neviditha says I'm trying to help you. I have exact code you want with me. Because I have already done those kind of things thousand times in my life up to now. I can just copy-paste the code here. But that's not the point here in our community.

    Forum is a place discuss some matters/issues with friends all over the world. So you can gather wast knowledge from there. Because people have different levels of knowledge in the field. Just asking code/help like you Mir, it's not good.

    So try all suggestions you have. That code given by Tim working extremely fine. So the problem is in your side.
    Ok sir

    i am going through your idea but after Monday.Becouse my project is just over.It's my last task to do on this project..

    Thxs

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

    Default

    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.

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

    Default

    Quote Originally Posted by Eranga View Post
    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.
    Sir i am try to do that.It is working but problem is that when i click any where in the dialog it is open a web page.But i want to open a particullar label.Can i send you last time code...

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

    Default

    Basically what you have to do is, change the component to label that referring on click. Can't you find that?

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

    Default

    Quote Originally Posted by Eranga View Post
    Basically what you have to do is, change the component to label that referring on click. Can't you find that?
    yes sir, i am unabel to find that.Sir plz see my code..Can i send you sir..

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

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

    Default

    Quote Originally Posted by Eranga View Post
    Put your code here in the forum. So all others can see it too.
    Sir i set the link only this url.But HAND_CURSOR showing all over the dialog. So how can i remove this...

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

    Default

    You are asking same thing again and again. That is because you working on the dialog, not on the label you want.

  10. #50
    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 asking same thing again and again. That is because you working on the dialog, not on the label you want.
    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);
    		}
    	}
    
    
    
    
    }

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

    Default

    Quote Originally Posted by Eranga View Post
    Put your code here in the forum. So all others can see it too.
    Sir can you tell what can i do for this code plz help me

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

    Default

    Quote Originally Posted by Eranga View Post
    Basically what you have to do is, change the component to label that referring on click. Can't you find that?
    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

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

    Default

    Quote Originally Posted by Eranga View Post
    Basically what you have to do is, change the component to label that referring on click. Can't you find that?
    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());
    	        }
    	    }

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

    Default

    Comment the following line and see.

    Java Code:
    Runtime.getRuntime().exec("cmd.exe /c start mailto:abc@yahoo.com");

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

    Default

    Quote Originally Posted by Eranga View Post
    Comment the following line and see.

    Java Code:
    Runtime.getRuntime().exec("cmd.exe /c start mailto:abc@yahoo.com");
    Sir then only web page open on both label. Sir i want ot open separete link from label. Plz help me

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

    Default

    Quote Originally Posted by Eranga View Post
    Comment the following line and see.

    Java Code:
    Runtime.getRuntime().exec("cmd.exe /c start mailto:abc@yahoo.com");
    Sir plz tell me how to solve that

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

    Default

    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.

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

    Default

    Quote Originally Posted by Eranga View Post
    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.

    sir i comment these line after that i send you report.What i am geting..I know i am not good prorammer..Any way what i am geting after that comment i am sending..

    Plz help me

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

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

    Default

    Quote Originally Posted by Eranga View Post
    You sending what? and where to? I didn't get anything from you at all.
    Sir when i comment these line then

    Java Code:
    Runtime.getRuntime().exec("cmd.exe /c start mailto:abc@yahoo.com");
    then only WebPage hyperlink open...

Page 3 of 5 FirstFirst 12345 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
  •