Add & update JLabels

Hello guys,
My problem is: I got a JLabel with an image that is showed in the panel when I start the application. Then if the user clicks on a button, the JLabel must be replaced by another one.
I know about Event Handling, as you can see below. I'm confused about what JPanel Methods I should use to print on screen the new JPanel.
Heres a sample of my code (this file is not the main one..it is involked by another one):
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class Simples extends JFrame implements ActionListener
public JFrame frame = new JFrame();
public JButton cg = new JButton();
public Simples()
     //Panel and JLabel
     final JPanel panel = new JPanel();
     final JLabel label1 = new JLabel ("LABEL_BEFORE_CLICKS);
pane.add(label1);
//JButton
JButton start = new JButton ("Start");
frame.getContentPane().add(panel, BorderLayout.CENTER);
     frame.pack();
frame.setVisible(true);
//events
     start.addActionListener(
     new ActionListener()
{      public void actionPerformed(ActionEvent e)
     { cg = (JButton)e.getSource();
JLabel label1 = new JLabel ("LABEL AFTER CLICKS");
panel.add(label1);
panel.remove(label1); /* IS THIS WRONG? WHAT SHOUD I DO HERE TO GET THE NEW LABEL DISPLAYED OVER THE OLD ONE?*/
frame.pack();
frame.repaint();

When you are changing a label don't worry about adding a new label in it's place just change the label that is already there with it's setText and setIcon methods. That way you don't have to remove and then add a new JLabel with is redundant anyway.

Similar Messages

  • I recently updated my iPhone 4s to ios6, and lost 1200 odd contacts. I have a backup from about 4-5 months ago avaiable.  Can I add/update contacts from the back up rather than restore which i assume will literally delete any new contacts added...?

    I recently updated my iPhone 4s to ios6, and lost 1200 odd contacts. I recently sold my macbook air and also my mac book pro, so have no recent backups avaiable.  I have a backup from about 4-5 months ago available on an external hdd as a time machine backup.  Can I add/update contacts from the back up rather than restore?  The reason i wish to do this is because in the update i didnt lose any messages, so all of the people i have met and networked with since that last update those many months ago, i have in my messages listings.  They are all unidentified numbers at present but over time i will be able to work through the messages and based on the conversation recall who each was with.  Also, yesterday, some two weeks after the update had left my contacts list entirely empty... a vast majority just reappeard, though all of them are without any phone numbers, all just emails or facebook contacts.  This is the work of facebook not mac/ios6 isnt it...?  Any help here would be greatly apprecaited.  I am about 2 days from flying to canada and having those contacts would make life a lot easier.

    You should be syncing your contacts with an app on your computer or cloud service (iCloud, Gmail, Yahoo, etc), and not relying on a backup.  If you haven't been doing this, start now and then restore your old backup.  You will then be able to sync the new contacts back into the phone.  However, you will lose all messages, etc newer thant the backup.

  • HOW CAN I ADD/UPDATE/INSERT IN A USER TABLE WITH MATRIX

    Hi All,
    I have one User table (Defined as No Object) and what i need to do is a form with a matrix to Add/Update/Delete data in my user table.
    I already create the form and the matrix that already give me the user table data. But now i have several problems to solve.
    First I try to add a new row but this new row get the data of the last row in the matrix. What i needed is a blank row to add new data in the user table.
    Second, when i change data in matrix and do update in the form, sap show me the message that the operation is successfully done but the data in the user table in not updated.
    I am trying to do one forma like whe can find in Setup-> General -> Freight.
    Can anyone help me?
    Best Regards,
    Luis Duarte

    Hi,
    If ur dealing with a simple form like that U can as well use the direct table form, and just provide a FMS to auto matically fill the code and name. U can directly use the form by.. Tools-->UserDefined Windows
    Or
    Comming to ur problem.... when ur adding a new row clear the data sources so that u'll get a blank row.
    And for update the best thing to do is delete all the records in the table and again insert all the records directly from the matrix.
    Hope it helps,
    Vasu Natari.

  • Add a JLabel below a JTextArea in a boxlayout

    I have a JTextArea in a JScrollPane in a GUI, and I'm using BoxLayout. Occasionally, I wish to add a JLabel to my JScrollPane, which works fine.
    However, since my BoxLayout is set to the Y_Axis layout, the JLabel always ends up being centered below the JTextArea, and I want it, as well as the JTextArea, to be aligned to the left. I know there is a LEFT_ALIGNMENT operator, but I am unsure of how to use it, although I've read the API for java.awt.Component.
    Also, my JTextArea has a maximum column size, but when the JLabel is displayed, the JTextArea stretches across my entire JScrollPane window. I've tried setting a maximum size, but for some reason that tends to cut off some text on the left side of the JTextArea.
    The JLabel will almost always be wider than the JTextArea. Perhaps that is causing some problems with BoxLayout?
    If there's any more information I should provide, please let me know.
    Thanks for any help you can provide,
    Dan
    Message was edited by:
    Djaunl

    Ok I figured out how the align the JLabel to the left:
    myJLabel.setAlignmentX(Component.LEFT_ALIGNMENT);However, I'm having an odd problem with my JTextArea. If my GUI displays the text normally, everything is fine. But once I add a JLabel to my JScrollPane that is wider than the view (i.e. so I need to scroll horizontally to see the entire JLabel), when I load more text, the text will not position itself within the JScrollPane view, and I will have to scroll over to see all of the text, which I do not want to do.
    Is there a way to keep the JTextArea at the same maximum column number, even though there is a JLabel below it that is much wider than the JTextArea should be?
    I get the feeling this isn't making sense. Here's the code to create my components:
    // Create min/max dimensions
              Dimension minimumSize = new Dimension(200, 500);
              Dimension maximumSize = new Dimension(500, 500);
                    Dimension buttonSize = new Dimension (125, 20);
                    int cols = 30;
              // Create Tree viewing pane
              JScrollPane treeView = new JScrollPane(tree);
              treeView.setMinimumSize(minimumSize);
              treeView.setMaximumSize(maximumSize);
              // Create HTML viewing pane 1
              final JPanel htmlView1 = new JPanel();
                    BoxLayout BL = new BoxLayout(htmlView1, BoxLayout.Y_AXIS);
                    htmlView1.setLayout(BL);
                    final JScrollPane htmlPane = new JScrollPane(htmlView1);
              htmlPane.setMinimumSize(minimumSize);
              htmlPane.setMaximumSize(maximumSize);
                    // Create text area1
                    final JTextArea textArea1 = new JTextArea();
                    textArea1.setLineWrap(true);
                    textArea1.setWrapStyleWord(true);
                    textArea1.setColumns(cols);
                    textArea1.setAlignmentX(Component.LEFT_ALIGNMENT);
                                            JLabel pic = new JLabel (new ImageIcon(new URL(DBQuery.list.get(1))));
                                            pic.setAlignmentX(Component.LEFT_ALIGNMENT);
                                            htmlView1.add(pic);Later in the code, I add textArea1 to htmlView1.
    I'm sorry if this is very confusing. If there is anything I can do to help, please let me know.

  • 'Null' being added to ArrayCollection during add/update by Dataservice

    Environment:
    Tomcat 6.0
    Livecycle 3.1
    Flex SDK 3.5
    We have a data service destination setup like this:
         <destination id="Trades" adapter="java">
            <properties>
                <factory>spring</factory>
                <source>lcdsTradeBlotterAssembler</source>
                <scope>application</scope>
                <item-class>com.domain.Trade</item-class>
                <use-transactions>false</use-transactions>
                <auto-sync-enabled>true</auto-sync-enabled>
                <cache-items>true</cache-items>
                <metadata>
                    <identity property="uid" type="java.lang.String" />
                </metadata>
                <network>
                    <throttle-inbound policy="IGNORE" max-frequency="500" />
                </network>
            </properties>
        </destination>
    We implement a custom assembler by extending the AbstractAssembler.
         The fill and refreshFill methods are implemented.
    Updates are pushed to the client using a DataServiceTransaction:
         DataServiceTransaction transaction = DataServiceTransaction.getCurrentDataServiceTransaction();
         transaction.createItem(DESTINATION, trade);
         transaction.commit();
    After we create items and push them from the server, the refresh method on the Assmbler gets called. We return 'APPEND_TO_FILL'.
    The item shows up in the client side managed ArrayCollection. This ArrayCollection is bound to a datagrid.
    Problem description:
    The above works fine when we run the server and the client locally on the same machine. When the application is hosted on a another part of the network - we see that for some of the updates - a null gets added to the ArrayCollection, instead of the object pushed from the server. We found this by attaching a CollectionChange event listener to the managed ArrayCollection. This causes blank rows to show up in the Blotter. In some cases we have also seen duplicate rows.
    We see that the object is delivered to the client but not applied to the ArrayCollection properly. I attached a screen shot of the client side stack where we loose the update.
    Calling the refresh() method on the ArrayCollection after the update, fixes the situation. The nulls disappear and the ArrayCollection now has the right data !
    Things tried so far:
    Throttling the DataService update rate - down to 1 update/sec
    Enabling reliable delivery on the Dataservice destination
    Handling conflicts - none detected. Client never updated data.
    Setting DataService.resetCollectionOnFill property to true
    Any pointers would be very helpful

    Thanks.
    We traced this down to the fact that we have multiple threads reading off a JMS queue and pushing the add/update to the client via LCDS.
    Each thread has its own instance of DataServiceTransaction - so this should be ok.
    Following up with support.

  • BAPI or function module to add/update MRP Area (MDMA table precisely)

    Hi All,
    can any one suggest me the BAPI to add/update MRP Area. I need to update the fields in MDMA table.
    Thanks in Advance,
    KG

    Dear Brahmankar,
    My actual requirement is that I will get an excel sheet with data to be added to MARC and MDMA table. I guess the report you suggest is good for manually updating/creating/deleting MRP area. It will as good as using BDC in MM02 transaction programatically. Doing BDC will be the last option. If I am able to use any function module then it will good I guess. Please correct me, if I am wrong and suggest me how to proceed.
    Thanks and Regards,
    KG

  • Add update rule for new key figure in one info struc

    Hi, everyone
    I would like to know how to add update rule for new key figure in one info struc.
    Thanks ahead.
    Eric

    1)I have created the update rule for one info structure
    2)add one key figure in the info structure due to business requirement
    3)then I use MC25 to add update rule for the new key figure, but I find that there no relevant menu to do such operation.
    Can anybody tell me how to do with it?
    Any answer will be appriciated.

  • Way to Add/Update XML through browser?

    First off, what a fantastic framework you folks have created!
    I'm deploying HTML site locally on the intranet and I'd like
    to be able to add, delete or modify items in the XML file through
    some sort of HTML form. All the examples I've seen on the internet
    require asp or php, is there a way to do this without asp or php?
    If not, can anyone recommend a "user friendly" way to allow people
    do this? Thanks!

    quote:
    Originally posted by:
    GlazerGallery
    I am interested in doing this, too, and would like some
    advice as to what would be the easiest way to go, taking the
    following into consideration:
    1. I consider myself an artist and designer, not a
    programmer, though I hand-code my HTML, have a decent grasp of CSS,
    and have learned enough about Spry and XML to take some of the Spry
    demos and customize them to work on a couple of web sites. But I
    would love to have something that I could use to fill out an XML
    document without having to individually type each entry including
    the opening and closing tags, when I have sets of items where there
    are anywhere from 20 to 300 entries.
    2. Our site is hosted on a shared Linux server.
    3. I am very comfortable with Dreamweaver, which I see has
    some tools for marking up pages in PHP and ColdFusion.
    So what would be easiest to learn to do, learn PHP, go with
    the ColdFusion example cited above, or something else?
    Thanks,
    Helen
    dear Helen,
    i see your server was Linux platform on Shared Hosting, the
    best way to do know is to learn PHP since most (if not all) Linux
    server support this programming language, and for ColdFusion you
    need special server for that
    you can read some basic of PHP and its backend Database
    (especially MySQL) here:
    http://www.w3schools.com/php/
    mostly PHP are more easier than ColdFusion, since ColdFusion
    has it own markup (CFML)
    the concept was you input data to database and generate
    dynamic XML for that (like what V1 Fusion said) and load it using
    Spry, but if you want add/update/delete, you may have to do some
    trick with spry :D
    good luck

  • Add/Update/Delete XMP (PDF) metadata?

    I'm new to working with PDF. What I would like to do is add/update/delete XMP metadata to PDF documents. These documents will be indexed by our search engine, which I'm told can index this metadata. It's indexing Dublin Core so don't see why it could not index custom schema. Anyway, I've been researching this and as a non-programmer I'm confused.
    1) Can PDF metadata be added, updated and deleted?
    2) Can this be done via a template? (ie. get the PDF file, fill out a metadata form, and submit it or in the case of update/delete change or remove the data).
    3) Are there any developed applications (client or server based) that can do this or must they be developed? If they exist please tell me what and where they are ...
    4) Has anyone used the Java XMP parser?
    5) Anyone know of any online demos of adding/updating/deleting PDF XMP metadata?
    6) Can XML or XMP data be imported into a PDF file?
    Any help will be very much appreciated.
    Thank you

    1) Can PDF metadata be added, updated and deleted?
    PDF metadata is tricky - it consists of legacy doc info within the PDF structure and newer XMP metadata - Adobe is making the transition to supporting XMP across all its applications but we have to ensure not to break older workflows.
    Additionally, PDFs have the property of storing successive edits - meaning, changes are stored as add ons on top of the orginal when Saved - they are cleaned up when the PDF is Save As-ed.
    This has the added implication that XMP packets are duplicated - so scanning for the XMP maker will bring up multiple 'hits' even if one object is there. I've believe there are some heuristics that can be applied to find the 'right' packet using mod dates.
    In most cases it helps to have the PDFL to assist in the process.
    2) Can this be done via a template? (ie. get the PDF file, fill out a metadata form, and submit it or in the case of update/delete change or remove the data).
    Yes, within the application - under Advanced > Document Metadata...
    Outside of the application you will need to build your own workflow.
    3) Are there any developed applications (client or server based) that can do this or must they be developed? If they exist please tell me what and where they are ...
    PDF can be updated very easily using the Photoshop CS File Browser - multiple files can be selected and metadata templates applied. Additionally the File Info dialog in the File Browser can be customized - adobe.com/xmp for docs.
    Also, check out poundhill.com - they have plugins for customization and integration with FileMaker, AppleScript & PHP
    4) Has anyone used the Java XMP parser?
    I'd like to know the answer to this too!
    Check out:
    http://www.java-channel.org/query.jsp?cids=c_10807
    Looks like some there are XMP and PDF related java code.
    5) Anyone know of any online demos of adding/updating/deleting PDF XMP metadata?
    What would you like to see? Using the Acrobat application or from a developer perspective?
    6) Can XML or XMP data be imported into a PDF file?
    What were you looking to do? Again, this can be done using templates and the PS CS File Browser.
    Pound Hill may be able to provide the connectors that you could piece together.

  • How to handle ok/add/update button

    hi,
       the button ui=1 automatically changes in add/update /ok buttons .but how we handle update and add ivent through database.
    Pandey
    Sai I.S.

    Hi,
    I have made a new company in SAP B1 and I Selected the Use purchase account posting system in company detail Basic Initalization tab.
    so it is post the taxes in stock account.this is not formal and i am getting problem in normal processing. so i want to know what the effects of this purchase account posting system. how it is different from normal. how can i chang this company in narmal company for normal processing .plz tell me process of changing in normal. and if i carry on futher hat will be the efect of it.
    plz give me answar quickly
    I have also a problem when i creating new company .it does not take any user name and when i open that by manager user it gives massege wrong user or passward.
    what the problem is there plz give me solution of all above.
    HP

  • Regarding add/update/find form modes

    Hi,
    Can you please help me with the way to catch the event of add/update/find form modes? Currently we are able to catch the event of the button but we require to catch seperately the form modes (add/update/find).
    Thanks in advance,
    Jona

    Hi Jona,
    You can use the property pVal.FormMode when you catch the itemEvent.
    You have access to :
    - find mode : SAPbouiCOM.BoFormMode.fm_FIND_MODE
    - ok mode : SAPbouiCOM.BoFormMode.fm_OK_MODE
    - update mode : SAPbouiCOM.BoFormMode.fm_UPDATE_MODE
    - add mode : SAPbouiCOM.BoFormMode.fm_ADD_MODE
    - view mode : SAPbouiCOM.BoFormMode.fm_VIEW_MODE
    - print mode : SAPbouiCOM.BoFormMode.fm_PRINT_MODE
    HTH,
    Thibault

  • Add Updates to SUGs

    Hello,
    I've been looking for a way to automatically add updates to Software Update Groups based on a specific property filters, I can't use ADR for this, because I can't set "Downloaded" as a property filter.
    My end goal is to have a SUG for each product, and have it automatically add all the downloaded (by the ADRs) and remove the expired/superseded updates, so that each product have all it's updates deployed and ready to be installed whenever needed.
    I've searched the internet and looked over
    THIS and I didn't see anyway to add/search for updates based on property filters or criteria.
    So, did I miss something? is this possible?
    Thanks.

    You don't mention a language or SDK, so I will just point you to the SDK samples of how to enumerate updates based upon criteria:
    http://msdn.microsoft.com/en-us/library/jj217929.aspx and how to create an update list:
    http://msdn.microsoft.com/en-us/library/jj217793.aspx
    It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.
    I was looking for a way to do it through PowerShell, but WMI will do (and seems the only way).
    Thanks for the info.
    Out-of-the-box the only method to automatically download updates is and ADR. I don't really follow why that's not an option...
    To download the content of an update group to a deployment package the cmdlets won't do the trick. You can have a look at something like this:
    http://www.petervanderwoude.nl/post/add-update-content-to-a-deployment-package-via-powershell-in-configmgr-2012/
    My Blog: http://www.petervanderwoude.nl/
    Follow me on twitter: pvanderwoude
    The updates are already downloaded, I want to add/remove them to/from a specific SUG that was not created by ADR.
    Based on your blog post (great blog BTW), I modified the query to list all the updates for a specific product that are not part of a specific SUG, but it didn't work (lists all the product updates):
    SELECT upd.* FROM SMS_SoftwareUpdate upd, SMS_CIRelation cr WHERE CategoryInstance_UniqueIDs='Product:704a0a4a-518f-4d69-9e03-10ba44198bd5 AND upd.IsContentProvisioned=1 AND upd.IsExpired=0 AND upd.IsSuperseded=0 AND cr.FromCIID<>16786172 AND cr.RelationType=1 AND upd.CI_ID=cr.ToCIID
    Is there a way to do it other than listing all the product updates and comparing it to all updates in the SUG?
    Thanks.

  • Failed to Add Update Source for WUAgent Error = 0x87d00692 - HELP!!

    I am having trouble with my clients recieving updates.  I notice alot of my clients where my primary site is are recieving updates but all of my clients in my secondary sites are not.  Below is output from the WUAHandler.log on a client system.
    Group policy settings were overwritten by a higher authority (Domain Controller) to: Server HTTPS://SERVER.COMPANY.COM:443 and Policy ENABLED WUAHandler 4/12/2013 8:21:28 AM 4220 (0x107C)
    Failed to Add Update Source for WUAgent of type (2) and id ({AA27FC20-A281-46CC-B04F-D0940B5E072F}). Error = 0x87d00692. WUAHandler 4/12/2013 8:21:28 AM 4220 (0x107C)
    The server stated above is correct and we have no GPOs applied to our enviornment for an update server.
    I did just update to SCCM 2012 SP1 and have applied all the hotfixes for WSUS.  I am at a roadblock.  Would a site reset be advised?  Perhaps WSUS and SUP reinstall?  Any help would be appreciated I am out of ideas.
    My enviornment:
    1 primary server - roles- sup, dp, mp
    3 secondary sites - role - dp and mp - clients under these sites do not get updates
    Ryan Ventimiglio

    When I have checked this my current SCCM server address thats listed in the WUAHandler log is set in the registry for the client.  So this is the same address so its not like anything is conflicting. 
    Whats strange about this is that everything was working fine before the SP1 upgrade.  I just ran a site reset but no change.  Do you think a WSUS/SUP uninstall/reinstall would be the next step?  Is this done typically?  Any other
    things I should be checking.  I know we do not have any GPOs set in our enviornment for this so this cant be the problem.
    Ryan Ventimiglio

  • Update JLabel

    I am just wondering if/how I can update JLabel or do I just have to use another method.
    I just want it to like update words in the JLabel...
    ...is there any actionListener/ItemListener to go with JLabel?
    I have also tried just writting strings directly to the JFrame, but when the JFrame updates, the words just write over each other....is there any way I can clear the JFrame before I redraw the string? (as an alternative to using JLabel?)
    Thanks
    Shellie

    You can make a JTextField look like a JLabel if repainting JLabel
    is a pain...
    final int LABEL_SIZE = 5;
    JTextField tf = new JTextField(LABEL_SIZE);
    tf.setEditable(false);
    tf.setBackground(UIManager.getColor("Label.background"));
    tf.setForeground(UIManager.getColor("Label.foreground"));
    tf.setBorder(UIManager.getBorder("Label.border"));That way you don't have to worry about repainting as
    tf.setText(updateText) will do...
    Also you can make it look like mutiline Label by using HTML in
    the textfield -
    tf.setText("<HTML>text1.....<br>text2....</HTML>");

  • Outlook integration synchronize (add / update)

    Dear All,
    Our client is using SAP881 PL09, Office 2003. They have 2 US companies and 1 CA company.
    What is the best way we setup the synchronization for BP contact person?
    Should we ask them add / update all contact person in SAP then synchronize from SAP to outlook only? Or they can do both, then synchronize from both side.
    They are big company. They have 50+ users. will the synchronization (update and add new) crash their exchange server?
    Thanks.
    Regards,
    Yuka

    Hello,
    May it will help you.
    Make a new folders Company name wise.
    and always sync all contact person folder wise one by one for all company.
    and whenever user want to mail  and want to add contact person mail id  then select company wise folder to mail Ed for conatct person.
    Syncronization will one by one for all company
    Thanks
    MAnvendra Singh Niranjan

Maybe you are looking for

  • To how many bluetooth receptors can I send sound from my MacBook?

    Hi, I have two 2.1 surrounds system at home and I would like to pair both with my MacBook via bluetooth to play at the same time. Is that possible? In that case, what should I look for? I did a little research and found that a mac can pair up to 7 de

  • Changes that I am making in layout profile are not reflecting..?

    Dear Experts, I have created a new Layout profile to adjust the user interface . I have created my new layout profile and added a layout set admin explorer to it then I have changed the settings in command groups to supress some commands and likewise

  • Make connections in Mobile Application Modeler

    Hi community, today i downloaded the mobile application modeler (MOAM). Now i'm trying to doe the tutorial in the How To.. guide. At one point i have to do a connect between an outbound plug of the application itself and an inbound plug of a task. I

  • Ajout d'une dimension temporelle à un tableau

    Bonjour, Actuellement j'effectue l'acquisition de données que je mets dans un tableau à une dimension au sein d'une boucle while. Je voudrais savoir comment faire pour faire correspondre à ces données le temps auquel elles ont été relevés (c'est une

  • Prinitng out text messages

    How do I get a print out of text messages?  I have a contractual issue that needs to be documented through messaging.