Simple, funny but annoying question, putting a pixel

Maybe this could be simple, funny but annoying question.
How do you put a pixel or draw a pixel?
Is there a method to draw a pixel directly on screen in j2SDK API?

This is a very open ended question, do you want to draw a pixel in an image or just draw a shape on the screen?
If you want to edit single pixels at a time then the best option is to create a BufferedImage and use the WritableRaster to edit the pixels you want by using setPixel().
Something like the following:
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
WritableRaster raster = img.getRaseter();
raster.setPixel(x_coord, y_coord, new int[]{R_val, G_val, B_val});This image can then be displayed by putting it in a JLabel (there are many other techniques but I find this the easiest method).
JLabel l = new JLabel(new ImageIcon(img));
JFrame jf = new JFrame();
jf.setContentPane(l);
jf.pack();Alternatively, you can draw shapes by using Graphics or Graphics2D objects
e.g.
public class MyPanel extends JPanel
  public void paintComponent(Graphics2D g)
     super.paintComponent(g);
     g.drawLine(x1,y1,x2,y2);
}Hope this helps,
Stef

Similar Messages

  • Pretty simple but annoying question for newbie

    when opening form is there a way to automatically display the
    record rather than having to hit F8.
    also....
    is there a way to navigate through records using PL/SQL rather
    than using the buttons on the tool bar at the top or form
    runtime.
    thanks in advance

    This is probably in the wrong forum. ;)
    Anyway, here's my suggestions for your two queries:
    Q1) Add a WHEN-NEW-FORM-INSTANCE trigger containing the
    following statement:
    EXECUTE_QUERY ;
    Q2) Use the up and down arrow keys - they navigate between the
    previous and next records respectively.
    HTH

  • Simple Logic but annoying

    I got this code from a web site ...it seems easy....The
    trouble I am having is : when the page loads it shows 10 record per
    page but when I click next link it shows 20 records on the
    page...another next will populate 30 records on page...I need 10
    records on each navigation...Any help :D
    <cfparam name="start" type="numeric" default="1">
    <cfparam name="step" type="numeric" default="10">
    <cfquery datasource="..." name="queryResults">
    select * from table
    </cfquery>
    <cfif queryResults.recordcount gt 0>
    <cfoutput>
    <p>
    <!--- if past start --->
    <cfif (start-step-step) gt 1>
    <a href="#cgi.SCRIPT_NAME#?start=1"><img
    src="/images/beginning_blue.png" alt="Beginning"
    align="absbottom"></a>
    </cfif>
    <cfif start gt 1>
    <a href="#cgi.SCRIPT_NAME#?start=#start-step#"><img
    src="/images/previous_blue.png" alt="Previous"
    align="absbottom"></a>
    </cfif>
    <strong>#start# - #iif(start + step gt
    queryResults.recordcount,queryResults.recordcount,start + step-1)#
    of #queryResults.recordcount# records</strong>
    <!--- if still some not displayed --->
    <cfif (start + step) lte queryResults.recordcount>
    <a href="#cgi.SCRIPT_NAME#?start=#start+step#"><img
    src="/images/next_blue.png" alt="Next"
    align="absbottom"></a>
    </cfif>
    <cfif (start+step+step) lte queryResults.recordcount>
    <a
    href="#cgi.SCRIPT_NAME#?start=#queryResults.recordcount-step+1#"><img
    src="/images/end_blue.png" alt="End"
    align="absbottom"></a>
    </cfif>
    </p>
    </cfoutput>
    </cfif>
    <cfloop query="queryResults" startrow="#start#"
    maxrow="#start + step-1#">
    ...... output query here
    </cfloop>

    There is an example that does just this in the CF help
    look-up cfquery / example
    I've posted the example below
    Example
    <!--- This example shows the use of CreateTimeSpan with
    CFQUERY ------>
    <!--- to cache a record set. Define startrow and maxrows
    to ---->
    <!--- facilitate 'next N' style browsing. ---->
    <cfparam name="MaxRows" default="10">
    <cfparam name="StartRow" default="1">
    <!--------------------------------------------------------------------
    Query database for information if cached database information
    has
    not been updated in the last six hours; otherwise, use cached
    data.
    --------------------------------------------------------------------->
    <cfquery
    name="GetParks" datasource="cfdocexamples"
    cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#">
    SELECT PARKNAME, REGION, STATE
    FROM Parks
    ORDER BY ParkName, State
    </cfquery>
    <!--- Build HTML table to display query.
    ------------------------->
    <table cellpadding="1" cellspacing="1">
    <tr>
    <td bgcolor="f0f0f0">
    </td>
    <td bgcolor="f0f0f0">
    <b><i>Park Name</i></b>
    </td>
    <td bgcolor="f0f0f0">
    <b><i>Region</i></b>
    </td>
    <td bgcolor="f0f0f0">
    <b><i>State</i></b>
    </td>
    </tr>
    <!--- Output the query and define the startrow and maxrows
    parameters.
    Use the query variable CurrentCount to keep track of the row
    you
    are displaying. ------>
    <cfoutput query="GetParks" startrow="#StartRow#"
    maxrows="#MaxRows#">
    <tr>
    <td valign="top" bgcolor="ffffed">
    <b>#GetParks.CurrentRow#</b>
    </td>
    <td valign="top">
    <font size="-1">#ParkName#</font>
    </td>
    <td valign="top">
    <font size="-1">#Region#</font>
    </td>
    <td valign="top">
    <font size="-1">#State#</font>
    </td>
    </tr>
    </cfoutput>
    <!--- If the total number of records is less than or equal
    to the total number of rows, then offer a link to
    the same page, with the startrow value incremented by
    maxrows (in the case of this example, incremented by 10).
    --------->
    <tr>
    <td colspan="4">
    <cfif (StartRow + MaxRows) LTE GetParks.RecordCount>
    <cfoutput><a
    href="#CGI.SCRIPT_NAME#?startrow=#Evaluate(StartRow +
    MaxRows)#">
    See next #MaxRows# rows</a></cfoutput>
    </cfif>
    </td>
    </tr>
    </table>

  • On my itunes library my albums are all sorted but when  i put onto my ipod touch (4th Gen) it seems to duplicate i have checked everything and there are no spaces in the information my question is how do isort it because these things drive me mad

    on my itunes library my albums are all sorted but when  i put onto my ipod touch (4th Gen) it seems to duplicate i have checked everything and there are no spaces in the information my question is how do isort it because these things drive me mad i would be most gratefully if you could find a way to help
    thatnks

    Never mind, got it to work. I stumbled around on Google for a while and somehow ended up reading things from the 'jailbroken' community. They had easy instructions to get out of Recovery mode. Thanks anyway though!
    P.S. For anyone who experiences this, here is the fix: Hold Power and Home in unison for 6 seconds, then power on as normal.

  • I know this is a stupid question but can u put movies on thi 5G ipod?

    i know this is a stupid question but can u put movies on thi 5G ipod? like longest yard, anchor man, ect.
    Nano 4GB black,Moto RAZR V3 black, PSP, all kinds of cases for nano,radio/remote   Windows XP   <img src="http://i36.photobucket.com/albums/e13/superman5656/s.gif"align="right"</span>

    i dont have one yet i was just wondering i was thinking about it thanks
    Nano 4GB black,Moto RAZR V3 black, PSP, all kinds of cases for nano,radio/remote   Windows XP   <img src="http://i36.photobucket.com/albums/e13/superman5656/s.gif"align="right"</span>

  • My internal hard drive isn't being recognized on my macbook pro but when I put the HD in my Mac Pro (desktop), the desktop computer recognizes the HD.  When I insert the installer CD on my laptop, it also doesn't recognize my hard drive. Please help!

    My internal hard drive isn't being recognized on my macbook pro but when I put the HD in my Mac Pro (desktop), the desktop computer recognizes the HD.  When I insert the installer CD on my laptop, it also doesn't recognize my hard drive. Please help! Thank you!
    I've also been getting an image with the folder and question mark. I've tried everything on the apple support page but it doesn't seem to work either.

    Well, I tried all of your suggestions and they didn't work -- no surprise because I was trying to backup to my external c.d. disk.  Duh!  The application for the home is in the mail.

  • HT1386 How do I copy music from an old iPod?  Why do you have to make things so difficult?  These are my files that I paid for but once I put them on your devices, I no longer have control over them.  I've wasted so much time on these stupid problems.

    How do I copy music from an old iPod?  Why do you have to make things so difficult?  These are my files that I paid for but once I put them on your devices, I no longer have control over them.  I've wasted so much time on these stupid problems.  I used to be able to do this until you "improved" things.

    Thanks, Deggie. I thought Apple would see my feedback.  I would just like to know if there is a simple way to copy just a few music files from an old iPod.  I saw instructions on how to copy all of them from the iPod but it was complicated and I really didn't want to copy all the songs.  I guess I could delete all the songs but the ones I want to copy then go through that process again.  Do you know how to back up music to my computer?  I don't want to have to go through this again and possibly lose music.

  • Every time i get on my computer and click on imessage and facetime a little box pops  up saying an internal messages error occurred  or an internal facetime error occurred....but my question is how do i get it to stop doing this or how to stop it

    every time i get on my computer and click on imessage and facetime a little box pops  up saying an internal messages error occurred  or an internal facetime error occurred....but my question is how do i get it to stop doing this or how to stop it.

    For what it's worth, you posted this in 2011, and here in 2014 I am still having this same issue. Over the last two days, I have had to unlock my apple account 8 times. I didn't get any new devices. I haven't initiated a password reset. I didn't forget my password. I set up two factor authentication and have been able to do the unlocking with the key and using a code sent to one of my devices. 
    That all works.
    It's this having to unlock my account every time I go to use any of my devices. And I have many: iMac, iPad, iPad2, iPad mini, iPhone 5s, iPod touch (daughter), and my old iPhone 4 being used as an ipod touch now.  They are all synced, and all was working just fine.
    I have initiated an incident with Apple (again) but I know they are just going to suggest I change my Apple ID. It's a simple one, and one that I am sure others think is theirs. I don't want to change it. I shouldn't have to. Apple should be able to tell me who is trying to use it, or at least from where.
    Thanks for listening,
    Melissa

  • Keeps asking me how to pay but I already put my Itunes card code in

    I don't know why its doing this. It keeps saying I need to find a payment method when I go to buy something but I just put money on my Itunes account via Itunes card. HELP.

    Easy call applecare, they can reset your security questions once your account has been verified.
    1-800-692-7753
    There is no charge for this service.
    Once your verified, make sure you have a computer avail to access appleid.apple.com during the call.
    <edited by host>

  • I recently started to have this problem, I can view videos on youtube without any problems, but if I put a link lets say on FB, I cant view the video

    I recently started to have this problem, I can view videos on youtube without any problems, but if I put a link lets say on FB, I cant view the video I can only hear the sound, its like, there even the buttons, only invisible, yet still clickable, so if I manage to find and click the full-screen button the video switch to full-screen and I can view it. this is really annoying as I cant see flash animations and some videos at all.

    You need to find out what type of video it is.  What your describing is what you get when a Video codec (software that allows you to "see" the video) is missing, damaged, or too old for the movie.
    Once you identify what kind of movie it is, then you can update the codec.

  • My Iphone 5 voice speaker is not working.I'm not able to hear the voice of the person calling.But when I put my iphone 5 on speaker mode, things seem ok.Please provide me some suggestions.

    My Iphone 5 voice speaker is not working.I'm not able to hear the voice of the person calling.But when I put my iphone 5 on speaker mode, things seem ok.Please provide me some suggestions.

    Hello rizvijunaid,
    Thank you for providing the details of the issue you are experiencing with calls on your iPhone.  I recommend following the steps in the article below for the issue you described:
    iPhone: Receiver and call audio quality issues
    http://support.apple.com/kb/ts5196
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • I am using chat-r wireless and facetime is not working but when i put rogers fido or any other carrier sim in it work. Anyone know what the problem?

    I am using chat-r wireless and facetime is not working but when i put rogers fido or any other carrier sim in it work. Anyone know what the problem?

    I'm guessing it's a compatibility problem similar to that that T-Mobile in the US has. I'm not familiar with chat-r wireless, but I'm guessing it's not a supported carrier for the iPhone. If they can't tell you how to fix it, I'm guessing it's just plain not going to work.

  • I want to play a song I bought but when I press play it says I need to authorize my PC but when I  put in my Apple ID it says its already authorized. What should I do to be able to play the song?

    I want to play a song I bought but when I press play it says I need to authorize my PC but when I  put in my Apple ID it says its already authorized. What should I do to be able to play the song?

    Delete and redownload it if doing so is free in your country.
    (94038)

  • I'm new using Logic, i've been using garageband for quite awhile now though but my question is just basic. When i want to record electric guitar while clicking the software option it brings me to alot of guitar sounds that i want to chose. I chose the twa

    I'm new using Logic, i've been using garageband for quite awhile now though but my question is just basic. When i want to record electric guitar while clicking the software option it brings me to alot of guitar sounds that i want to chose. I chose the twangy electric or the distorted strat but i only hear clean sounds. No matter what kind of guitar sound i chose in the library it only produces clean guitar. How can i make it sound like it supposed to? Did i miss something i should do?

    This definitely has me stumped as I'm unsure as to why your guitar can be heard, but with none of the channel strips plugins applied to the sound.
    On the record enabled channel strip that contains your guitar input, is the "I" button located near the "R" active? Also, if you record your guitar, can you hear the FX applied to it when you play back the recorded track?

  • I have an I pad 2 . I have put things for sale on Craigslist but I cannot put pictures on the ad. Is there an app or so etching I need to be able to load the pictures to the ad. I also have an I phone4s same thing with it. Appreciate any info. Thanks iPad

    I have an I pad 2 . I have put things for sale on Craigslist but I cannot put pictures on the ad. Is there an app or something I need to be able to load the pictures to the ad. I also have an I phone4s same thing with it. Appreciate any info. Thanks iPad

    Yes there is; http://itunes.apple.com/app/+craigslist+/id373576667?alreadyRedirected=1&mt=8

Maybe you are looking for

  • Why isn't ratings information set in lightroom showing up in windows explorer file properties?

    I am using Lightroom 3.4 64 bit on Windows7 64 bit.  When I apply keywords and set a rating in lightroom, only the keywords show up in the file properties in windows explorer, and FastStone viewer.  The ratings information is not shown.  Is this a kn

  • How to cancel an edit to an iCal event with attendees

    I keep running into this-- - Open an existing event with attendees - Make an edit of some kind - Change your mind - Forget what changes you made and/or not wish to let everyone already invited know that iCal is sometimes as crappy as Outlook. - Only

  • Distorted songs on burned DVD

    I created some movies in iMovie using still photos from iPhoto, and added songs from iTunes. Then I burned a DVD using iDVD. Playing this DVD on my Panasonic DVD player and TV, some, not all, of the songs are distorted. Everything sounds just fine on

  • Scaled Price in MDM Catalog

    Dear MDM Experts, What is the method to create scaled price for an item in MDM? For Example if you buy 1 pc of pen = 1€/pcs; if you buy 10 pcs the price is just 0,98€/pcs; if you by 100 or more, the price is 0,95€/pcs. In CCM it can be solved, is it

  • Where do i find my apple id password on my computer

    i am trying to identfy my apple id password - where is it saved? and where do i find it? thanks