How to use Toolkit.prepareImage()??

hey,
I was wondering how to use the prepareImage() method in the Toolkit class. So far i've been using the method just before I paint an image to the screen. Is there any better usage for it. Is my way slowing the painting proccess down?
here's some sample code
Image image;
Toolkit tk;
public void paint(Graphics g){
        tk.prepareImage(image, 32, 32);
        g.drawImage(image, 0, 0, this);
}Thanks,
Bluelikeu

Do you really want to load the images asynchronously or are you willing to wait?
If you can wait, javax.imageio.ImageIO is a simpler way to load images.
And even if you load in a seperate thread, you can do it with ImageIO:
import java.awt.*;
import java.io.*;
import java.net.URL;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.border.*;
public class BackgroundBorderExample {
    public static void main(String[] args) throws IOException {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JFrame f = new JFrame("BackgroundBorderExample");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JTextArea area = new JTextArea(24,80);
        area.setForeground(Color.WHITE);
        area.setOpaque(false);
        area.read(new FileReader(new File("BackgroundBorderExample.java")), null);
        final JScrollPane sp = new JScrollPane(area);
        sp.setBackground(Color.BLACK);
        sp.getViewport().setOpaque(false);
        f.getContentPane().add(sp);
        f.setSize(600,400);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
        String url = "http://today.java.net/jag/bio/JagHeadshot.jpg";
        final Border bkgrnd = new CentredBackgroundBorder(ImageIO.read(new URL(url)));
        Runnable r = new Runnable() {
            public void run() {
                sp.setViewportBorder(bkgrnd);
                sp.repaint();
        SwingUtilities.invokeLater(r);
import java.awt.*;
import java.awt.image.*;
import javax.swing.border.*;
public class CentredBackgroundBorder implements Border {
    private final BufferedImage image;
    public CentredBackgroundBorder(BufferedImage image) {
        this.image = image;
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        int x0 = x + (width-image.getWidth())/2;
        int y0 = y + (height-image.getHeight())/2;
        g. drawImage(image, x0, y0, null);
    public Insets getBorderInsets(Component c) {
        return new Insets(0,0,0,0);
    public boolean isBorderOpaque() {
        return true;
}Warning: explicit image!

Similar Messages

  • How to use Toolkit.getDefaultToolkit().getImage in JPanel in Java Swing

    Hi Sir,
    I want to know how to use Toolkit.getDefaultToolkit.getImage()
    in JPanel (ie) the class that extends the JPanel.There is no problem to include the Toolkit.getDefaultToolkit.getImage()in JFrame.It is displaying it without any problem.But in JPanel it is showing a problem of cannot resolve symbol.Here i can't use JFrame instead of
    JPanel.So how to solve the problem.Pls.do send the code of how to do this.It is Urgent.
    Thanx,
    M.Ananthu

    you use Toolkit.getDefaultToolkit.getImage() in a JPanel exactly the same way you do in a JFrame.
    You are getting a compile message "cannot resolve symbol". You have made a programming error and since you have not included code there is no way to guess what you did wrong.

  • How to tell if an Image is loaded using Toolkit.getImage()

    If I use Toolkit.getImage(url) it always returns an Image object, no matter if the image located at that url is a correct image or not.
    The w/h is always -1, -1 right after loading (since it hasn't been loaded completely of course).
    Anyone know how I can tell if a correct image is loaded or not, without adding a MediaTracker?

    Why don't you want to use a MediaTracker? It is by far the most convenient way to do what you want to do.
    Huw

  • How to use Real time execution trace toolkit with Dual-core processor??

    hi there
    the situation as follows:
    i have a computer (PC and Laptop) types with Dual-core processors, and am trying to do simulation using Multi-core technology and based on different simulation scenarios...starting from sequantial processing,.......Piple lining processing strategy. so that i can differentiate the time delay between those types of processing based on (Using 1 processor then dual-core processor Computers)
    my question is: As i read through Ni's white papers i saw many notes refer to Real-time execution trace toolkit to investigate the (processing-time , etc) of multi-core processors in processing diffenent algorithms. My algorithms are to be run on 1 computer with dual-core processor BUT, not in real time environments, that is ( No hardware to be connected to my pc) only algorithms running on my pc....
    So, is it possible to use Real time execution trace toolkit  or anyother tools in LabVIEW to show processing-delays and/or anyother timing critical issues without using my application for  real- time hardware.???
    in other words: how to use Real time execution trace toolkit  in non-hardware and/or real-time scenarios???
    please help me in this.
    Any suggestion, comments, feedback.....is absolutely highly appreciated
    thanks a lot in advance
    Labview Lover

    Hey,
    The Realtime Execution Trace Toolkit only works for NI RT Targets.
    But you can use the Desktop Execution Trace Toolkit, just search for it under ni.com.
    Christian

  • How to use assert with wireless toolkit?

    Hi,
    I am trying to find out how to use assert with wireless toolkit. I have found that I need to pass "-source 1.4" to the java compiler. But I can't find any documentation on how to do it.
    I'm using J2ME Wireless Toolkit 2.2.
    thanks
    Ludde

    Here's a quote from an article on Java World at http://www.javaworld.com/javaworld/jw-11-2001/jw-1109-assert.html
    "To support the new assertion facility in J2SE 1.4, the Java platform adds the keyword assert to the language, an AssertionError class, and a few additional methods to java.lang.ClassLoader."
    So I really think it's part of 1.4.

  • MAP Toolkit - How to use this MAP tool kit for all SQL Server inventory in new work enviornment

    Hi Every one
     Just joined to new job and planning to do Inventory for whole environment so I can get list of all SQL Server installed . I downloaded MAP tool kit just now. So looking for step by step information to use this for SQL Inventory. If anyone have documentation
    or screen shot and can share would be great.
    Also like to run It will be good to run this tool anytime or should run in night time when is less activity? 
    Hoe long generally takes for medium size environment where server count is about 30 ( Dev/Staging/Prod)
    Also any scripts that will give detailed information would be great too..
    Thank you 
    Please Mark As Answer if it is helpful. \\Aim To Inspire Rather to Teach A.Shah

    Hi Logicinisde,
    According to your description, since the issue regards Microsoft Assessment and Planning Solution Accelerator. I suggestion you post the question in the Solution Accelerators forums at
    http://social.technet.microsoft.com/Forums/en-US/map/threads/ . It is appropriate and more experts will assist you.
    The Microsoft Assessment and Planning (MAP) Toolkit is an agentless inventory, assessment, and reporting tool that can securely assess IT environments for various platform migrations. You can use MAP as part of a comprehensive process for planning and migrating
    legacy database to SQL Server instances.
    There is more information about how to use MAP Tool–Microsoft Assessment and Planning toolkit, you can review the following articles.
    http://blogs.technet.com/b/meamcs/archive/2012/09/24/how-to-use-map-tool-microsoft-assessment-and-planning-toolkit.aspx
    Microsoft Assessment and Planning Toolkit - Technical FAQ:
    http://ochoco.blogspot.in/2009/02/microsoft-assessment-and-planning.html
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How tu use or install package API Toolkit BPC

    Dear All,,,
    I have problem with performance SAP BPC, then i read SAP Note from SAP Support Portal. In that document, there are download API toolkit. I don't understand how to use this file (API Toolkit)...??
    Any Idea..??
    Thanks...
    Dharma Setiadi

    The reflow plug-in is installed by default when you install Reader. In order for it to work optimally, the document should be correctly tagged, which is something you can do in Acrobat. To activate Reflow in Reader X, select: View > Zoom > Reflow

  • How to use get column name.vi in SQL toolkit 2.0?

    Due to the vi "get column name.vi" paremeters,no table name has connected to the vi. So, I want to ask how to use this vi for gain one column name of a table. Maybe there are some other ways to solve column name getting.
    Thanks.

    Thanks!
    Error 4101 Description:
    Execute SQL - The connection, statement, or query handle you provided is not valid.
    I don't just used the toolkit in a while,now, I am developing a irrigation system. For the table field names defined by users,column names must be known before any select operations. Do you have any other good idea about drawing out the columnname parameters?
    As you know, a valid DSN and table have been also available. The database I used is Access. The bad thing to me is that there is no any text information gotten. And I think, it may be some problems in connection way which I don't find out.
    Really appreciated by your reply.
    Could you give me some example in the aspect?
    Thank you again.

  • How to use TCP Checksum Off-load in my network driver

    I am seeking infomation on how to use TCP Checksum Off-load to tell the Solaris 8 stack not to handle it for both receives and transmits (and let our NIC handle this compute-intensive task instead).
    There is mention that Sun GigabitEthernet Adapter cards, Release 1.1 supports Sol-2.6 use of NIC features: TCP checksum offload & byte swapping
    There are limited bits of info in include files. For example
    sys/strick.h indicates use of:
    inetcksum_t's ick_xmit
    stream.h has:
    struct datab's unsigned u16:16; /* used to store hw-calculated cksum
    #define STRUIO_IP 0x04 /* IP checksum stored in db_struioun */
    #define STRUIO_ZC 0x08 /* mblk eligible for zero-copy */
    strsub.h has:
    struct zero_copy_kstat
    Also /include/inet/tcp.h has tcp_sum for outbound.
    Thank you. -Weimin Tchen

    VenK7337,
    Could you show your python code. so we know what your are "writing" to the ethernet port?
    That way we can see what you are receiving.
    Parsing the incoming data (from the TCP-read) depends heavily on the device that sends it, and can not generically be described. LabVIEW has many byte (and even bit) manipulation functions to convert many different data formats to its own build in formats.
    So after the TCP listener is connected, you are constantly reading from the established connection (until it gets broken of course). More advanced example would be the internet toolkit if oyu have it.
    From the read characters (and I hope you designed a protocol with a clear starting character, ending character and maybe even a build in checksum) you parse the data and perform you action, and of course generate a reply. Again the internet toolkit is a good example. It parsed the input as it comes it, based on the HTTP format. Then generates the reply based on the request received.
    These days I would suggest not to use binairy encoded numerics. Try and use XML formatted data. Yes, it causes a lot of overhead. But typically this is not an issue and makes the code a lot more portable and maintainable. Also makes it easier to interface with other languages/platforms.
    Umless of course you are looking at Khz data rates, then XML is not th preferred choice.
    Hope this helps...

  • How to use ActiveX to open/write to Excel template but not to overwrite it

    Hi there again (it's me...if anyone recognised me...)
    I managed to use ActiveX to open Excel and make it visible onto the screen. But I would like to know how can I make Excel open an Excel template and let me write data to the cells without overwriting the original template. I did try to use another program source such as the EXCEL TOOLKIT but I can't still figure out how does it work for my case. Is there a simpler example for me to refer too? Please help.
    Thank you,
    juni

    Hi Mike..
    I have tried to use the examples provided LabView 6.0. I don't understand how to use the Range value to get the data from my global array and also how to open the template and write data to it.
    At the moment, I could only open a saved dialog box and a default string filename is used to save my data into a new Excel but not the formatted excel which I want.
    If possible, please help again. Vi attached.
    Attachments:
    savefile.vi ‏109 KB
    datarecords.vi ‏12 KB

  • How to use customize mouse cursor?

    Hello everyone
    i want to use my own pictures as the mouse cursor. How can I make it?
    Thank you

    Try using ToolKit.getDefaultToolKit().createCustomCursor() as a first step.

  • How to use notifier

    Hello,
    I will try to creat extention for photoshop in Flash Builder 4  using CS Extention Toolkit 3.4.
    For automatic or something happen, i think we have to used notifier but i do't no how to used it and  where i have to code that thing.
    Or any other thing used for automation?
    Thanks
    Matt Forman

    I think I have got it working.  Check out the new snapshot to see what I changed.
    Attachments:
    SetNotificationNew.jpg ‏85 KB

  • How to Use Ajax Framework with Netbean6.0

    Hello Friends....
    I am using netbeans IDE to develop Java enabled web application
    now i want to use ajax technology in my webapp.
    So how can i use ajax with netbeans.
    I add Jmaki plugins in netbeans and i got various jmaki component but i dont know how to use them.....!
    Please somebody help me.........

    vasim_saiyad2000 wrote:
    Yes My Friend in the past i made a web application and all html, jsp and java code was written in notepad.
    I want that how to use ajax with java. IDE does not matter i wrote about netbeans because now i am very good aware of netbeans and i am using netbeans ide to develop my app.
    You just tell me how to use ajax with java like .net has some ajax toolkit in its palette..
    How can we use same thing in java /netbeans.Uh, look for a plugin which does that? Or, better, just write code yourself inside Netbeans.
    Can u tell one most import thing .......Suppose when user log in i have created session.
    Suppose user does not logout manually by clicking LOGOUT link its close directly browser so can be I sure that session may have been expired......!
    Please solve my this doubt.....!Implement HttpSessionListener and do the desired task in sessionDestroyed() method.

  • How to use the XYBubbleRenderer

    I have found in the JFreeChart api that there is a method for turning data points into a bubble via the XYBubbleRenderer. How ever i do not know how to use this renderer effectively. It says the z value determines the size of the bubble. Does any body know how to use this renderer and if how? If this is not the best method to do this, could some body please guide me to the correct way please.
    Cellze

    I have had a similar problem and I share your pain.  The support for serial numbers in UCS is not great.  What's worse is that the Cisco Customer Service Centre (CSCC) are absolutely clueless about UCS so they will close requests where you quote the vendor serial number, as being invalid, and then try to tell you that what you have quoted isn't a UCS component.
    For example, I've been trying to get the serial numbers of my two CPUs updated for over 2 months with CSCC (due to a DOA RMA).  CSCC have no idea what to do and continually close cases relating to this request stating that the chassis serial number is right, ignoring that it's the CPU serial numbers which I keep asking for that need to be updated.  Compounding that, the CPU serial numbers aren't accessible in CIMC unless I dismantle the server and actually pull the CPUs out to examine them.
    I just hope that I don't need to ever have a CPU replaced one day, as none of the serial numbers will match when it happens.
    What would be really useful is if there was an enhancement request in Bug Toolkit to gather all the correct details in UCS, much like there is in IOS ("show inv") for routers and switches.

  • How to use cgi directly in FP 2000?

    I want to build a Web Server that includes using CGI
    in FP 2000.However, i don't want to include any VI when I use the CGI. One reason is the memory of the FP 2000 is not enough to add more VI. Can anyone tell me how to use CGI in FP 2000 directly? Thank you for your help.

    Hello,
    What you are trying to do is not a supported feature. The Internet Toolkit and the G Web Server for LabVIEW was developed and tested for its use under Windows only. R&D has not tested it running on an RT target. You might be able to load and start the G Web Server on RT, however there might be some files that you need to copy to get it to work.
    The G Web Server is what you should try to use. The server comes with the Internet Toolkit. There is no way to use CGI directly with FieldPoint without the G Web Server. I am not sure what you mean about not including any VI when using CGI. There is lots of information here about the Internet Toolkit http://www.ni.com/support/labview/toolkits/
    internet/. Once it is installed there is lots of documentation that comes with it.
    Good luck with developing your application.
    Jared A

Maybe you are looking for

  • How to retrieve resources from a jar file ?

    Hello, Currently, I have application classes in a jar file, and all other resources (pictures, properties, and so forth..) in my windows folder. I do not have any problem for using them such way. For example to set an icon to a JFrame I have coded :

  • Displaying WebI report parts via openDocument in BI 4.1 SP 3 Update

    1) We are using SAP BO 4.1 SP3 Update version. 2) We have a requirement to display PARTS of webi report which has prompts as well. 3) We referred the Opendocument PDF and used the below functionality to get what we need: sRefresh=Y&mode=part&sReportP

  • High Level Bin Search, before Storage Type Search

    Hi, Can anyone help me to guide, which user Exit/Badi, be used for searching Empty bins, before storage type search. I come to know from one of colleague below message. "" if you want to check the quantities on a higher level (before storage type sea

  • Outline stroke command?

    I'm making an extension panel, and I want to convert some fat roundendcapped lines to paths, but it seems there's no command for this in the SDK. Object -> Path -> Outline stroke Is it true? If so, do you know a workaround for this? I made an Action

  • UDF on linux box

    Hi, Ive tried using UDF on windows box successfully. but while trying to replicate the same on linux box iam facing certain issues. I am trying to load the string functions that i downloaded from oracle network. made changes to udf.policy and added g