Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. package AppletDraw;
  2.  
  3. import java.awt.Graphics;
  4.  
  5. import javax.swing.ButtonGroup;
  6. import javax.swing.JApplet;
  7. import javax.swing.JRadioButton;
  8.  
  9. public class AppletDraw extends JApplet {
  10.    
  11.     private JRadioButton rect, roundRect, circle;
  12.     private ButtonGroup btnG;
  13.    
  14.     public void init() {
  15.        
  16.         rect = new JRadioButton("Rectangle");
  17.         roundRect = new JRadioButton("RoundRectangle");
  18.         circle = new JRadioButton("Circle");
  19.         btnG = new ButtonGroup();
  20.         btnG.add(rect);
  21.         btnG.add(roundRect);
  22.         btnG.add(circle);
  23.        
  24.     }
  25.    
  26.     public void paint(Graphics g) {
  27.        
  28.         super.paint(g);
  29.        
  30.         if (rect.isSelected() == true) {
  31.             g.drawRect(10, 10, 50, 50);
  32.         }
  33.         if (roundRect.isSelected() == true) {
  34.             g.drawRoundRect(10, 10, 50, 50,10,10);
  35.         }
  36.         if (circle.isSelected() == true) {
  37.             g.drawOval(10, 10, 50, 50);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement