Page 1 of 2 12 LastLast
Results 1 to 20 of 28

Thread: Dialog

  1. #1
    JavaLerner is offline Member
    Join Date
    Jul 2008
    Posts
    18
    Rep Power
    0

    Default Dialog

    Hi All

    I am student of MCA.I want to know how can i develop a About Dialog.About Dialog means..A dialog have a one picture and multiple label.As we see all software have a help menu and help menu have a About Dialog.As like that i want to develop.Can any one give me example link or some code...

    Plz help me..

  2. #2
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    You want to create your own style of dialog boxes?

    You can try creating your own Dialog function with a JFrame and just call it. You can have as may pictures you like and many labels.

    I hope i shared some ligth into your question
    Mind only knows what lies near the heart, it alone sees the depth of the soul.

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

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

  5. #5
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by Eku View Post
    You can try creating your own Dialog function with a JFrame and just call it. You can have as may pictures you like and many labels.
    What? No reason. JDialog can be used exactly as if it were a JFrame (minus the min/max and maybe some other window functions). There is no reason to use JFrame and attempt to control modality and everything else inherit in a Dialog yourself. Dialogs are not just JOptionPane.

  6. #6
    JavaLerner is offline Member
    Join Date
    Jul 2008
    Posts
    18
    Rep Power
    0

    Default

    Sir i have a code which have picture and one label show on dialog.But i want to do show more than one label on dialog.I found some code from this forum.It ia very hekp full for me...
    Plz help me

  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

    Default

    I think Eku is talking about calling a JFrame within a JOptionPane. Because I agreed with masijade too, with the following.

    Dialogs are not just JOptionPane.

  8. #8
    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

    Quote Originally Posted by JavaLerner View Post
    Sir i have a code which have picture and one label show on dialog.But i want to do show more than one label on dialog.I found some code from this forum.It ia very hekp full for me...
    Plz help me
    Are you talking about JDialog or JOptionPane? Can you clarify it little more.

  9. #9
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by JavaLerner View Post
    Sir i have a code which have picture and one label show on dialog.But i want to do show more than one label on dialog.I found some code from this forum.It ia very hekp full for me...
    Plz help me
    Did you go to that tutorial?

    I posted that one because it deals with JDialog, not JOptionPane. Sun's tutorials, are now, unfortunately, solely concerned with JOptionPane, and just give references to JDialog, but don't actually demonstrate anything with it.

  10. #10
    JavaLerner is offline Member
    Join Date
    Jul 2008
    Posts
    18
    Rep Power
    0

    Default

    Quote Originally Posted by masijade View Post
    Did you go to that tutorial?

    I posted that one because it deals with JDialog, not JOptionPane. Sun's tutorials, are now, unfortunately, solely concerned with JOptionPane, and just give references to JDialog, but don't actually demonstrate anything with it.
    yes sir i got it but there is nothing for Background Picture..

  11. #11
    JavaLerner is offline Member
    Join Date
    Jul 2008
    Posts
    18
    Rep Power
    0

    Default

    Quote Originally Posted by masijade View Post
    Did you go to that tutorial?

    I posted that one because it deals with JDialog, not JOptionPane. Sun's tutorials, are now, unfortunately, solely concerned with JOptionPane, and just give references to JDialog, but don't actually demonstrate anything with it.
    Sir i got some code from this forum.Code is here

    Java Code:
    import java.awt.* ;
    import java.awt.Image;
     
    import javax.swing.* ;
     
    public class JFrameBg extends JDialog{
    	
    	public JFrameBg() {
    		super() ;
    		setTitle( "Background Image on JFrame or JDialog or JApplet" ) ;
    		setDefaultCloseOperation( EXIT_ON_CLOSE ) ;
    		setContentPane( new MyPanel() ) ;
    		getContentPane().add( new JLabel( "It is a Label" , new ImageIcon( "D:/Personal/Shilu/teddy,bmp" ) , 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() ;
    	}
    It is working fine but i need to add more label on this Dialog.

  12. #12
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by JavaLerner View Post
    yes sir i got it but there is nothing for Background Picture..
    So? I thought your question was simply on how to use a JDialog, not how to use a background picture.

    And, judgiung by your next post, you're not even asking about that, but rather, how to add more labels.

    So what, exactly, is it you're having problems with?

  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

  14. #14
    JavaLerner is offline Member
    Join Date
    Jul 2008
    Posts
    18
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Think about some layout and add components there first.
    which layout i use for this..i am useing
    Java Code:
    setLayout( new BorderLayout() )
    for picture...

  15. #15
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Go through this entire tutorial, thoroughly, as you seem to have no idea how to use Swing.

    Trail: Graphical User Interfaces (The Java™ Tutorials)

  16. #16
    JavaLerner is offline Member
    Join Date
    Jul 2008
    Posts
    18
    Rep Power
    0

    Default

    Quote Originally Posted by masijade View Post
    So? I thought your question was simply on how to use a JDialog, not how to use a background picture.

    And, judgiung by your next post, you're not even asking about that, but rather, how to add more labels.

    So what, exactly, is it you're having problems with?
    Sir i want to set background picture and multipe label on dialog. And same thing i written in first post...

  17. #17
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by JavaLerner View Post
    Sir i want to set background picture and multipe label on dialog. And same thing i written in first post...
    Except that you already have parts of it, and according to your last post, need only to know how to add labels to that, which is entirely different than "the first post" as that post is essentially asking "How do I use JDialog?", and you're last post is, "How do I add additional JLabels to a JPanel?".

    Completely different things. Anyway, go through the Swing tutorials.

  18. #18
    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

    Quote Originally Posted by masijade View Post
    Go through this entire tutorial, thoroughly, as you seem to have no idea how to use Swing.

    Trail: Graphical User Interfaces (The Java™ Tutorials)
    Yes, it's better to go through this link and have an idea.

    At the minute, JavaLerner, there are different layouts you can use. Each has strength and weaknesses, depends on the situation you can use the best one. Better to read about them too.

  19. #19
    JavaLerner is offline Member
    Join Date
    Jul 2008
    Posts
    18
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Yes, it's better to go through this link and have an idea.

    At the minute, JavaLerner, there are different layouts you can use. Each has strength and weaknesses, depends on the situation you can use the best one. Better to read about them too.
    I need some code example to understand...So plz if it is possibel then give me

  20. #20
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by JavaLerner View Post
    I need some code example to understand...So plz if it is possibel then give me
    You, seemingly, do not understand the code you already have, so how is giving you more going to help?

    Go through the tutorials and learn alittle bit about how to use Layouts, Windows, and Components in general, then try to make this change.

Page 1 of 2 12 LastLast

Similar Threads

  1. Printing (no dialog)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-04-2008, 09:36 AM
  2. Example of SWT Dialog
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-09-2008, 12:01 PM
  3. Yes/No confirm dialog box
    By mandrake446 in forum Advanced Java
    Replies: 2
    Last Post: 12-09-2007, 05:31 AM
  4. Dialog Box
    By uncopywritable in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 12:42 PM

Posting Permissions

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