What is the easiest way to import an image to display in Java. I want
to show an image with +- zoom. I have the frame set and the buttons
in place but can not import the image.
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
public class Zoom extends JPanel
{
public static void main(String []args)
{
Zoom zoom = new Zoom();
JFrame frame = new JFrame("ShowZoom");
frame.setTitle("Show zoomed image in frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 400);
frame.getContentPane().add(zoom,
BorderLayout.CENTER);
frame.setVisible(true);
}
public Zoom()
{
this.setBackground(Color.white);
//this.setFont(new Font("Dialog", Font. Bold, 24));
JPanel p1 = new JPanel();
p1.setBackground(new Color(200, 200, 200));
this.add(p1);
p1.add(new JButton("+"));
JPanel p2 = new JPanel();
p2.setBackground(new Color(200, 200, 200));
p1.add(p2);
p2.add(new JButton("-"));
}
}