Professional Documents
Culture Documents
Javalesson47 Jframe String Javalesson47: "Serial"
Javalesson47 Jframe String Javalesson47: "Serial"
new JavaLesson47();
public JavaLesson47() {
// create frame
this.setSize(500, 500);
this.setTitle("Drawing Shapes");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.add(new DrawStuff(), BorderLayout.CENTER);
this.setVisible(true);
graph2.draw(drawLine);
graph2.draw(drawArc2D);
graph2.draw(drawArc2D2);
graph2.draw(drawArc2D3);
// draw rounded rectangle upper left hand corner x and y, bottom right
hand corner x and y, arc height and width
Shape drawRoundRec = new RoundRectangle2D.Double(25,25,50,50,45,45);
graph2.draw(drawEllipse);
// set color to green
graph2.setColor(Color.GREEN);
// draw with fill instead of empty lines
graph2.fill(drawRect);
// change stroke color
graph2.setPaint(Color.BLACK); // this works but use
//graph2.setStroke(); to change stroke settings
graph2.draw(drawRect);
graph2.draw(drawRoundRec);
graph2.draw(cubicCurve);
graph2.draw(drawQuadCurve);
graph2.draw(drawTransRect);
// draw gradients
// starting point, starting color,
angle-0 for vertical,
// how many pixels the blue goes to before it
changes color, the color it changes to (hex)
GradientPaint theGradient = new GradientPaint(0,0, Color.BLUE, 0, 60,new
Color(0x66ffff)); // add ,true to end to make color in middle
graph2.setPaint(theGradient);
}
}