Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to make multiple rectangles
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Vaishnavi Mukundhan
how to make multiple rectangles
0 Answer(s)      a year and 5 months ago
Posted in : Java Beginners


I,m a beginner , m sorry if the question is really simple
i have an array list.I want to print the contents of the array list in rectangles. as in each element should be in different rectangles. please help my code as of now:(but this doesn't work)

import java.awt.Color;  
import java.awt.Graphics;
import java.util.ArrayList;
import javax.swing.JFrame;

public class Output extends JFrame  
{ 

    /**
     *
     */
    public Output()  
{  
 //Set JFrame title  
 setTitle("Draw A Rectangle In JFrame");  

 //Set default close operation for JFrame  
 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  

 //Set JFrame size  
 setSize(400,400);  

 //Make JFrame visible   
 setVisible(true);  
}  

public void paint(Graphics g)  
{  
    ArrayList <String> classlist=new ArrayList<String>();
   classlist.add("library");
   classlist.add("customer");
   classlist.add("member");
   classlist.add("card");
   classlist.add("yes");


  for(int i=0;i<=classlist.size();i++)
  {    
      super.paint(g);
      int x=i+100;
      int y=i+500;
      int w=x+25;
      int z=y+25;
     String thisCity= classlist.get(i);
 //draw rectangle outline
      super.paint(g) ;
 g.drawRect(x,y,100,100);  
 g.drawString(thisCity,w ,z);
  }
}  

public static void main(String[]args)  
{  

 Output dlijf;  
        dlijf = new Output();
}

}


Advertisement
View Answers

Related Tutorials/Questions & Answers:
how to make multiple rectangles
how to make multiple rectangles  I,m a beginner , m sorry... of the array list in rectangles. as in each element should be in different rectangles...(JFrame.EXIT_ON_CLOSE); //Set JFrame size setSize(400,400); //Make JFrame
how to make multiple choice questions
how to make multiple choice questions  I have to make a multiple choice choice using JSP/Servlets. I created a a session bean for the questions and answers. how to associate group of questions to a user? so each user will have
Advertisements
how to draw lines,circles, rectangles on JSP.
how to draw lines,circles, rectangles on JSP.  how to draw lines,circles, rectangles on JSP. Kindly provide solutions asap
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)   Hello Anuj Try the Following Code : image.jsp <%@ page contentType="image
how to make this pattern???
how to make this pattern???  how to make following pattern in javascript
How to make elements invisible ?
How to make elements invisible ?   How to make elements invisible
how make ID - Ajax
how make ID  how make a ID in eyeball chat
how to make exampage in jsp ?
how to make exampage in jsp ?  how to make a online exam page in jsp and servelet
how to make a program on array
how to make a program on array  When you make a program on array that the element will move downward and upward and when you input twice 0 then thats the time that it will not move. pls. give me a formula...tnx
How to make selectOneMenu scrollable
How to make selectOneMenu scrollable  how to make the selectOneMenu scrollable? I have around 20 values in drop down and i want the scrollable functionality after 5 values. Kindly reply as soon as possible. Thanks Shikha
how make excel
how make excel  how make excel spreadsheet IN JAVA. please send this code argently   Hello Friend, Try the following code: import java.io.*; import org.apache.poi.hssf.usermodel.HSSFSheet; import
how to display multiple images on browser
how to display multiple images on browser  i want to display multiple images on brower including string values from sql database using jsp
how to display multiple images on browser
how to display multiple images on browser  i want to display multiple images on brower including string values from sql database using jsp
how to make paging with function ?
how to make paging with function ?  how to make paging with function ?   //this page is display.php <?php</p> $con=mysql_connect("localhost","root",""); if(!$con) { die("you can connect please check". mysql
how to make a label left alignment?
how to make a label left alignment?  how to make a label left alignment
how to make a field left justification
how to make a field left justification  how to make a field left justification.need code.thanks in advance
How to make a chain, make a chain, chain
How to make a chain       To learn how to design a chain in the photoshop has become so easy by this example, it has some important instruction to make it so follow
how to make paging with class and ajax
how to make paging with class and ajax  paging with class and ajax
How to make bubbles, make bubbles, bubbles
How to make bubbles      ... to make it easily to draw. New File: First take colored background file. Draw... Overlay, use same both settings as given below. Duplicate: Now make
How to make directory in java
Description: This example demonstrate how to create a directory at specified path. Code: import java.io.File; public ... is that it will make a dir at root directory of C drive
How to make a transparent text
How to make a transparent text Learn how to make a transparent...) and make formatting as looking here. Write Text: Now write your text as you like. I have written here "Text". After writing text make copy (Ctr
How to make halo effect
How to make halo effect       Now get ready to learn a simple way to make a halo effect on the picture, follow to make it. Take a picture: Capture any picture to give
How to make a bone, make a bone, a bone
How to make a bone       This example bone design example, It is very easy. If you are looking for, please follow now. New File: Create a new file. Rounded rectangle
How to Make iPhone Window Application
How to Make iPhone Window Application  Hi, For Making iphone window application, what parameters i have to follow or provide example related to iphone window application. Thanks
how to send mail with multiple attachments in jsp
how to send mail with multiple attachments in jsp  how to send mail with multiple attachments in java script
How to make query and abstraction in Java
How to make query and abstraction in Java  Hi, I read the lessons you have in the sites. They are really useful. However, I could not write codes... PostgreSQL database, and I want to make a query and abstraction for a table. Could
How to display multiple images in jsp
How to display multiple images in jsp  <%@ page import="java.io.*"%> <%@page import="book.Databasecon"%> <%@ page import="java.sql.*,java.util.*"%> <%!OutputStream o; %> <%!ArrayList<Blob> bl
How to make a button of different behaviour?
How to make a button of different behaviour?  Suppose In a jsp page I have a button SAVE with id="btnSave" value="SAVE" and a javascript function... ajaxInsertUpdateData(document.getElementByID("btnSave1").value,......); How to do
How To Make This Program - Java Beginners
How To Make This Program  How To Make Java Calculation program I want to Write a program in Java that calculates the sum of digits of an input number, prints it, then calculates the sum... output: 59 14 5 please help to make
how to make employee i card
how to make employee i card  hello friends can anyone help me.. I have to make a project to make Identity card for employees...but i am facing problems with database and jsp connection ... also tell me how to retrive data
how to make combinations - Development process
how to make combinations  import java.util.*; interface Expression { public void interpret(ArrayList exp); } class OrExpression implements Expression { public void interpret(ArrayList exp) { //wats the logic
 

 

 

DMCA.com