Question

In: Computer Science

in a gui ' in java write a program that draws equal a simple fence with...

in a gui ' in java write a program that draws equal a simple fence with vertical, spaced slats backed by two boards. Behind the fence show a simple house support Make sure the in the und. house is visible between the slats in the fence.

Solutions

Expert Solution

import java.awt.*;

import java.applet.*;

public class Designandimplementation

{

public void paint (Graphics g)

{

house (g);

roof1 (g);

windows (g);

framing (g);

}

public void house (Graphics g)

{

g.setColor (Color.black);

g.fillRect (100,250,400,200);

g.setColor(Color.blue);

g.fillRect (245,380,110,70);

g.setColor (new Color(186,134,11));

g.fillOval (282,412,10,10);

g.fillOval (307,412,10,10);

}

public void roof1 (Graphics g)

{

g.setColor(Color.red);

int x[] = {98,300,501};

int y[] = {250,130,250};

g.fillPolygon(x,y,3);

}

public void windows (Graphics g)

{

g.setColor (Color.red);

g.fillRect (121,261,78,78);

g.fillRect (121,361,78,78);

g.fillRect (401,261,78,78);

g.fillRect (401,361,78,78);

g.setColor (Color.orange);

g.fillRect (125,265,70,70);

g.fillRect (125,365,70,70);

g.fillRect (405,265,70,70);

g.fillRect (405,365,70,70);

}

public void framing (Graphics g)

{

g.setColor (Color.red);

g.fillRect (298,380,2,70);

g.setColor (Color.red);

g.fillRect (157,265,5,70);

g.fillRect (157,365,5,70);

g.fillRect (437,265,5,70);

g.fillRect (438,365,5,70);

g.fillRect (125,298,70,5);

g.fillRect (125,398,70,5);

g.fillRect (405,298,70,5);

g.fillRect (405,398,70,5);

g.fillRect (245,375,110,5);

}

}


Related Solutions

In java processing 3, write a program that draws a circle. The center of the circle...
In java processing 3, write a program that draws a circle. The center of the circle would be first point on the canvas where the mouse is pressed on it. While the mouse is pressed, the circle can be drawn by moving the mouse cursor farther than the first point that mouse was pressed (circle center). As soon as the code is run, a timer at the bottom of the canvas should start working. Also, the radius of the circle...
Develop a simple GUI-based Java program that may be used to control a lighting system
Develop a simple GUI-based Java program that may be used to control a lighting system
Using a (GUI interface), write a Java program that simulates an ATM machine with the following...
Using a (GUI interface), write a Java program that simulates an ATM machine with the following options menu: "Welcome" 1. Deposit to account 2. Withdraw 3. Exit
Use Java GUI to write a chessboard 8 Queens Problem Write a program that can place...
Use Java GUI to write a chessboard 8 Queens Problem Write a program that can place 8 queens in such a manner on an 8 x 8 chessboard that no queens attack each other by being in the same row, column or diagonal.
I want to write this program in java. Write a simple airline ticket reservation program in...
I want to write this program in java. Write a simple airline ticket reservation program in java.The program should display a menu with the following options: reserve a ticket, cancel a reservation, check whether a ticket is reserved for a particular person, and display the passengers. The information is maintained on an alphabetized linked list of names. In a simpler version of the program, assume that tickets are reserved for only one flight. In a fuller version, place no limit...
Write a program in Java Design and implement simple matrix manipulation techniques program in java. Project...
Write a program in Java Design and implement simple matrix manipulation techniques program in java. Project Details: Your program should use 2D arrays to implement simple matrix operations. Your program should do the following: • Read the number of rows and columns of a matrix M1 from the user. Use an input validation loop to make sure the values are greater than 0. • Read the elements of M1 in row major order • Print M1 to the console; make...
(Java program) Write an applet that draws two animated cars that must race each other. The...
(Java program) Write an applet that draws two animated cars that must race each other. The race cars should move along a straight line, with each starting behind a Start Line. The user should have the option to set the speed of each car. The speed range is 0 to 100. There should be a Start button to begin the race and an End button to stop the race at any time.
Give an example of a program in java that creates a GUI with at least one...
Give an example of a program in java that creates a GUI with at least one button and several textfields. Some of the textfields should be for input and others for output. Make the output textfields uneditable. When the button is clicked, the input fields should be read, some calculation performed and the result displayed in the output textfield(s).
Design and implement a Java program that creates a GUI that will allow a customer to...
Design and implement a Java program that creates a GUI that will allow a customer to order pizza and other items from a Pizza Paarlor. The customer should be able to order a variety of items which are listed below. The GUI should allow the customer (viaJavaFX UI Controls - text areas, buttons, checkbox, radio button, etc.) to input the following information: Name of the customer First Name Last Name Phone number of the customer Type of food being order...
In Java Create a simple GUI that gets the exam score and shows the corresponding letter...
In Java Create a simple GUI that gets the exam score and shows the corresponding letter grade by clicking on the “Convert Score to Letter Grade” button.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT