We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

Hope It will help the one who deserves guidance.

FigureWindow Java source code is still under dev stage, it will draw few sqaures, and fill Ovals , circles. Just enjoy
Code:
import java.awt.*;
import java.awt.Color;
/**
* A simple window to display graphic figures in. The window is a subclass
* of the Java ’Frame’ class, which describes graphic windows. The window
* keeps its figures in an array.
*
* The Java window system (AWT) automatically calls the paint method in
* the Frame class whenever the window’s contents need to be redrawn. A
* new implementation of paint is provided in FigureWindow to handle the
* drawing.
*/
class FigureWindow extends Frame {
/**
    *
    */ 
   private static final long serialVersionUID = -8500445690251228566L;
/**
* Constructor: the parameter indicates the maximal number of figures.
*/
public FigureWindow(int max) {
super("Fabulous Figures");  // Window title
figures = new Figure[max];
nbrOfFigures = 0;
}
/**
* Add the figure f to the window. If the maximal number of figures has
* been reached, nothing happens.
*/
public void addFigure(Figure f) {
if (nbrOfFigures < figures.length) {
figures[nbrOfFigures] = f;
nbrOfFigures++;
}
}

/**
* This method is called automatically by the system. Draws the
* raphic figures associated with the window.
*
* The g parameter is a drawing ’pen’ provided by the system.
*/
public void paint(Graphics g) {
int i;
for(i = 0; i < nbrOfFigures; i++) {
figures[i].draw(g);
}
}
// Array of graphic figures
private Figure[] figures;
// Current number of figures
private int nbrOfFigures;
/**
* Main method: creates a FigureWindow and a few figures inside it.
*/
public static void main(String[] args) {
FigureWindow w = new FigureWindow(10);
w.setSize(400, 300);
w.addFigure(new Square(50, 50, 200));
w.addFigure(new Circle(200, 100, 150));
w.addFigure(new Circle(300, 200, 200));
w.show();
}
}
/**
* Simple abstract class for graphic figures that can be drawn in windows.
*/
abstract class Figure {
/**
* Constructor: takes two parameters, the X and Y coordinates.
*/
public Figure(int inX, int inY) {
x = inX;
y = inY;
}
/**
* Abstract method for drawing this thing.
*
* The g parameter is a ’pen’ that can be used to draw things
* in the window.
*/
public abstract void draw(Graphics g);
/**
* Move the figure to (newX, newY).
*/
public void move(int newX, int newY) {
x = newX;
y = newY;
}
protected int x, y; // X and Y coordinates
}
/**
* A square that can be drawn in a window. The coordinates represent the
* upper left corner of the square.
*/
class Square extends Figure {
/**
* Constructor: first two parameters are the coordinates, the third is
* the side.
*/
public Square(int inX, int inY, int inSide) {
super(inX, inY);
side = inSide;
}
/**
* Drawing method for squares.
*/
public void draw(Graphics g) {
g.drawRect(x, y, side, side);
g.setColor(Color.red);
g.fillRect(10,20,20,30);
g.setColor(Color.blue);
g.fillRect(x+200, y+40, side-30, side+20);
}
private int side; // Square side
}
/**
* Circle class. The coordinates represent the circle’s center.
*/
class Circle extends Figure {
/**
* Constructor: the first two parameters are the coordinates,
* the third is the diameter.
*/
public Circle(int inX, int inY, int inDiam) {
super(inX, inY);
d = inDiam;

}
/**
* Drawing method for circles.
*/
public void draw(Graphics g) {
g.setColor(Color.green);
g.drawOval(x, y, d, d);
g.setColor(Color.red);
g.fillOval(x, y, d, d);
g.setColor(Color.yellow);
g.fillOval(x+150, y-40, d*2, d*3);
}
private int d; // Circle diameter
}




[color=#BF4080][b]Btn5 is my so far effort for solution , so  someone can improve it.[/b][/color]
import java.awt.*;
import javax.swing.*;
import java.lang.String;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JComponent;
import java.awt.Toolkit;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Btn5 extends JPanel implements ActionListener {
// public class Btn5 {
JFrame myFrame, myFrame1  ;
JTextField tf, tf1, tf2,tf3;
JTextArea displayArea;
JButton btn1, btn2,btn3,btn4;
JLabel jL1 , jL2;
//method used for setting layout of GUI
public void initGUI ( ) {
   myFrame = new JFrame();
   Container c = myFrame.getContentPane();
   c.setLayout( new FlowLayout( ) );
   JTextField tf = new JTextField(10);
   JLabel  jL1 = new JLabel ("My Name is : Student ");
   JLabel  jL2 = new JLabel ("My VU ID is :    Find Out           ");
   JButton b1 = new JButton("OK");
   c.add(jL1);
   c.add(jL2);
   c.add(b1);
   // c.add(tf);
   b1.addActionListener(this);
   myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   myFrame.setSize(250,175);
   myFrame.setVisible(true);

}
public boolean action(Event evt, Object arg)
    {
        if (evt.target instanceof Button)
        {
           System.out.println("Why Why  ");
                   //    HandleButtons((String)arg);
               
    }return true;
    }
   


public void actionPerformed(ActionEvent e) {         ccc ();            }



protected void ccc ()       {        System.out.println("hello "); }
public Btn5 () {     initGUI ();    }
public static void main (String args[ ]) { Btn5 MyFirstGUI = new Btn5(); }


}



/*
public boolean action(Event evt, Object arg)
    {
        if (evt.target instanceof Checkbox)
            ChangeLabel(evt);
      if (evt.target instanceof Button)
            HandleButtons((String)arg);
             
      if (evt.target instanceof Choice)
            ccc ();
            repaint ();
                return true;
    }
*/

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 47

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Latest Activity

HAROON "DOLPHIN SQUAD" updated their profile
43 minutes ago
Moureen Max left a comment for Saddi
4 hours ago
Moureen Max left a comment for Muhammad Hassan Akbar
4 hours ago
Moureen Max left a comment for Muhammad Moin khan
4 hours ago
Moureen Max left a comment for Junaid
4 hours ago
Moureen Max left a comment for hafsa irum
4 hours ago
Moureen Max left a comment for ramla shireen
4 hours ago
Moureen Max left a comment for Raheela kanwal
4 hours ago
Moureen Max left a comment for AAMIR SHAHZAD BUTT
4 hours ago
Moureen Max left a comment for Iqbal
4 hours ago
Moureen Max left a comment for Bilal Raza
4 hours ago
Moureen Max left a comment for A-butt
4 hours ago

Today Top Members 

© 2020   Created by +M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.