including pictures
Author |
Message |
underdog
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
turboliux
![](http://img.photobucket.com/albums/v637/turboliux/hl2_avatar.gif)
|
Posted: 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();
}
} |
|
|
|
|
|
![](images/spacer.gif) |
turboliux
![](http://img.photobucket.com/albums/v637/turboliux/hl2_avatar.gif)
|
Posted: 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); |
|
|
|
|
|
![](images/spacer.gif) |
|
|