Map_Linepublic class Map_Line extends Applet
Fields Summary |
---|
private BufferedImage | bi |
Constructors Summary |
---|
public Map_Line()
setBackground(Color.white);
Image img = getToolkit().getImage("images/bld.jpg");
try {
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(img, 0);
tracker.waitForID(0);
} catch (Exception e) {}
int iw = img.getWidth(this);
int ih = img.getHeight(this);
bi = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
Graphics2D big = bi.createGraphics();
big.drawImage(img,0,0,this);
|
Methods Summary |
---|
public static void | main(java.lang.String[] s)
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
};
Frame f = new Frame("Map_Line");
f.addWindowListener(l);
f.add("Center", new Map_Line());
f.pack();
f.setSize(new Dimension(350, 250));
f.show();
| public void | paint(java.awt.Graphics g)
Graphics2D g2 = (Graphics2D) g;
int w = getSize().width;
int h = getSize().height;
int bw = bi.getWidth(this);
int bh = bi.getHeight(this);
g2.drawImage(bi, null, 0, 0);
g2.setColor(Color.white);
g2.setStroke(new BasicStroke(5.0f));
g2.drawLine(10, 10, bw-10, bh-10);
|
|