
-----------------------------------
underdog
Thu Jan 19, 2006 10:58 am

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

-----------------------------------
turboliux
Thu Jan 19, 2006 12:16 pm


-----------------------------------
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
Thu Jan 19, 2006 12:22 pm


-----------------------------------
if you have already your own program, then include this into your constructor, or main method:
ImageIcon icon = new ImageIcon("image.jpg");
JLabel myLabel = new JLabel ("some text", icon, JLabel.RIGHT);
myPanel.add(myLabel);
