how to make multiple rectangles

how to make multiple rectangles

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();
}

}

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 :ADS_TO_REPLACE_1 image.jsp <%@ page
how make ID - Ajax
how make ID  how make a ID in eyeball chat
How to make elements invisible ?
How to make elements invisible ?   How to make elements invisible
how to make this pattern???
how to make this pattern???  how to make following pattern in javascript
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 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 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 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 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 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 label left alignment?
how to make a label left alignment?  how to make a label left alignment
How to make first JSP page?
How to make first JSP page?  Hello, How I can make first JSP page? Thanks
How to make bubbles, make bubbles, bubbles
How to make bubbles      ... to make it easily to draw. New File: First take colored background file.ADS.... ADS_TO_REPLACE_3 Duplicate: Now make duplicate layer and press Ctr
how to make paging with class and ajax
how to make paging with class and ajax  paging with class and ajax
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... mask tool (T key) and make formatting as looking here. Write Text: Now write... text make copy (Ctr +C) and past (Ctr + V).ADS_TO_REPLACE_2 Drop Shadow: Go
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.ADS_TO_REPLACE_1
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 a new List in Java
How to make a new List in Java  Hi, I have to create list object in Java. How to make a new List in Java? Thanks (adsbygoogle = window.adsbygoogle || []).push({});   Hi, The easiest way is to use
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 first JSP page?
How to make first JSP page?  Hello, How I can make first JSP page? Thanks   HI, Beginner can learn JSP from writing the first Program... tutorial: How to make my first JSP page? Thanks
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 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 pass multiple values from a servlet to JSP?
How to pass multiple values from a servlet to JSP?  hi, I want to pass multiple values form a servlet to JSP. Hw do i do that? I am able to send one value at a time without any prb, but I am unable to carry multiple (from two
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 carry multiple values from a Servlet to a JSP?
How to carry multiple values from a Servlet to a JSP?  By using...). ----response.sendRedirect("index.jsp?uname="+username);---- But I want multiple values needs to be carried from my servlet to a JSP. How do I do
How to make a design document for exception handling in java
How to make a design document for exception handling in java  How to make a design document for exception handling
how to scroll multiple images using on Click in Android
how to scroll multiple images using on Click in Android  I am new... there is requirement like multiple image scrolling dynamically. But unfortunately i am unable to scroll multiple images. But i am able to scroll single image. plz let me know
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
How to convert multiple files in java to .zip format
How to convert multiple files in java to .zip format  i receive multiple files from a remote URL as for (String reportid : reportList... as to make it available for download.   import java.io.*; import
How servlet Handles Multiple Request - Java Beginners
How servlet Handles Multiple Request  In servlet life cycle,consider two requests are waiting for service(). I know all request will be assigned to thread, which request gets excecuted first. 1
how can i make monthly register ?
how can i make monthly register ?  how can i make monthly register ? iam using jdeveloper
how to make paging with class and ajax
how to make paging with class and ajax  paging with class and ajax... displayLinks($show){ $this->show = $show; // How many links to show... displayLinks($show){ $this->show = $show; // How many links
How to make a cross eye, make a cross eye, cross eye
How to make a cross eye       You can make a cross eye effect with any type of eye picture by using this example, It will surly help you to make this effect. Take a picture: Capture
how to use a single web page multiple functionaliteies
how to use a single web page multiple functionaliteies  i have a web page in that according to user role functionality should be varies/changes but page should be common for every user & functionality..my moto is to reduse
how to use a single web page multiple functionaliteies
how to use a single web page multiple functionaliteies  i have a web page in that according to user role functionality should be varies/changes but page should be common for every user & functionality..my moto is to reduse
how to use a single web page multiple functionaliteies
how to use a single web page multiple functionaliteies  i have a web page in that according to user role functionality should be varies/changes but page should be common for every user & functionality..my moto is to reduse
how to use a single web page multiple functionaliteies
how to use a single web page multiple functionaliteies  i have a web page in that according to user role functionality should be varies/changes but page should be common for every user & functionality..my moto is to reduse
how to use a single web page multiple functionaliteies
how to use a single web page multiple functionaliteies  i have a web page in that according to user role functionality should be varies/changes but page should be common for every user & functionality..my moto is to reduse
how to use a single web page multiple functionaliteies
how to use a single web page multiple functionaliteies  i have a web page in that according to user role functionality should be varies/changes but page should be common for every user & functionality..my moto is to reduse
How to make login form in Struts 2?
How to make login form in Struts 2?  Hi, How to make login form in Struts 2? Thanks   Hi, If you want to learn to make Login form in Struts then check following tutorial: How to create Login Form in Struts2? Thanks

Ads