How can one optimize Swing

How come i wrote a simple code extending JPanel as shown belo trying to render a new component but realized the running code was consuming like 88% of the processor time, using windows task manager. Is there a way to help swing eat less memory and processor time
import java.awt.*;
import javax.swing.*;
public class CustomP extends JPanel{
public void paintComponent(Graphics g)
super.paintComponent(g);
//some g.drawXXX dumps here
repaint();
//CustomB.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CustomB extends JFrame{
private CustomP bpanel;
public CustomB()
super("New Button");
bpanel = new CustomP();
Container c = getContentPane();
c.add(bpanel,BorderLayout.CENTER);
setSize(90,90);
show();
public static void main(String args[]){
CustomB newb = new CustomB();
newb.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){System.exit(0);}
}Lastly, i am trying to create my own look and feel or say new button by rendering a gif image on a panel with Graphics g object in paintComponent(g) and then attaching events to it, is it advisible to create new components like that?

uhm. crosspost
http://forum.java.sun.com/thread.jsp?forum=31&thread=390432&tstart=0&trange=15

Similar Messages

  • How can one optimize Swing-Answer this one

    How come i wrote a simple code extending JPanel as shown belo trying to render a new component but realized the running code was consuming like 88% of the processor time, using windows task manager. Is there a way to help swing eat less memory and processor time?
    Lastly, i am trying to create my own look and feel or say new button by rendering a gif image on a panel with Graphics g object in paintComponent(g) and then attaching events to it, is it advisible to create new components like that?
    import java.awt.*;
    import javax.swing.*;
    public class CustomP extends JPanel{
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    //some g.drawXXX dumps here
    repaint();
    //CustomB.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class CustomB extends JFrame{
    private CustomP bpanel;
    public CustomB()
    super("New Button");
    bpanel = new CustomP();
    Container c = getContentPane();
    c.add(bpanel,BorderLayout.CENTER);
    setSize(90,90);
    show();
    public static void main(String args[]){
    CustomB newb = new CustomB();
    newb.addWindowListener(
    new WindowAdapter(){
    public void windowClosing(WindowEvent e){System.exit(0);}

    http://forum.java.sun.com/thread.jsp?forum=31&thread=390432&tstart=0&trange=15
    crosspost!!!!!!!

  • Regarding iMessage, when i want to send text to a person in my contacts app, i've been getting a message saying the number has not been registered with iMessage.  How can one fix this problem?

    Regarding iMessage, when i want to send text to a person in my contacts app, i've been getting a message saying the number has not been registered with iMessage.  How can one fix this problem?  It works on the iPhone.

    It takes two to tango, maybe it's your recipient that has weak Internet/Cellular connections.

  • I have lost my phone IMEI  Number 012546005322381, Serial Number 87******A4S, is there a way it can be tracked? Also, how can one remove the device from the itunes account

    I have lost my phone IMEI  Number 012546005322381, Serial Number 87******A4S, is there a way it can be tracked? Also, how can one remove the device from the itunes account
    <Serial Number Edited By Host>

    If you enabled Find my iPhone then you should use that. If not, I'm afraid you're out of luck for finding it. 
    To manage your devices, go to Your Account in iTunes.

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • How can One sender communication channel pick two file from two location

    Hello
    I have a requirement that how can One sender communication channel pick two file from two location.Both the file has same name...How to configure the one receiver communication channel.i dont have any IR,no mapping..Please help me...

    >
    Soumitra Sinha wrote:
    > Hello Vijay
    > I already done the adapter specific message attribute.i am getting the file name properly.but that is nothing to do with my req.i am again clearing my problem:
    > i have two folder   folder a,folder b.Both has the same file credit0002. i have two destination folder i have one sender and one receiver channel.I dont have any IR.How one sender channel can  pick file from two location and how one receiver channel can put in two location.please help me..
    Ok now I get your requirement.
    you cant achieve this -  how one receiver channel can put in two location if you dont have a dynamic configuration defined i.e Adapter specific attributes.
    easy way - involve IR mapping
    else
    have a adapter module to define your dynamic configuration.
    Ref: /people/daniel.graversen/blog/2006/10/05/dynamic-configuration-in-adapter-modules & /people/michal.krawczyk2/blog/2006/10/09/xi-dynamic-configuration-in-adapter-modules--one-step-further
    Set the dynamic directory/file name etc for your receiver adapter.

  • How can one find out how much hard drive space the apps and media are using?

    how can one find out how much hard drive space the apps and media are using?

    See Here  >  Where did my Disk Space go?
    And Here  >  The Storage Display

  • How can one send email-sized photo files as attachments in Mail, without the photos appearing within the email?s

    How can one send email-sized photo files as attachments in Apple Mail, without the photos appearing in the body of the email?  If it can be done, it's not at all obvious, at least not to me.  Thanks for any help you can provide.

    The "View as icon" option shrinks the photo to an icon in the sender's Apple Mail, but how it appears to the recipient varies dependingy on what e-mail client he/she uses.
    Using Apple Mail 5.0 (the Lion version) at both ends, the sender can use the "View as icon" option to shrink his view of the photo to an icon, but the recipient also using Apple Mail 5.0 still sees the full photo in line with the message text. The recipient can then use the "View as icon" option to shrink it to an icon, but I don't think that's not what jackofarabia is looking for.
    As far as I know there is no way in the current Apple Mail to do what jackofarabia wants. There should be, but there isn't.

  • How can one use Mission Control with two monitors?  Please bring Spaces back

    How can one use Mission Control with two monitors.  With Spaces I could treat each space as a single desktop.
    SyBB

    I use two monitors at work and have no issue. I have my mail set to use Desktop 1 and iTunes set to the second monitor of Desktop 1. I have browsers set to Desktop 2 and Fusion and RDC set to Desktop 3.
    Two things that may help you. In System Preferences > Mission Control, disable the setting "Automatically rearrange spaces...". This screwed with assigning applications to certain spaces. And the other thing is don't use full screen on apps that support it. This just makes your second monitor superfluous.

  • How can one accept that the only way to sync with OSX 10.9 is through I cloud?

    How can one accept that the only way to sync with OSX 10.9 is through I cloud?
    One is now obliged to send private information to an external server...

    Thank you for the link but what a waist of time.
    Who is the idiot that decided to drop manual syncing of contacts and calendars?
    I am on the point of dropping all APPLE machines!
    I am looking to sync without having to worry about security issues, keeping my files and passwords locally on my machines, and not an external server such as a cloud drive.
    Do you know if Outlook syncs also over an external server?
    Do you know of this solution? http://www.codetwo.com/public-folders/share-windows-files-securely/

  • Imac frozen at blue screen after i went into disk utilities and cleaned my free space. I tried holding down T key as it reboots and i get a message. Start up disk full empty it how can one emptie it if you cant get past the blue screen

    Imac frozen at blue screen after i went into disk utilities and cleaned  free space.
    I tried holding down T key as it reboots
    and i get a message. Start up disk full empty it how can one emptie it if you cant get past the blue screen?
    to make matters worse we bought the IMAC of amazon uk on the 4/07/011 so what can we do?
    please remember how frustrating it is when asking for help when the helper telling you to type something on the screen when its frozen
    Tell us when you can type some instuctions to the software how do you get to the doss prompt so to speak to do this
    Thanks

    i tried all this thanks
    i can not get past blue screen and message Your disk is full it needs to be emptied Please not I cant proceed past this message.
    no matter what you tell me
    Am i right ok in thinking that
    when i went into disk utilities and chose to clean my free space i left it over one hour to do its stuff
    i came back and there was no progress bar just the box so i quit the program and when i opened  mac mail the system just froze  i forced quit mail rebooted and blue screen death
    Now when free space is being cleaned is it the same as windows dose the utility write lots of 0 on the hard drive then rebbot its self to free the space
    basicly is my hard drive full of 00000  is this why im getting this message  because the process was interupted
    I need to know if i need outside help i bought the computer on line on  amazon uk  what dose one do next

  • How can one transfer emails and contacts from Zimbra to gmail, without it being deleted if the Zimbra account is shut down?

    How can one move Zimbra Contact list and emails to a gmail account, so they won't be deleted if the Zimbra account is shut down?

    What does this have to do with iPhones or anything else Apple related.  Contact Zimbra and ask them...

  • MTO --- How can one verify costs are tracked at sales order level

    PP members:
    In MTO -- costs are tracked at sales order level, how can one verify that costs are tracked at sales order level
    Are there any settings/fields in master data to look into for <b>identifying costs at sales order level</b>,
    Thanks for your time

    Hi suren,
    on the top you will see "sales document" "edit" "goto" and then you have "extras".
    On the dropdown you will see "costing".
    Regards,
    Satyajit

  • How can one create a paint color generated from a photo using Kuler?

    How can one create a paint color generated from a photo using Kuler?

    The best way to remove a pattern is to use a Fast Fourier Transform.  There's a free plugin (as well as examples and instructions) here:
    http://dl.dropboxusercontent.com/u/6795661/4N6site/improc/fftplugin/examples.htm
    Using the plugin requires editing the individual colour channels, which PSE does not natively allow.  You'll need the reasonably-priced Elements+ addin:
    http://elementsplus.net/
    Here's a crop at 100% of the result I got:
    The pattern is much reduced.  With some experimenting, you can probably do a little better.
    Ken

  • How can one edit a profile name in ACR?

    Both Adobe DNG Profile Utility and the PassPort profile software very nicely create and install profiles in ACR.  A profile name is given at the time of creation. Once installed in ACR, however, how can one edit the name of the profile?
    thanks, grampus45

    http://forums.adobe.com/message/3158961#3158961

Maybe you are looking for

  • Ipod Shuffle STRANGE problem

    Hi: There is something strange with my shuffle, the first time when I bought it apparently it was working fine on my computer, but later when I was trying to add more music, I began to have problems. First, there was an orange flashing light on it an

  • How to use Role Menu item in BI 7.0

    Hi experts, From web applications desiger in version 3.5 we can use Role Menu item to access our querys easily. In version 7.0 this item has been deleted from standard items. How can we manage it ? Thanks a lot Best regards, Santi

  • The system cannot find the file -DRCU_HOME

    Hi, WHile running RCU for Oracle Data Integrator, I am getting the above error. I checked and the file exists. So not sure why this error happens. any help is really appreciated. Thanks Amit

  • Why are my actions no longer working?

    I can't understand, trace, or figure out why (haven't made any significant changes lately to my system, app, etc.), but my PSD actions (specifically, ones from PSDCovers.com to do book mockups) are no longer working. When I run Step 2 of the action,

  • SERIAL NUMBER EMAIL

    Using the student and teacher edition of Lightroom.  I have been able to check the status, and it was approved, however never received the email regarding the serial number.