Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2004

Tip: Looking for answers? Try searching our database.

Graphics Ques & Array List Wrapping

Thread view: 
M Smith - 30 Mar 2004 00:28 GMT
Hi im turning to you guys for two trivial questions, the first, I am drawing
a line using g.drawPolyline() how can I make each line a different colour,
the g.setColour() allows me to set the colour of the entire canvas as the
repaint method is required to show a newly drawn line ?

My second question is, how do I wrap an Array List as in place an entire
list into the first index of another array list or basic array, I presume it
needs to be wrapped but is there an easier way ?.

Hope that's semi clear, Thanks Pete
Andrew Thompson - 30 Mar 2004 00:35 GMT
> My second question is, how do I wrap an Array List as in place an entire
> list into the first index of another array list or basic array, I presume it
> needs to be wrapped but is there an easier way ?.

That has nothing to do with GUI's, try..
<http://www.physci.org/codes/javafaq.jsp#cljh>

OR, once you have learned what the
various groups are for, maybe..
<http://www.physci.org/codes/javafaq.jsp#cljp>

But no, stick with the former for the moment.

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Thomas Weidenfeller - 30 Mar 2004 07:48 GMT
> Hi im turning to you guys for two trivial questions, the first, I am drawing
> a line using g.drawPolyline() how can I make each line a different colour,

By drawing individual lines instead of a polyline.

> My second question is, how do I wrap an Array List as in place an entire
> list into the first index of another array list or basic array, I presume it
> needs to be wrapped but is there an easier way ?.

See a good textbook about Java, or comp.lang.java.help.

/Thomas
Babu Kalakrishnan - 30 Mar 2004 08:02 GMT
> Hi im turning to you guys for two trivial questions, the first, I am drawing
> a line using g.drawPolyline() how can I make each line a different colour,
> the g.setColour() allows me to set the colour of the entire canvas as the
> repaint method is required to show a newly drawn line ?

Obviously you cannot use the drawPolyLine method to achieve what you want.
Instead write your own method that does what you want and call it.

For instance :

private drawColoredPolyLine(     Graphics g,
                int[] xPoints,
                int[]yPoints,
                int nPoints,
                Color[] colors)
{
    for (int i=1; i < nPoints, i++)
    {
        g.setColor(colors[i-1]);
        g.drawLine( xPoints[i-1],yPoints[i-1],
                yPoints[i],yPoints[i]);
    }
}

> My second question is, how do I wrap an Array List as in place an entire
> list into the first index of another array list or basic array, I presume it
> needs to be wrapped but is there an easier way ?.

That isn't very clear. Why do you need a special wrapping to do that ? An
ArrayList is an object, and I don't see any problem in adding it directly
to another ArrayList (or placing it into an Array of objects)

BK


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.