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

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: 41

.

+ 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

Profile IconMuhammad Affan Muneer and Siddiq khan kakar joined + M.Tariq Malik's group
3 minutes ago
Mumtaz Hussain liked + M.Tariq Malik's discussion CS101 Assignment No 01 Fall 2019 Solution & Discussion
7 minutes ago
+ ! ! ! ! ᎠixieᎠuຮt꧂ liked Usman Mughal's discussion Fall 2019 Assignment No. 1 English Comprehension (Eng101)
8 minutes ago
muddasir and Adil Iqbal are now friends
10 minutes ago
Mohsin pervaiz liked Usman Mughal's discussion Fall 2019 Assignment No. 1 English Comprehension (Eng101)
12 minutes ago
Profile IconNaeem jani and abdul ghafoor joined + M.Tariq Malik's group
18 minutes ago
Profile IconNabeel Ahmed, M IDREES and Abdul Ghaffar joined + M.Tariq Malik's group
36 minutes ago
BILAL Maher replied to + M.Tariq Malik's discussion CS401 Assignment No 01 Fall 2019 Solution & Discussion in the group CS401 Computer Architecture and Assembly Language Programming
54 minutes ago
+¢αяєℓєѕѕ gιяℓ replied to Moji's discussion Assignment #1 Semester FALL 2019 Physics (PHY101)
1 hour ago
Asmat replied to + "J ɨ y ą ⋆'s discussion CS501 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 12-11-2019 in the group CS501 Advance Computer Architecture
2 hours ago
+!!! NOOR UL JANAT !!!+ replied to Rana Ali's discussion Alfaz
2 hours ago
Rana Ali replied to Rana Ali's discussion Alfaz
3 hours ago
Rana Ali liked Rana Ali's discussion Alfaz
3 hours ago
Rana Ali liked Rana Ali's discussion Psy511 assignment no 1
3 hours ago
Rana Ali added a discussion to the group PSY511 Environmental Psychology
3 hours ago
Rana Ali liked + M.Tariq Malik's group PSY511 Environmental Psychology
3 hours ago
Rana Ali joined + M.Tariq Malik's group
3 hours ago
Rana Ali liked + M.Tariq Malik's discussion EDU302 Human Development and Learning Assignment No 01 Fall 2019 Solution & Discussion
3 hours ago
MUHAMMAD USMAN replied to MIT's discussion Operating Systems(CS604) Assignment # 01 Deadline Date 16-11-2019 in the group CS604 Operating Systems
3 hours ago
Muhammad Awais replied to Usman Mughal's discussion Assignment No. 01 Semester: Fall 2019 in the group CS101 Introduction to Computing
4 hours ago

Today Top Members 

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

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