How to call repaint() from one panel for another panel

I have two classes (leftPanel and rightPanel), which extends JPanel. I have added these panels to the container of the JFrame. I have a JButton in my left leftPanel. When I click the button I want that the repaint method of rightPanel is called. Please tell me how to do that.

Ok, the reason it wasn't working is because the two classes don't have a reference to each other. They don't have anything in common at all. The only class hooking them together is the myFrame. Therefore, myFrame is the class that should be the communication link. I've added a few lines of code to myFrame, but didn't change the other classes. Now myFrame has an actionListener and it listens for the leftPanel.leftButton. When the leftButton fires, myFrame tells rightPanel to repaint. Another cool way would be to have an actionListener on rightPanel and register that with leftPanel when you instantiate them in myFrame.
GL
kimoS
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.util.*;
public class myFrame extends JFrame implements ActionListener{
leftPanel left;
rightPanel right;
static int st=0;
myFrame(){
left=new leftPanel();
left.leftButton.addActionListener(this);
right=new rightPanel();
this.getContentPane().add(left,BorderLayout.WEST);
this.getContentPane().add(right,BorderLayout.CENTER);
public static void main(String args[]){
myFrame mf=new myFrame();
mf.setSize(500,500);
mf.setVisible(true);
public void actionPerformed(ActionEvent e){
right.repaint();
class leftPanel extends JPanel {
JButton leftButton;
leftPanel(){
leftButton=new JButton("leftButton");
this.add(leftButton);
leftButton.addActionListener(new leftButtonListener());
class leftButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
myFrame.st=myFrame.st+1;
System.out.println("st value inside listener="+myFrame.st);
// ??? here I want to call repaint method of rightPanel
class rightPanel extends JPanel{
int flag=-1;
public void paintComponent(Graphics g) {
update(g);
public void update(Graphics g){
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.drawString("If " myFrame.st" increases then repaint() called on click of button",30,100);
flag=flag*(-1);
if(flag==1){
g2.drawString(" painting is working",100,200);
}

Similar Messages

  • Can anyone give me step by step for calling FM from one SAP to another SAP

    can anyone give me step by step for calling FM from one SAP to another SAP
    points will be rewarded,
    thank you,
    Regards,
    Jagrut BharatKumar Shukla

    *& Report  RFC_FOR_CUSTOMER_LIST
    *& RFC to a Fn. module from another system which implements BAPI
    REPORT  rfc_for_customer_list.
    DATA:
      fl_status TYPE i.
    DATA:
      fs_message TYPE bapiret2.
    DATA:
      BEGIN OF fs_customers,
        id   TYPE s_customer,
        name TYPE s_custname,
      END OF fs_customers.
    DATA:
      t_customers LIKE
         STANDARD TABLE
               OF fs_customers.
    CALL FUNCTION 'Z_BAPI_GET_CUSTOMER_LIST' DESTINATION 'R3N'
      IMPORTING
        return = fs_message
      TABLES
        customerlist = t_customers.
    IF sy-subrc EQ 0.
      fl_status = 1.
      LOOP AT t_customers INTO fs_customers.
        WRITE:
          /10 fs_customers-id,
           30 fs_customers-name.
        AT LAST.
          WRITE:
            /,/5 'No of customers in R3N = ', sy-tabix.
        ENDAT.
      ENDLOOP.
    ELSE.
      MESSAGE 'RFC failed' TYPE 'S'.
      EXIT.
    ENDIF.
                           TOP-OF-PAGE EVENT                            *
    TOP-OF-PAGE.
      IF fl_status NE 0.
        WRITE:
          /12 'ID'   COLOR 6,
           32 'NAME' COLOR 6.
        SKIP.
      ENDIF.
    This is one small example...
    Regards,
    Pavan

  • How to move value from one tlist to another tlist in same form?

    how to move value from one tlist to another tlist in same form on button press?
    Same like in data block wizard when we select value from 1st list it will go to 2nd list and can be move back. Please help i am new to forms .
    Regards

    just call the following proc in your add & add all buttons. Reverse the code for REMOVEs
    this proc will move one item at a time from list_item1 to list_item2.
    PROCEDURE add_an_item
    IS
      v_list_count    NUMBER;
      v_item1_label  VARCHAR2(60);
    BEGIN
      IF :list_item1 IS NOT NULL THEN v_list_count := nvl(Get_List_Element_Count('list_item1'),0);
          IF v_list_count >= 1 THEN FOR i IN 1..v_list_count
          LOOP
             IF   :list_item1    = Get_List_Element_Value('list_item1', i)
             THEN
                  v_item1_label := Get_List_Element_label('list_item1', i);                 
                  Add_List_Element('list_item2',1,v_item_label,:list_item1);         
               Delete_List_Element('list_item1',i);
               Exit;
             END IF;
          END LOOP;
           END IF;
       END IF;
    END;
    *********************************************************************************this proc will move all items from list_item1 to list_item2.
    PROCEDURE add_all_items
    IS
      v_list_count NUMBER;
      v_item_label VARCHAR2(60);
      v_item_value VARCHAR2(60);
    BEGIN
    v_list_count := nvl(Get_List_Element_Count('list_item1'),0);
    IF    v_list_count = 1 AND Get_List_Element_Value('list_item1', 1) IS NULL THEN NULL;
    ELSIF v_list_count >= 1 THEN
           FOR i IN 1..v_list_count
           LOOP
            v_item_value  := Get_List_Element_Value('list_item1', i);
            v_item_label  := Get_List_Element_label('list_item1', i);       
            Add_List_Element('list_item2',i,v_item_label,v_item_value);
           END LOOP;
           clear_list('list_item1');
    END IF;
    END;I added [ code ] tags to make this easier to read.
    Message was edited by:
    Jan Carlin

  • How do you facetime from one iPad2 to another?

    How do you facetime from one iPad2 to another?  Obviously, there's no phone number involved.

    Maybe you didn't sign in correctly.
    Open FaceTime, enter your Apple ID and password, and tap Sing in. On the screen enter your email address others will use to call you, then tap next. Choose a contact and start the call.
    You can add another email address for yourself for others to also call you on.
    Go to Settings > Tap FaceTime > Tap Add Another Email

  • How to transfer Signatures from one Mac to another

    In Mail, if I go to Preferences > Signatures, I see in the left column *All Signatures*, and signatures for various accounts.
    How would I transfer the signatures in *All Signatures* from one Mac to another?
    The names of files in the folder ~/Library/Mail/Signatures are all cryptic.
    Moreover, since each signature is tied to a certain account, I don't think that I can just copy these files into the Signature folder of the 2nd Mac.

    Simply moving these cryptic files did not work, in the sense that these signatures did not show up in the right-most column of the Signatures pane.
    I made sure that I did not move the SignaturesByAccount.plist file in the ~/Library/Mail/Signatures folder.
    So, would someone please share with me how to transfer signatures from one Mac to another, with both running Mail?

  • How to transfer photos from one make to another

    How to transfer photos from one mac to another wirelessly

    I can give you a few ways to so:
    First (and my favorite way) is the one said above.  First, on the computer with the photos on it, you have to do is turn on file sharing (go to system preferences, sharing, file sharing) and have both computers on the same network.  Second, have the computers you want the photos on, and launch finder.  On the sidebar, there should be a "sharing" category, and below it should be the computer with the photos on it.  Click on it, and you will be prompted for the computer username and password.  It will then show all of the files on your computer.  Then, just find the files, copy them (command-C) and paste them to where you want them! (If this confuses you, I can upload a video step-by-step on how to do this).
    My second way is to use air drop. To start, Both computers must be on the same network.  Then, on the computer with the photos on it select all of the photos you want to send to the other computer (you can select many photos by holding the command key and clicking on photos), right-click (control-click) on the selected photos, find the button share, and click air drop.  On the computer you want the photos on, go to air drop on the side bar.  You should see the name of the computer on the radar-looking screen.  Click your computer.  The photos should begin to download to the downloads folder. (This feature is only compatible with certain computers)

  • How do I move from one website to another using Safari, while still allowing Pandora to provide music in the background? It seems that when ever I open a new URL, I lose Pandora.

    How do I move from one website to another using Safari, while still allowing Pandora to provide music in the background? It seems that when ever I open a new URL, I lose Pandora.

    Try running Pandora in its own tab and leaving that tab open (Safari 7.1.5, OS 10.9.5).  I don't have Pandora to try this, but it works for me otherwise.
    Good luck
    srb

  • OBIEE 11g How to pass variable from one prompt to another prompt in dashboard page.

      How to pass variable from one prompt to another prompt in dashboard page.
    I have two prompt in dashboard page as below.
    Reporttype
    prompt: values(Accounting, Operational) Note: values stored as
    presentation variable and they are not coming from table.
    Date prompt values (Account_date, Operation_date)
    Note:values are coming from dim_date table.  
    Now the task is When user select First
    Prompt value  “Accounting” Then in the
    second prompt should display only Accounting_dates , if user select “operational”
    and it should display only operation_dates in second prompt.
    In order to solve this issue I made the
    first prompt “Reporttype” values(Accounting, Operational) as presentation
    values (custom specific values) and default presentation value is accounting.
    In second prompt Date are coming from
    dim_date table and I selected Sql results as shown below.
    SELECT case when '@{Reporttype}'='Accounting'
    then "Dates (Receipts)"."Acct Year"
    else "Dates (Receipts)"."Ops
    Year"  End  FROM "Receipts"
    Issue: Presentation variable value is not
    changing in sql when user select “operation” and second prompt always shows
    acct year in second prompt.
    For testing pupose I kept this presentation
    variable in text object of dashboard and values are changing there, but not in
    second prompt sql.
    Please suggest the solution.

    You will want to use the MoveClipLoader class (using its loadClip() and addListener() methods) rather than loadMovie so that you can wait for the file to load before you try to access anything in it.  You can create an empty movieclip to load the swf into, and in that way the loaded file can be targeted using the empty movieclip instance name.

  • How to include iview from one page to another using FPM

    Dear experts
    using ECC6 NetWeaver 7
    I have followed this WIKI guide step by step.
    How to include iview from one page to another using FPM?
    https://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=118423928
    On step 4 I couldnu2019t create an Iview based on view u201Cpersonal datau201D u2013 it was not possible.
    The view wasnu2019t there (in comprehend to the  WIKI)
    What could be the reason?
    I have full authorization on the portal.
    Thank in advance for your help.

    Please check this.
    Re: Organizational History iView
    /thread/370447 [original link is broken]
    Regards,
    Sandip

  • The float in windows option is grey and not accessable ? How can I copy from one image to another ? Elements 11

    The float all in windows option is grey and not accessible ? How can I copy from one image to another ? Elements 11

    You really are not getting this.
    "I guess I am still completely shocked that as a parent we can't download something for everyone to use."
    Why do you continue to think this although we keep telling you that this is not the case.
    You do NOT have to purchase anything twice.  You can share the music with as many ipods as you like in your household.
    The ipods are designed to sync with your computer regularly.  You should have been syncing these other ipods with your computer all along, thus transferring the purchases to your computer where that music can be synced to as many ipods as you like.
    Take on of the ipods with the music in it.  Open itunes on your computer.  Plug in the ipod.  Do not sync.  Click File>Transfer Purchases  This will transfer the purchases from the ipod to the computer.  Make sure that you have authorized your account on the computer:  here are directions for that. http://support.apple.com/kb/HT1420
    Unplug the ipod.
    Plug in the other ipod with purchased music.  Do not sync.  Click File>Transfer Purchases  This will transfer purchases from the ipod to the computer.
    You can now plug in any of the ipods, select what you want to sync and sync.
    Have a look at the manual for the ipod.  http://manuals.info.apple.com/en_US/iPod_touch_iOS4_User_Guide.pdf

  • I would like to know how to transfer ebooks from one laptop to another with adobe digital editions both authorized with the same adobe ID.

    I would like to know how to transfer ebooks from one laptop to another with adobe digital editions both authorized with the same adobe ID.

    Stop using the account.
    You need do nothing more.
    You will need to authorize your computer for both accounts as you have purchased from both accounts.

  • How to transfer pictures from one itunes to another?

    I have most of my iPod stuff on my laptop, but my pictures are on my mac. I just got a new iPod, and I did what I normally do to get my pictures onto it- go into itunes, go into my pictures, and apply it. This time, however, not all of the pictures got transferred. I think it would be easier to have all my pictures on my laptop, but I do not know how to transfer them from one computer to another. How can I do this?

    If they are synced photos just copy the folders with the photos to the new computer. Synced photos are not associated with iTunes or the iTunes library.

  • How to transfer photos from one rhyme to another?

    how to transfer photos from one rhyme to another?

    Can you connect the phone to the computer as a disk drive using the usb cable supplied with the phone? Copy the files from the first phone. Disconnect it properly. Connect the second phone in the same manner. This time copy the files from the computer to the phone in the same place where you found them on the other phone.

  • How  to transfer data from one system to another by datamart please give de

    how  to transfer data from one system to another by datamart please give details

    Hi Deba,
    Find the below SAP help doc which may help u...
    http://help.sap.com/saphelp_nw70/helpdata/en/12/43074208ae2a38e10000000a1550b0/frameset.htm
    Also find the below threads...
    Loading data from one cube to another cube.
    data copy from infocube to infocube in two different BW systems
    Delta when loading from ODS to ODS
    reg datamart
    Data mart flag
    Regards,
    KK.

  • How to transfer bookmarks from one computer to another?

    how to transfer bookmarks from one computer to another?

    Export your bookmarks (file menu in Safari, from the Show All Bookmarks option in Firefox) and save to your HD. Copy the saved .html file to the other Mac over the network, or by copying the file to a USB stick and copying to the other Mac, or emailing them to the other Mac. On the other Mac import the Bookmarks file into your browser of choice,

Maybe you are looking for

  • Oracle Developer Suite 10g on Mandrake 10

    Hi all, I'm using new ODS 10g on Mandrake 9.2 for a few mounts without any problem. Yesterday I tried to install ODS on new Mandrake 10g. Universal installer run, but when I clicked on Next>, it crashed with this log: java.lang.UnsatisfiedLinkError:

  • Truncating/droping partitions

    i have to drop around 20 partitions for a particular table . the scripts are ready for droping and i have taken a logical export of 20 partitions. one thing i have realised is that the table have lot of constarints . my first question whether constra

  • INeed to load the excel directly

    Is it always mandatory to convert the Excel sheet to comma separated or tab seperated csv file before loading the data by SQL loader. Can't we directly load the Excel data without doing any conversion to csv file. if yes please let me know the field

  • Cannot Access AppSTore: "We could not complete your request."

    Hi, I have a valid Apple ID and I am also able to Sign In with that ID to the App Store. But when I try to install any application I get the following message: "We could not complete your request" "There was an error in the App Store. Please try agai

  • Error 1714: The Older Verison of Palm Desktop by ACCESS Cannot be Removed

    Hi Folks: Does anybody know what specific registry keys, files or directories must be cleaned up for this error to go away when installing Palm Desktop 6.2?   Note that I had a previous version 4.1.4 that got damaged.   I've run Windows Install Clean