Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package AppletDraw;
- import java.awt.Graphics;
- import javax.swing.ButtonGroup;
- import javax.swing.JApplet;
- import javax.swing.JRadioButton;
- public class AppletDraw extends JApplet {
- private JRadioButton rect, roundRect, circle;
- private ButtonGroup btnG;
- public void init() {
- rect = new JRadioButton("Rectangle");
- roundRect = new JRadioButton("RoundRectangle");
- circle = new JRadioButton("Circle");
- btnG = new ButtonGroup();
- btnG.add(rect);
- btnG.add(roundRect);
- btnG.add(circle);
- }
- public void paint(Graphics g) {
- super.paint(g);
- if (rect.isSelected() == true) {
- g.drawRect(10, 10, 50, 50);
- }
- if (roundRect.isSelected() == true) {
- g.drawRoundRect(10, 10, 50, 50,10,10);
- }
- if (circle.isSelected() == true) {
- g.drawOval(10, 10, 50, 50);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement