my code works fine with .GIF but not with .JPEG!!??
jdk.6.0_02
jre1.6.0_05
jdk.6.0_02
jre1.6.0_05
ort java.awt.BorderLayout; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JFrame; public class LabelDemo { public static void main( String args[] ) { // Create a label with plain text JLabel northLabel = new JLabel( "North" ); // create an icon from an image so we can put it on a JLabel ImageIcon labelIcon = new ImageIcon( "C:\\Users\\george bush\\Desktop\\ring_sat.GIF" ); // create a label with an Icon instead of text JLabel centerLabel = new JLabel( labelIcon ); // create another label with an Icon JLabel southLabel = new JLabel( labelIcon ); // set the label to display text (as well as an icon) southLabel.setText( "South" ); // create a frame to hold the labels JFrame application = new JFrame(); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); // add the labels to the frame; the second argument specifies // where on the frame to add the label application.add( northLabel, BorderLayout.NORTH ); application.add( centerLabel, BorderLayout.CENTER ); application.add( southLabel, BorderLayout.SOUTH ); application.setSize( 300, 300); // set the size of the frame application.setVisible( true ); // show the frame } // end main } // end class LabelDemo
Comment