Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 including pictures
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
underdog




PostPosted: Thu Jan 19, 2006 10:58 am   Post subject: including pictures

is there a short code to include pictures in your program?

if not, could sum1 send me a method to do it anyway?

thx
Sponsor
Sponsor
Sponsor
sponsor
turboliux




PostPosted: Thu Jan 19, 2006 12:16 pm   Post subject: (No subject)

code:
import java.awt.*;
import javax.swing.*;

class image {
       
        public static void main (String args[]) {
                JFrame myFrame = new JFrame ("Image");
                JPanel myPanel = new JPanel ();
                ImageIcon icon = new ImageIcon("image.jpg");
                JLabel myLabel = new JLabel ("some text", icon, JLabel.RIGHT);
               
                myFrame.setDefaultCloseOperation(myFrame.EXIT_ON_CLOSE );
                myFrame.getContentPane().add(myPanel, BorderLayout.CENTER);
               
                myPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
                myPanel.add(myLabel);
               
                myFrame.pack();
                myFrame.show();
        }
}
turboliux




PostPosted: Thu Jan 19, 2006 12:22 pm   Post subject: (No subject)

if you have already your own program, then include this into your constructor, or main method:
code:
ImageIcon icon = new ImageIcon("image.jpg");
JLabel myLabel = new JLabel ("some text", icon, JLabel.RIGHT);
myPanel.add(myLabel);
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: