Thread: Dialog
View Single Post
  #11 (permalink)  
Old 07-07-2008, 10:51 AM
JavaLerner JavaLerner is offline
Member
 
Join Date: Jul 2008
Posts: 18
JavaLerner is on a distinguished road
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

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.
Reply With Quote