Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.geom.Ellipse2D;
- import java.util.Vector;
- import javax.swing.*;
- /**
- *
- * @author stefan Klaus
- *
- */
- public class rectangles extends JPanel{
- public double x;
- public double y;
- private NewClass newClass;
- private JLabel name, test1, fields, test2, methods;
- private String text;
- public Vector<rectangles> rects;
- //public int i = rects.size();
- public rectangles(){
- this.x = x;
- this.y = y;
- this.setLayout(new GridLayout(10,1,1,1));
- setBackground(Color.WHITE);
- setSize(250,300);
- setBounds(10,10, 200, 300);
- name = new JLabel("newClass");
- test1 = new JLabel();
- fields = new JLabel();
- test2 = new JLabel();
- methods = new JLabel();
- add(name);
- add(test1);
- add(fields);
- add(test2);
- add(methods);
- }
- public void setName(String text){
- name.setText(text);
- test1.setText("-------------------------");
- //fields.setText(text);
- //methods.setText(text);
- repaint();
- }
- public void setFields(String text){
- fields.setText(text);
- test2.setText("-------------------------");
- repaint();
- }
- public void setMethods(String text){
- methods.setText(text);
- repaint();
- }
- public void paintComponent(Graphics g){
- super.paintComponents(g);
- g.setColor(Color.PINK);
- g.fillRect((int)x, (int)y, 170, 300);
- }
- public void drawing(){
- repaint();
- }
- public void update(int x, int y){
- this.x = x;
- this.y = y;
- }
- public double distanceTo(double x, double y) {
- return (Math.abs(this.x-x) + Math.abs(this.y-y));
- }
- /*public int getI(){
- return i;
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment