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

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
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...
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...
Use the below info to create a java program A GUI interface to ensure a user...
Use the below info to create a java program A GUI interface to ensure a user is old enough to play a game. Properly formatted prompts to input name, address, phone number, and age. Remember that name, address, phone number, etc. can be broken out in additional fields. Refer to the tutorial from this week’s Reading Assignment Multiple vs. Single Field Capture for Phone Number Form Input for help with this. Instructions to ensure that the information is displayed back...
Write a simple java program to list roman numeral for a given range of numbers. Roman...
Write a simple java program to list roman numeral for a given range of numbers. Roman numerals are represented by seven different symbols: I, V, X, L, C, D, and M. I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, M = 1000 Roman numerals are usually written largest to smallest from left to right. But a number like 4 is not written as IIII. It is written as IV. Because...
Write a java simple document retrieval program that first asks the user to enter a single...
Write a java simple document retrieval program that first asks the user to enter a single term query, then goes through two docuements named doc1.txt and doc2.txt (provided with assignment7) to find which document is more relevant by calculating the frequency of the query term in each document. Output the conclusion to a file named asmnt7output.txt in the following format (as an example for query “java” and “problem”). The percentages in parenthese are respective supporting frequencies. java: doc1(6.37%) is more...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT