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...
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...
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 this question, you are asked to write a simple java program to understand natural language....
In this question, you are asked to write a simple java program to understand natural language. The user will enter the input following the format: Name came to City, Country in Year. For example: Robin came to Montreal, Canada in 2009. Assume a perfect user will follow the exactly above formats for the inputs. Your program should be able to analyze the key words (Name, City, Country and Year) from the inputs and reorganize the outputs following format: Name stay...
I need a java code Write a simple program to prompt the user for a number...
I need a java code Write a simple program to prompt the user for a number between 1 and 12 (inclusive) and print out the corresponding month. For example:   The 12th month is December. Use a java "switch" statement to convert from the number (1-12) to the month. Also use a "do while" loop and conditional checking to validate that the number entered is between 1 and 12 inclusive and if not, prompt the user again until getting the correct...
Create in java an interactive GUI application program that will prompt the user to use one...
Create in java an interactive GUI application program that will prompt the user to use one of three calculators, label project name MEDCALC. You can use any color you want for your background other than grey. Be sure to label main java box with “MEDCALC” and include text of “For use only by students” On all three calculators create an alert and signature area for each user. The alert should be something like “All calculations must be confirmed by user...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT