Need help forming randomly colored lines, that are equidistant(ex included)

My assignment: The
top-right cell requires horizontal lines that are equidistant in the cell. Each line is 10 pixels apart. Additionally, the lines need to be colored randomly in any possible red, green and blue range.
example: http://i68.photobucket.com/albums/i35/stxda/example.jpg
(example of what I need to do)
what I have now: http://i68.photobucket.com/albums/i35/stxda/current.jpg
I have all the lines coded for the top right cell, but I do not know how to get the colors random. I only know how to set all the lines to one single color.
Below is my coding:
(please try this out and help me code it)
my AIM screen name is sTxDa if there are any questions/comments
import java.awt.*;
import java.applet.*;
import java.util.*;
public class Lab06G90 extends Applet
public void paint(Graphics g)
// BELOW is for the top left cell and box (which is int a and the box's frame)
int width = 800;
int height = 600;
g.drawRect(10,10,width,height);
g.drawLine(410,10,410,610);
g.drawLine(10,310,810,310);
for (int a = 20; a <= 400; a += 10)
g.drawLine(a,20,a,290);
// BELOW is for the top right cell, which is int b. so far
// i've only done the lines, and not yet the random colors
for (int b = 10; b <= 290; b += 10)
g.drawLine(420,b,800,b);
}

but I do not know how to get the colors randomUse the Random class.

Similar Messages

  • On Windows 7, CS6 all products, but especially need help with ID.  Fonts that are showing in other applications are not showing in ID.

    on Windows 7, CS6 all products, but especially need help with ID.  Fonts that are showing in other applications are not showing in ID.

    The ID Program folder will be relevant to your OS...
    I took a shot and right clicked on my Scripts Samples, choose reveal in Explorer and opened up the ID Program folder.
    As shown, there is a Fonts folder.
    Drag/Copy/Paste fonts to this folder.

  • Need a VB-Script that read a txt-file and only the lines that are new since last time

    Hi,
    I need help to write a VB script that read all new lines since the last time.
    For example:  The script reads the textfile at specific time, then 10 minutes later the script read the file again, and it should now only read the lines that are new since last time. Anyone that has such a script in your scriptingbox?
    cheers!
    DocHo
    Doc

    Based on the excellent idea by Pegasus, where is a VBScript solution. I use a separate file to save the last line count read from the file, then each time the file is read I update the line count. Only lines after the last count are output by the program:
    Option Explicit
    Dim strFile, objFSO, objFile, strCountFile, objCountFile, strLine, lngCount, lngLine
    Const ForReading = 1
    Const ForWriting = 2
    Const OpenAsASCII = 0
    Const CreateIfNotExist = True
    ' Specify input file to be read.
    strFile = "c:\Scripts\Example.log"
    ' Specify file with most recent line count.
    strCountFile = "c:\Scripts\Count.txt"
    ' Open the input file for reading.
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(strFile, ForReading)
    ' Check if the line count file exists.
    If (objFSO.FileExists(strCountFile) = False) Then
        ' Initial count is 0, so all lines are read.
        lngCount = 0
    Else
        ' Open the line count file.
        Set objCountFile = objFSO.OpenTextFile(strCountFile, ForReading)
        ' Read the most recent line count.
        Do Until objCountFile.AtEndOfStream
            lngCount = CLng(objCountFile.ReadLine)
        Loop
    End If
    ' Read the input file.
    lngLine = 0
    Do Until objFile.AtEndOfStream
        ' Count lines.
        lngLine = lngLine + 1
        strLine = objFile.ReadLine
        If (lngLine >= lngCount) Then
            ' Output the line.
            Wscript.Echo strLine
        End If
    Loop
    ' Close all files.
    objFile.Close
    If (lngCount > 0) Then
        objCountFile.Close
    End If
    ' Ignore last line of the file if it is blank.
    If (strLine = "") Then
        lngLine = lngLine - 1
    End If
    ' Save the new line count.
    Set objCountFile = objFSO.OpenTextFile(strCountFile, _
        ForWriting, CreateIfNotExist, OpenAsASCII)
    objCountFile.WriteLine CStr(lngLine + 1)
    objCountFile.Close
    Richard Mueller - MVP Directory Services

  • I need help with storage.    5 GB are free.   So iCloud sends an email that I need more.   So I purchase 20GB and now I want to downgrade back to the 5GB.   I can check the 5GB box, but no DONE button appears.   Anyone have an answer?

    I Need help with iCloud storage.   5gb are free, so I get an email, that mine is just about full.   So I upgraded to 20gb and now I want to downgrade back to 5gb.
    tthe DONE button doesn't highlight, so my requested can't be completed.   Any help will be appreciated.

    Have you tried rebooting the computer? If not, the next step is to contact iCloud Support. http://www.apple.com/support/icloud/

  • Read sql error log, skip lines that are in a exception list

    Could someone help, I am creating a nice powershell script to read a sql server log file but to skip lines that are normal in a sql server. the "normal lines are held in a SQL table.
    To expand.
    I run a query to get the list of exception lines using invoke-sqlcmd  this creates $TextEXP
    this will contain things like "Microsoft Corporation", "All rights reserved", "Starting up Database"
    I then connect to a sql server using SMO and want to read in the error log where the text is not matched the values in $textExpI want to avoid reading extra data and process it. I have a work round but its not a nice clean as its hardcoded the match.
    $ENV =$srv.ReadErrorLog()
    |? {  $_.text
    -notmatch'This
    is an informational message only'-and$_.text
    -notmatch'No
    user action is required'-and$_.text
    -notmatch'found
    0 errors'-and$_.text
    -notmatch'Microsoft
    Corporation.'-and$_.text
    -notmatch'All
    rights reserved.'-and$_.text
    -notmatch'Server
    process ID is'-and$_.text
    -notmatch'System
    Manufacturer: '-and$_.text
    -notmatch'Starting
    up database'-and$_.text
    -notmatch'Using
    ''dbghelp.dll'' version'-and$_.text
    -notmatch'Authentication
    mode is'-and$_.text
    -notmatch'Logging
    SQL Server messages in file '-and$_.text
    -notmatch'Setting
    database option'-and$_.text
    -notmatch'The
    error log has been reinitialized. See the previous log for older entries'-and$_.text
    -notmatch'Server
    is listening on '-and$_.text
    -notmatch'Registry
    startup parameters:'-and$_.text
    -notmatch'Clearing
    tempdb database'-and$_.text
    -notmatch'Service
    Broker manager has started'-and$_.text
    -notmatch'The
    Service Broker protocol transport is disabled or not configured'`
    -and$_.ProcessInfo
    -notmatch"Logon"-and$_.logdate
    -ge$Sdate}

    So after some looking about on the web I found that you can use the | in a string
    the following will give an idea of how to use this (this is not a clean bit of code but will give you a starting point)
    $TextEXP  this is a data table from sql server with the list of values I want to skip
    The field name (col name) is extext
    Set the string to be empty
    $exclusions = ""
    #Create a string with the values in $TextExp
    Foreach($value in $TextExp){
    $exclusions = $exclusions + "$($value.extext)|"
    #remove the last pipe from the string
    $exclusions = $exclusions.substring(0,$exclusions.length-1)
    ##This will create a long string value|value|value###
    $err = $srv.readerrorLog() | ?{$_.text - notmatch $exclusions}
    ###end
    May need bit of a clean up and may be a better way but seems to do what I need for now.
    Thanks all for the help

  • How to draw vertical lines that are visible in preview mode?

    Hi all,
    I need to draw vertical lines on a document. The lines must be same as we draw using line tool.
    I could draw the line using CreateLineSpline() method of IPathUtils.
    The problem is that these lines are not visible in preview mode. Please tell how can we make lines that are visible in preview mode.
    Please help, I'm running out of time.

    CodeSnippetRunner has the answer:
    Utils<IPathUtils>()->CreateLineSpline

  • I need help in resolving a problem that prevents me from accessing the iTunes store.  Message reads " iTunes cannot contact the iTunes store" and also says that my laptop is no longer authorized to access my account.  Help!

    I need help in resolving a problem that prevents me from accessing the iTunes store.  Message reads " iTunes cannot contact the iTunes store" and also says that my laptop is no longer authorized to access my account.  Help!

    Go up to the top of your screen on iTunes and click on 'Store'.  Then go down to 'Authorize This Computer'.  That should cover part of it unless you've already authorized a bunch of other computers to use your account.  If that's the case, you'll have to go to one of those computers and click the button just below it to 'deauthorize your account' from that computer.  If you're not able to access the store, check your internet connection to make sure you are connected.  Hope this helps.. good luck!     

  • Is there any way to get Mini Bridge to show the color labels that are set in Bridge and/or Lightroom

    Is there any way to get Mini Bridge to show the color labels that are set in Bridge and/or Lightroom?
    I am using Cloud InDesign CS6 on Windows 7.

    You will need to go via your computer's iTunes - to get music into the Music app you either need to download it directly on the iPad from the iTunes store app, or sync it from your computer's iTunes

  • HT1349 I need help finding an old library that itunes states my ipod is already linked to

    I need help finding an old library that it states my ipod is already linked to.  My computer recently had a terrible virus and needed to be wiped clean.  I had to redownload itunes and I bought several songs.  I want to add them to my old library because I had several cd's that I had uploaded.  Is there a way to find that old library and combine them without having to erase all the songs that are currently on my ipod???  Thanks

    Umm.  If you wiped the hard drive, then all old libraries are gone unless you have them on backup.

  • I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    You mean an image such as a scanned document?
    If that is the case, the file doesn't contain any text for Reader Out Loud to read. In order to fix that, you would need an application such as Adobe Acrobat that does Optical Character Recognition to convert the images to actual text.
    You can also try to export the file as a Word document or something else using ExportPDF which I believe offers OCR and is cheaper than Acrobat.

  • Help needed in generating random colors...

    Please review my code. I'm trying to generate ten triangles in random colors but each time I run the app the triangles are always in the same color (but a different color with each run). What am I doing wrong?
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class DrawTriangles extends JFrame
    public DrawTriangles ( )
    super ( "Drawing Random Triangles" );
    setSize ( 400, 400 );
    setVisible ( true );
    public void paint ( Graphics g )
    super.paint ( g );
    int [ ] xArray = { 10, 40, 70, 100, 130, 160, 190, 220, 250, 280 };
    int [ ] yArray = { 30, 60, 90, 120, 150, 180, 210, 240, 270, 300 };
    Graphics2D g2d = ( Graphics2D ) g;
    GeneralPath triangle = new GeneralPath ( );
    for ( int counter = 0; counter < 10; counter++ )
    triangle.moveTo ( xArray [ counter ], yArray [ counter ]);
    for ( int count = 1; count < 3; count++ )
    triangle.lineTo ( xArray [ counter ] + 20, yArray [ counter ] + 40 );
    triangle.lineTo ( yArray [ counter ] + 20, xArray [ counter ] + 20 );
    triangle.closePath ( );
    g2d.setColor ( new Color (
    ( int ) ( Math.random ( ) * 256 ),
    ( int ) ( Math.random ( ) * 256 ),
    ( int ) ( Math.random ( ) * 256 ) ) );
    g2d.fill ( triangle );
    public static void main ( String args [ ] )
    DrawTriangles application = new DrawTriangles ( );
    application.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );

    You're are only drawing one thing, the GeneralPath, not ten things. If you want your things to have ten different colors then you will need ten different things. (ie, use 10 different general path instances)

  • Form template with lines that shouldn't print are printing

    I have Windows 8.1 and Adobe Reader 11.0.09. I have had a template from my employer that we use to create address labels. There are lines for name, address, etc that are supposed to be invisible when printed, but that has not been the case the past few times I have printed.

    Ask the author of the file to double-check their work. There's nothing you can do about it yourself if you only have Adobe Reader.

  • Cancel Sales Order lines that are picked

    Hi
    1. I'm trying to cancel sales order lines through process order api that are picked and delivery status is Staged/Pick Confirmed. The error is
    You are not allowed to cancel Order Line because:
    Line has been pick confirmed/staged.
    I'm unable to perform by below means
    1.There is a processing constraint on the field SCHEDULE_ARRIVAL_DATE.
    Delete the processing constraint and retry the cancel line process - Processing constraint form the fields are protected against update
    2.Navigate to the shipping transaction form and query the order. Select the line and enter 0 at shipped quantity.Save the record.Ship confirm the line, this will cause the line to be backordered.Query the order line in the order entry form and cancel this. - Shipping transactions form the fields are protected against update
    2. Is there a way to cancel Internal Sales Order(ISO) lines of one OU and the corresponding internal requisition is another OU
    Thanks
    kumar

    If you are in R12, there are some enhancements from Oracle that allows updating/cancelling certain Internal requistion fields and Internal orders automatically. You may need to disable few processing constraints too.
    As of Now Oracle support change to following attribute at OM side
    1 Order Quantity
    2 Request Date
    3 Schedule date
    4 Arrival date
    Similarly if we make changes in following fields in Approved IR
    1 Quantity
    2 Need by Date
    These changes will got reflected in ISO
    Plus cancel the IR line or ISO line, the other one gets cancelled automaically.
    To cancel the picked line, first undo the pick confirmation process by back ordering. or unassign the delivery details from the delivery (if created already) and cancel the delivery.In either case, you need to manually trasnfer the qty from staging area to original locations. Oracle doesn't automatically move the qty back, (undo move order transaction).
    Ganesan.

  • Need help setting up color scanning through Adobe 9 pro

    Unable to set-up the color scanning through adobe 9 pro,   need help!

    Obviously, FireWire is a fast connection, but for changing metadata, USB is plenty fast. Why it takes so long is anyones guess. Is it a USB 2.0 drive? Using external drives can be tricky. My father uses them for his gigantic library of almost 80,000 songs. When you have it setup properly, it works fine, but if you say forgot to have the external drive mounted when you launch iTunes, iTunes defaults the library back to your Music folder, then when you start importing, it puts in on the internal drive, then you have to go back and reset it, etc. Problem, with iTunes alone, you can only set one library, so if you want to use two drives, you will have to have one set at any given time.
    So you could set the music one first, add to the library, then set it for movies, then add those to the library. Then keep the library set to the one you use most frequently, so you don't have to always switch. Once you import all media, and iTunes "knows" where to find the files, you can play them with no problems with two drives.
    For wireless, you have a couple choices. If you have two Macs, you could keep one connected to the two drives, then with the other computer, just connect to the network and share the iTunes library so your other computer has access. If you want the music stored on a drive accessible wireless, you'll probably have to look to NAS, or some form of wireless storage. If you do that, their may even be a better third party software solution other than iTunes for managing multiple libraries.
    This is something iTunes really needs. As libraries grow, one drive just isn't enough often.
    Bryan

  • I need help with random number in GUI

    hello
    i have home work about the random number with gui. and i hope that you can help me doin this application. and thank you very much
    Q1)
    Write an application that generates random numbers. The application consists of one JFrame,
    with two text fields (see the figures) and a button. When the user clicks on the button, the
    program should generate a random number between the minimum and the maximum numbers
    entered in the text fields. The font of the number should be in red, size 100, bold and italic.
    Moreover, if the user clicks on the generated number (or around it), the color of the background
    should be changed to another random color. The possible colors are red, green blue , black ,cyan
    and gray.
    Notes:
    �&#61472;The JFrame size is 40 by 200
    �&#61472;The text fields size is 10
    this is a sample how should the programe look like.
    http://img235.imageshack.us/img235/9680/outputgo3.jpg
    Message was edited by:
    jave_cool

    see java.util.Random

Maybe you are looking for

  • How do I get my laptop to remember different display arrangements for different external monitors?

    I have a couple of different places where I work, and in both places there is an external monitor. As it turns out, the external monitor is on the left in one place and on the right in the other. They are different monitors, too (one's an old dell an

  • Problem in unzip companion 10g cd .

    Hi Frnds, I am trying to unzip 10g companion using the command .. unzip <file_name> while unzipping i am getting this error during the middle file #1245 : bad zipfile offset (local header sig): 3945848393 This line is continued for 10 to 30 files. Is

  • Satellite U305-S7446 and Windows XP troubles

    Ok I got here Satellite U305-S7446 and as I didnt like vista I thought I will install Windows Xp so I use my trusty windows 98CD and go to fdisk and delete non dos partitions and create one primary partition of 30% of the hard drive. I then start com

  • Firmware problem

    Hi, the nxt brick is connected and recognized by lab view(2012 version), when trying to donwload the Firmware "LEGO MINDSTORMS NXT Firmware V.1.31" when trying to download the firmware the progress starts loads and the brick starts to tick (tic tic t

  • Safari crashing the machine

    Since upgrading to 10.8.2 I've been experiencing periodic crashes of my late 2009 27" iMac -- roughly once a week on a heavily used machine. The symptoms are always the same: Safari stops responding and everything else -- including mouse and keyboard