Home Answers Viewqa Java-Beginners drawing triange using stars

 
 


goodie
drawing triange using stars
1 Answer(s)      5 years and 2 months ago
Posted in : Java Beginners

How do i Write a program to draw the boundaries of a plot of land with the structure shown in the diagram, for any set of input values for the dimensions. Use ?*? to represent the sides

View Answers

April 2, 2008 at 8:48 PM


Triangle.java

import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;

public class Triangle{
public static void main(String args[]){
Polygon tri = new Polygon();
tri.addPoint(0,25);
tri.addPoint(25,0);
tri.addPoint(50,25);
Rectangle rect = tri.getBounds();
BufferedImage img = new BufferedImage(rect.width,rect.height,BufferedImage.TYPE_INT_RGB);
Graphics2D g = img.createGraphics();
g.setColor(Color.white);
g.fill(rect);
g.setColor(Color.black);
g.fill(tri);
int x,y;
for (y = 0;y < img.getHeight();y++) {
for (x = 0; x< img.getWidth();x++) {
if (img.getRGB(x,y) == 0xffffffff)
System.out.print(" ");
else
System.out.print("*");
}
System.out.println("");
}
}
}









Related Pages:
drawing triange using stars - Java Beginners
drawing triange using stars  How do i Write a program to draw the boundaries of a plot of land with the structure shown in the diagram, for any set of input values for the dimensions. Use ?*? to represent the sides   
stars question
stars question  program to get this output
Drawing Graphs - Java3D
Drawing Graphs  how to draw graphs using certain parameters  Hi Friend, To draw a graph using JfreeChart library, please visit the following link: http://www.roseindia.net/chartgraphs/index.shtml Here you
scrolling a drawing..... - Swing AWT
scrolling a drawing.....  I am using a canvas along with other components like JTable over a frame the drawing which i am going to show over canvas is dynamic and hence there is no fixed size, that's why i need to make
Line Drawing - Swing AWT
Line Drawing  How to Draw Line using Java Swings in Graph chart... using java Swing import javax.swing.*; import java.awt.Color; import...) { System.out.println("Line draw example using java Swing"); JFrame frame = new
drawing a christmas tree - Java Beginners
drawing a christmas tree  how do i write a program that draws a chrimas tree using the knowledge of loops only. i.e * *** ***** ******* the program will draw a Christ mas tree  Hi ChristmasTree.javaimport java.awt.
Drawing
the basis for drawing simple graphics (lines, circles, text, ...). It is easy to use, and can be used with the Color class to set the drawing color and Font class to set the font for drawing text. Additional graphical classes In Java 2
importing excel file and drawing multiple graphs from one excel file
importing excel file and drawing multiple graphs from one excel file  thanks a lot sir for replying with code for importing excel file... time from one excel file using different columns..and instead of passing column
Drawing a Shape in Excel Sheet
Drawing a Shape in Excel Sheet In this section, you will learn how to draw a shape in excel sheets using Apache POI library. Using Apache POI, you can draw a shape with the help of Microsoft Office drawing tools. The top-most shape
JPanel - Drawing Area
Java: JPanel - Drawing Area   To use a JPanel for graphics  ...; Example of drawing panel drawing area.   Define a subclass of JPanel... background . . . // do your drawing here
How many types of drawing objects are available in drawing toolbar
How many types of drawing objects are available in drawing toolbar  How many types of drawing objects are available in drawing toolbar
Drawing with Color in Java
Drawing with Color in Java     ... these with the appropriate color. Following are some methods are using in the given program... class is used to drawing different-different type of shapes). This method draws
Drawing Graphs - Swing AWT
Drawing Graphs  hi i am doing a small project in java swings . there is a database table having two columns A,B i want to plot a graph to that values in database the graph must be interactive graph
Arcs Drawing In Java
Arcs Drawing In Java      .... In this program we are using the BasicStroke() method. You can learn about this method in the previous program. Here, this program is using the "Arcs2D.Double"
Drawing with Gradient Color in Java
Drawing with Gradient Color in Java       In this section, you will learn how to draw the colorful...; this program. Program draws a rectangle using Graphics2D and GradientPaint(). 
drawing out of bounds
drawing out of bounds  How to throw an exception when a rectangle goes out of the boundaries of a JFrame. The program is asking to draw a triangle, and resize it. If the triagle size goes out of the JFrame throw an execption. I
How to convert a picture to drawing, convert a picture to drawing, picture to drawing
How to convert a picture to drawing       Learn here a simple processing to make a color picture to drawing, we have tried here to take simple step to learn easily for the beginners
Please help in drawing Flowchart
Please help in drawing Flowchart  we found that the student names with marks in a text file the marks decreases significantly. when exams conducted fast 4 times.THe first column is the student name and the second column is marks
drawing shapes in applet - Applet
drawing shapes in applet  hi, i need a single applet prgm which draws cone,cube and square in circle.  Hi manju, This is cube example import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import
Java - Drawing Shapes Example using color in java
Java - Drawing Shapes Example using color in java       Introduction In this program we will show you how to draw the different types of colorful shapes. This example show
drawing a human in java - Java Beginners
drawing a human in java  i wanna to draw a human in java can u help me how can i draw.? the question is : how to draw a human in java add the nose + the eye + mouth .   where is the answer.? plz i want
An Applet program for Drawing picture & graph - Applet
An Applet program for Drawing picture & graph  How can I write an Applet program for drawing picture and graph having various colours and tools provided
problem in scrolling SVG drawing in canvas - MobileApplications
problem in scrolling SVG drawing in canvas  hi all, i'm developing an app that display maps on mobile -i used SVG graphics in drawing the maps... over the drawing , scrolling works well in wireless toolkit emulator , but when i
Applet program for drawing picture and graph - Applet
Applet program for drawing picture and graph  Please send me the program(code) of drawing picture and graph in Applet.  Hi Friend, Please visit the following links: http://www.roseindia.net/java/example/java
Java: Example - Drawing a Face - v2
Java: Example - Drawing a Face - v2 This simple application creates... the paintComponent method to do the drawing. 1 2 3 4 5 6 7 8...()); // Put drawing in window. window.pack(); // Adjust
Java: Example - Drawing a Face - v3
Java: Example - Drawing a Face - v3 Two separate source files This is the same as the previous application, except that the two classes have been put...); window.setContentPane(new Face()); // Put drawing in window
Java gui program for drawing rectangle and circle
Java gui program for drawing rectangle and circle   how to write java gui program for drawing rectangle and circle? there shoud be circle and rectangle button, check box for bold and italic, and radio button red,green and blue
Java: Example - Drawing a Face - v5
Java: Example - Drawing a Face - v5 Main - Setting the instance variables 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16...); // Put drawing in window. window.pack(); // Adjust to fit
Simple Line Canvas Example
Simple Line Canvas Example       This is a simple example of drawing lines using canvas class in J2ME. In this example we are creating three different lines at different
Java: Example - Drawing a Face
Java: Example - Drawing a Face This simple application creates... the paintComponent method to do the drawing. 1 2 3 4 5 6 7...()); // set its layout PacLady drawing = new PacLady
Print Screen Using Java Swing
Print Screen Using Java Swing   ... that describes how to send drawing to the printer. To start drawing the Graphics..." file for print the display value. In this step using print() method
Java: Example - Drawing a Face - v5 - Fill-in
Java: Example - Drawing a Face - v5 - Fill-in Main - Setting the instance variables 1 2 3 4 5 6 7 8 9 10 11 12 13 14...(aFace); // Put drawing in window. window.pack(); // Adjust
Java: Example - Buffered Analog Clock
) clock that uses buffered drawing to increase speed. In buffered drawing some... of Buffered Analog Clock.   This is an an analog clock example Using Timer...:   // An analog clock -- Using Timer and Calendar..// Uses
to write an SQL query using insert statement
to write an SQL query using insert statement  I need to write an sql query for the below using InSERT command.pls help. Insert 5-star ratings.... Rating ( rID, mID, stars, ratingDate ) English: The reviewer rID gave the movie
Open-jACOB Draw2D
to provide an interactive drawing and diagramming solution. Open-jACOB Draw2D is the graph component of the Open-jACOB online Workflow editor. Using open
History and Evolution Of GPS
to follow the coastline and stars in the sky to to keep themselves from getting... using atomic clocks placed in orbit inside artificial satellites... by Russia on October 4th, !957 which led the concept that artifical stars can also
JPanel - Drawing Area 2
Java: JPanel - Drawing Area 2   To initialize the panel..., but if all drawing panels have the same attributes or the attribute can easily... To find the size of the drawing area Use drawing.getWidth
Drawing a Face v2
Java: Example - Drawing a Face v2 This simple application creates... the paintComponent method to do the drawing. 1 2 3 4 5 6 7 8 9... content.setLayout(new BorderLayout()); // set its layout PacLady drawing = new
Font
Java NotesFont Description The java.awt.Font class is used to create Font objects to set the font for drawing text, labels, text fields, buttons, etc...[] allFonts = ge.getAllFonts(); Using Fonts for Graphics Font f; f = new Font
Drawing a Face - v4
Java: Example - Drawing a Face - v4 Instance variables representing the state This Face class is essentially the same are the previous example... of the drawing. These could be declared as constants (static final), but we're going
Graphics class
Java NotesGraphics class Description The Graphics class contains drawing... need to write a paintComponent() method which contains all your drawing calls... and font for all drawing. The "draw" methods all draw lines, and the "fill
Flex Circle drawing example
Flex circle drawing example       Example below draw circles on the panel... for drawing a circle is defined inside the Sprite class of flash.display
Java - Drawing Shapes Example in java
Java - Drawing Shapes Example in java       Introduction Applet is a program to run on the browser and it is embedded on the web page. This program is not system level program
java
java  using java how to show password in stars (**). but not in JSP. plz im waiting for ur reply eagerly. thanks in advance
how to draw lines,circles, rectangles on JSP (using Java Graphics)
how to draw lines,circles, rectangles on JSP (using Java Graphics)  how to draw lines,circles, rectangles on JSP (using Java Graphics)   ... = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // Get drawing
Displaying the same image in a JPanel and using scroll - HELP - Java Beginners
Displaying the same image in a JPanel and using scroll - HELP  I hope... contain a Scroll, so using the scroll I want to see the first image displayed... cannot see the images displayed using the scroll. import javax.swing.
Summary: Graphics
in the java.awt.Graphics class for drawing with shapes, colors, text, ... Other... classes: Fonts, Images - ImageIcon java.awt.Graphics Class - Basic drawing...) g.setColor(Color c); // All drawing after this uses the Color c
Cubic Diagram In Java
common Geometry object as a coordinate component. The Java Drawing program...;java.awt.geom" package. Program Description: In this program, We are using
core java - Java Beginners
using stars. class EquilateralTriangle { public static void main(String...core java  write a program to display equilateral traiangle using stars? output will be as follows: * * * * * * * * * * 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.