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!!!!!!!

Similar Messages

  • 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.

  • In Mail, one mailbox for Recovered Message (AOL) keeps showing 1 very large message that I cannot delete. How can I get rid of this recurring problem, please?

    In Mail on iMac, successfully running OS X Lion, one mailbox on My Mac for "Recovered Messages (from AOL)" keeps showing 1 very large message (more than 20 Mb) that I just cannot seem to delete. Each time I go into my In Box, the "loading" symbol spins and the message appears in the "Recovered Messages" mailbox. How can I get rid of this recurrent file, please?
    At the same time, I'm not receviving any new mails in my In Box, although, if I look at the same account on my MacBook Pro, I can indeed see the incoming mails (but on that machine I do not have the "recovery" problem).
    The help of a clear-thinking Apple fan would be greatly appreciated.
    Many thanks.
    From Ian in Paris, France

    Ian
    I worked it out.
    Unhide your hidden files ( I used a widget from http://www.apple.com/downloads/dashboard/developer/hiddenfiles.html)
    Go to your HD.
    Go to Users.
    Go to your House (home)
    there should be a hidden Library folder there (it will be transparent)
    Go to Mail in this folder
    The next folder ( for me ) is V2
    Click on that and the next one will be a whole list of your mail servers, and one folder called Mailboxes
    Click on that and there should be a folder called recovered messages (server) . mbox
    Click on that there a random numbered/lettered folder -> data
    In that data folder is a list of random numbered folders (i.e a folder called 2, one called 9 etc) and in EACH of these, another numbered folder, and then a folder called messages.
    In the messages folder delete all of the ebmx (I think that's what they were from memory, sorry I forgot as I already deleted my trash after my golden moment).
    This was GOLDEN for me. Reason being, when I went to delete my "recovered file" in mail, it would give me an error message " cannot delete 2500 files". I knew it was only 1 file so this was weird. Why 2500 files? Because if you click on the ebmx files like I did, hey presto, it turned out that they were ALL THE SAME MESSAGE = 2500 times. In each of those folders in the random numbers, in their related message folder.
    Now remember - DONT delete the folder, make sure you have gone to the message folder, found all those pesky ebmx files and deleted THOSE, not the folder.
    It worked for me. No restarting or anything. And recovered file. GONE.
    Started receiving and syncing mail again. Woohoo.
    Best wishes.

  • HT4623 How can I get rid of this new update and go back to the previous one and how can I register a complaint with Apple?

    How can I get rid of this new 7.0.2 update and go back to the previous one and how can I register a complaint with Apple?

    You can't go back.
    You can leave feedback: http://www.apple.com/feedback

  • I have problem with my iphone 4s my battery is not keeping charge. how can I get help with this one. it is less than a year that I purchased this cell.

    I have problem with my iphone 4s my battery is not keeping charge. how can I get help with this one? it is less than a year that I purchased this cell.

    I would like to know the answer to that one.  I realized this was happening just after upgradeing my iOS to 6.  Then when I looked up my purchase date, I was about 5 days past my one year warranty.  So I'm dead in the water.  Apple will replace the battery, but it will be about $80+.  I took it to the Apple store, and they checked a bunch of stuff, but said that it seemed ok.  I'm debating getting a battery for a more reasonable price off of ebay.  But if it's the iOS thats draining the battery, then I'm not going to be able to help it.  I wish I knew a better way to tell if its the battery, the phone, or the iOS.

  • Hi. I have an iPhone and a Mac,and my sister has iPad2 and iPhone also.we both use a pc to sync our devices and use one App ID in our devices.but we want to use personal iCloud to achieve our personal files.how can I use iCloud in this situation?

    Hi. I have an iPhone and a Mac,and my sister has iPad2 and iPhone also.we both use a pc to sync our devices and use one App ID in our devices.but we want to use personal iCloud to achieve our personal files.how can I use iCloud in this situation?

    You will need to setup a new Apple ID for your sister.  You have to have an Apple ID and iDevice connected and using that account to get an iCloud account.

  • HT5129 How can one stop this annoying MobileMe notice from appearing every time iPhoto is opened?

    How can one stop the annoying MobileMe notice from appearing every time iPhoto is opened?

    Well then you can not remove something that obviously has been removed
    Did you remove the references in the iPhoto preferences?  Did this eliminate the problem?  If so then you are done and your problem has been
    N resolved.
    LN

  • How can one develop "view only" client applications in Lookout?This is to develop remote monitoring without control functionality.

    How can one develop "view only" client applications in Lookout?This is to develop remote monitoring without control functionality.
    We have 10 Client Nodes in the field and we need two "View Only" functionality in Client machines located on Supervisory Desks.

    I have done this. There are many ways to approach this but I will offer what I think is the easiest. This will work ONLY if you have been assigning security levels to your objects (objects that actually control devices in the field) greater than zero AND allowing a security level of zero to view all panels. When I develop interfaces I do this just for creating a non control client.
    Basically, you remove all users from the Lookout client in the user manager. You will not be able to remove the built-ins, "Guest" and "Administrator". Now when the end users tries to login using his normal login he will be denied. Consequently, he will not be able to control. But, he will still be able to view all the information since a no login can view a panel with a viewing se
    curity level of zero. You must ensure any pushbuttons that are used to open panels have a security level of zero.
    Now you can copy this security profile by finding the lookout.sec file and copying it to another non-control client computer. In Windows NT this file is located in the system32 directory.
    There are many other ways but I find this the easiest.
    Regards,
    Tommy Scharmann

  • HT5312 I forgot the answers to my security questions and the e-mail where apple is sending the answers is no longer accessible, how can I get the answers to be sent to one of my current mails? Thank you

    I forgot the answers to my security questions and the e-mail where the replies are being answered is no longer valid or active, how can I get the answers to be sent to my current active e-mail? Thank you

    You need to contact Apple, either through the link in that article or by phoning them and asking for the Account Security team.
    (80384)

  • Hi I have forgotten the security answers and changed my email as I no longer use my old one how can I get the answers please

    I have forgotten my answers to my security answers and changed my email how can I get my answers to purchase off the store

    Click here and request assistance.
    (80557)

  • How can I get rid of this message that keeps popping up: Widevine Media Optimizer Update Available? Don't know what it is but don't want it.

    How can I get rid of this message that keeps popping up:
    Widevine Media Optimizer Update Available? Don’t know what it is but don’t want it.

    Any third-party software that doesn't install by drag-and-drop into the Applications folder, and uninstall by drag-and-drop to the Trash, is a system modification.
    Whenever you remove system modifications, they must be removed completely, and the only way to do that is to use the uninstallation tool, if any, provided by the developers, or to follow their instructions. If the software has been incompletely removed, you may have to re-download or even reinstall it in order to finish the job.
    Here are some general guidelines. Suppose you want to remove something called “BrickYourMac.” First, consult the product's Help menu, if there is one, for instructions. Finding none there, look on the developer's website, say www.brickyourmac.com. (That may not be the actual name of the site; if necessary, search the Web for the product name.) If you don’t find anything on the website or in your search, contact the developer. While you're waiting for a response, download BrickYourMac.dmg and open it. There may be an application in there such as “Uninstall BrickYourMac.” If not, open “BrickYourMac.pkg” and look for an Uninstall button.
    You may have to log out or reboot in order to complete an uninstallation.
    If you can’t remove software in any other way, you’ll have to erase your boot volume and perform a clean reinstallation of OS X. Never install any third-party software unless you're sure you know how to uninstall it; otherwise you may create problems that are very hard to solve.
    Trying to remove complex system modifications by hunting for files by name often will not work and may make the problem worse. The same goes for "utilities" that purport to remove software.

  • 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 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/

Maybe you are looking for