URGENT!! How to avoid paint all the components?

In the following code sample, when you move the mouse, the top-level JPanel (with the name p) repaints itself with a red circle. The strange thing is that also the 4 JButtons repaint themselves!! (this is shown by the System.out). If the container of the 4 JButtons and the "p" had too many components, then the repaint of "p" gets very slow!! If i delete the line "super.paintComponent(g)" in the class "Myb", then the JButtons do not show correctly.
How can i avoid that the 4 JButtons do not repaint themselves all the time?
import javax.swing.*;
import java.awt.*;
public class Fr extends javax.swing.JFrame {
    private javax.swing.JPanel p;
    private Ap ap1;
    private Myb b4;
    private Myb b3;
    private Myb b2;
    private Myb b1;
    public Fr() {
        p = new javax.swing.JPanel();
        ap1 = new Ap();
        b1 = new Myb();
        b2 = new Myb();
        b3 = new Myb();
        b4 = new Myb();
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                System.exit(0);
        p.setLayout(null);
        p.setBackground(new java.awt.Color(153, 153, 0));
        p.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                ap1.repaintWith(SwingUtilities.convertPoint(p,evt.getPoint(),ap1));
        ap1.setFont(new java.awt.Font("Dialog", 0, 11));
        ap1.setOpaque(false);
        p.add(ap1);
        ap1.setBounds(-10, -40, 500, 500);
        b1.setText("b1");
        p.add(b1);
        b1.setBounds(0, 0, 150, 150);
        b2.setText("b2");
        p.add(b2);
        b2.setBounds(0, 150, 150, 150);
        b3.setText("b3");
        p.add(b3);
        b3.setBounds(150, 0, 150, 150);
        b4.setText("b4");
        p.add(b4);
        b4.setBounds(150, 150, 150, 150);
        getContentPane().add(p, java.awt.BorderLayout.CENTER);
        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setSize(new java.awt.Dimension(500, 500));
        setLocation((screenSize.width-500)/2,(screenSize.height-500)/2);
    public static void main(String args[]) {
        new Fr().show();
class Ap extends JPanel
    private Point p;
    public Ap(){
        super();
        p = new Point(10,10);
    public void repaintWith(Point p){
        this.p = p;
        repaint();
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.red);
        g.fillOval(p.x-5,p.y-5,10,10);
class Myb extends JButton
    int x = 0;
    public Myb() {
        super();
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        System.out.println(getText()+"-->"+(x++));
}

I did that, but still nothing!
I inserted these lines!
        JPanel subp = new javax.swing.JPanel();
        subp.setBorder(new javax.swing.border.LineBorder(Color.blue, 2));
        subp.setOpaque(false);
        p.add(subp);
        subp.setBounds(200, 0, 200, 200);
        ap1.setOpaque(false);
        subp.add(ap1);
        ap1.setBounds(200, 0, 200, 200);

Similar Messages

  • How can I disable all the components in a JPanel?

    I want to disable all the components( button, text field ) in a JPanel. I know I can search the panel and disable each of its children component recursively. Is there a better way to do this?

    I want to disable all the components( button, text field ) in a JPanel.You haven't defined what you mean by "disable".
    If you mean you want the component to be repainted in its disabled state, then you would need to set the property of each individual component to disable, which would imply some kind of recursion.
    If you just want to prevent components from receiving key events and mouse events, then you can use a glass pane or maybe a panel with an overlay layout that contains a non-opaque panel that intercepts all events.

  • How to validate that all the components are running healthy in 12.1.1

    Hi All,
    I have just installed EBS 12.1.1, Is there any way to validate that all the components are running healthy?
    Thanks in Advance.

    Oracle-User wrote:
    Hi All,
    I have just installed EBS 12.1.1, Is there any way to validate that all the components are running healthy?You can verify that from OAM or from "adopmnctl.sh status" command.
    Please see old threads which discuss the same topic.
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Checklist&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Health+AND+check&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Checklist+AND+R12&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • How to avoid changing all the document with alignment change

    I want to change one paragraph as centered alignment, but not change the rest of the document. How?

    Just select whatever you want to format and not the rest. If it is just the one paragraph just click any where in it.
    The alignment formatting is on your toolbar, in the text inspector and under the Format menu > Text.
    Peter

  • How are all the Components available in CCMS

    All,
    I am new to MI, I have one question: Once we register all the components in MCD, Are all these components required to be enabled/made available in CCMS? If so how will that be done?
    Regards
    Sudh

    Hi
    It is not necessary to make an entry of your components in CCMS. It is an optional configuration unless you want to be alerted on some updates. These steps will be defined clearly in your configuration docs.
    regards
    Arun

  • We had to change the feed adress and the epsiode adresses. Now all the episodes of my podcast are downloaded (although i have downloaded them already). How can I make the changes in my feed and avoid that all the episodes are reloaded?

    Hello,
    We had to change the feed adress (<itunes:new-feed-url>)and the epsiode adresses in the feed because the feed and the episode-files are on a new server. Now when i open my iTunes subscription of our podcast all the episodes of my podcast are downloaded again (although i have downloaded them already).
    My Question therefore is: How can I make the changes in my feed and avoid that all the episodes are reloaded?
    Maybe have an answer?
    Thank you very much.

    Thank you very much for your answer
    As I see now, our 'guid' tags contain the episode URLs
    To avoid this problem in the future i would like to change guid tags. Can you please tell me how a guid tag should look like if it is not the URL?
    Thank you for helping us!
    ps now it looks like this eg:
    <guid isPermaLink="false">http://www.castyourart.com/podcasts/213_thinkglobal_en.mp4</guid>

  • How can get all the components used on the current page

    how can I get list of all components being used on the current page using javascript. I have tried CQ.WCM.getComponentList(CQ.WCM.getPagePath()) but this seems to list all the components available.
    Environment CQ 5.5 Update 1, Widnows 7

    You have to remember that once you are in JS, you are only really able to retrieve markup or representations of the DOM.  The markup is the result of a combination of components, which is technically a "server only" concept.  Components are just a way for CQ to organize executable code, so once a page is rendered a component isn't really a thing.  The closest thing I can think of is to list all of the DIVs that represent a component wrapper that are on the page, but this is error prone and clunky.  You could also make AJAX calls back to the server to retrieve a list of the components by node name, but that approach would not return synthetic resources (ones that render, but do not have a node representing them).
    Why are you trying to do this?  Maybe someone has a better idea, but this has a bad smell to me.

  • Disable all the components of a panel ( panels within the main panel )

    Hi guys!
    I have a problem!
    i have to disable all the components of a panel. please note that i am also having panels within the main panel. please tell me how to do that!!!
    its urgent!!

    Hi guys!
    I have a problem!Wouldn't have figured that one out by myself ...
    its urgent!!No, it's not.
    You know, a panel is most often a subclass of Container, so all you need to do is recursively disable all child components. The methods getComponents and getComponent are very helpful when trying to access child components. Code likeif ( comp instanceof Container )
      // do soemthing
    }will help in determining whether a child component is yet another Container.

  • Show Error string for all the components in a form at a time

    How do I show all the error strings for all the components in the form when the submit button is clicked?

    This code answers your question:
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
        <![CDATA[
          import mx.events.ValidationResultEvent;
          import mx.validators.ZipCodeValidator;
          import flash.events.MouseEvent;
          public var v:ZipCodeValidator = new ZipCodeValidator();
          public var vResult:ValidationResultEvent;
          public function performValidation():void {
            v.domain = "US or Canada";
            v.listener=myZip;
            vResult = v.validate(myZip.text);
            if (vResult.type==ValidationResultEvent.INVALID) {
              myZip.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_OUT));            
              myZip.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_OVER));
        ]]>
      </mx:Script>
      <mx:TextInput id="myZip"/>
      <mx:Button label="Submit" click="performValidation();"/>
    </mx:Application>
    If this post answers your question or helps, please mark it as such. Thanks!
    http://www.stardustsystems.com
    http://www.stardustsystems.com/blog
    Adobe Flex Development and Support Services

  • Is it Possible in Purchase Order that putting the BOM, all the components ?

    Is it Possible in Purchase Order that putting the BOM, all the components of that particular ges populated in the Rowt ? This is necessary to select single - single items is PO..
    We are also using MRP and Forecast. We want to use this method in case of placing URGENT Purchase Order without considering WH stock + PO ordered + ....................
    What kind of Query we would write , that  putting the BOM in the UDF, the componenets get populated in Purchase Order...
    Please give complete query.................

    The query I have provided earlier needs to be set in the ItemCode field at the row level and not on your User field at the header.
    The query below (same as earlier with the addition of the user field name - please verify) will show the Child Items of the BOM item who code you have entered at the Header level in your UDF.
    SELECT T0.Code FROM [dbo\].[ITT1\] T0 WHERE T0.Father = $\[OPOR.U_BOMNAME]
    This will not automatically fire but the user has to first enter the Vendor Code and then enter the U_BOMName and then in the Item code field press Shift+F2 which will fire the above query FMS displaying the child Items for this BOM.
    Suda

  • Installed cs6 master collection wont install all the components for photoshop , after effects or FB yet everything else is fine

    installed cs6 master collection wont install all the components for photoshop , after effects or FB yet everything else is fine

    Alanh61734259 are you receiving any specific error messages in the installation log files?  You can find details on how to locate and interpret the installation log files at Troubleshoot with install logs | CS5, CS5.5, CS6, CC.  You are welcome to post any specific errors you discover to this discussion.

  • How can i print all the contect of the code in sapscript window ? ?

    how can i print all the contect of the code in sapscript window ? ?

    Hi,
    Do you mean that you want to print the ABAP code to SAPscrip form ?
    Svetlin

  • How can i print all the tab pages not just the first page (tab)

    how can i print all the tab pages not just the first page (tab)

    You would need to do this programmatically. Here's one way:
    Attachments:
    Example_VI_BD6.png ‏3 KB

  • I am running out of memory on my hard drive and need to delete files. How can I see all the files/applications on my hard drive so I can see what is taking up a lot of room?

    I am running out of memory on my hard drive and need to delete files. How can I see all the files/applications on my hard drive so I can see what is taking up a lot of room?
    Thanks!
    David

    Either of these should help.
    http://grandperspectiv.sourceforge.net/
    http://www.whatsizemac.com/
    Or search 'disk size' in the App Store.
    Be carefull with what you delete & have a backup BEFORE you start, you may also want to reboot to try to free any memory that may have been written to disk.

  • How do I find all the purchased items on my iPhone? When I try to update the iPhone iOS while connected to my MacBook it says there are purchased items on the phone that have not been transferred to my iTunes library and that I should transfer them.

    How do I find all the purchased items on my iPhone? When I try to update the iPhone iOS while connected to my MacBook it says there are purchased items on the phone that have not been transferred to my iTunes library and that I should transfer them before updating.

    Thanks. This seems to have worked easily.

Maybe you are looking for

  • Can no longer save Nikon .NEF files in Photoshop cc 2014

    Hi I am hoping someone can help.   I was using a PC running Windows 7 64-bit and using LR, PS and Bridge to sort and edit Nikon files. This worked fine up to November of last year when I lost PC etc due to house fire. In the interim period I've been

  • Firefox does not autofill the userid & password when i go to websites after upgrade to 6.0.2

    i used to be able to type the first letter of a userid or double click on the userid field and firefox would show all my userid options and then autofill the password. when i upgraded to 6.0.2 it wouldnt do it anymore. i double checked and all my use

  • SVG files?

    What are SVG files used for? Are they still used? Thanks.

  • Browser fill parallax?

    Hi there, This was today's muse site of the day, so you know that it's created 100% muse. I'm designing my new Graphic Design website and I really want to achieve the effect shown here: http://blacksheepcooperative.com If you scroll down you see the

  • Data Load error ODS to Cube

    Hi Data Flow ODS-->Cube (Transformations) We replaced update rules with transformations. Fiscal Year Variant is mapped to Fiscal Year Variant FY Year mapped to FY Year FY Year/Period Mapped to FY Year/Period In Transformations we are getting Cal Mont