Accessing javax.swing.JPanel from outside the EDT

Hi everybody!
I am not new to Java but to Swing.
Please consider the following:
public class MyPanel extends JPanel
     private int number = 0;
     private Object object = null;
     public int getNumber()
          return number;
     public void setNumber(int aNumber)
          number = aNumber;
     public Object getObject()
          return object;
     public void setObject(Object aObject)
          object = aObject;
Question:
Is it save to call the getters and setters defined above from a Thread other than the Event Dispatching Thread.
From my point of view and my understanding of Swing this should be save as the getters and setters do not touch anything other than the methods and instances defined within the object layer of MyPanel.
Please help :-)

jboeing wrote:
I might be wrong, but I think it's safe to touch the non-Swing methods in a subclass from other threads. The main concern in accessing Swing off the EDT is that you can concurrently modify parts of code, but since the EDT does not touch your getters and setters, at least it won't make deadlocks. Perfect, exactly what I would suggest. I couldn't have put it better.
The only oddities may occur if the member variable you set is used in logic for an overriden method (like paintComponent), but I don't think this will be too problematic in most cases.See what you mean so: What about synchronizing the getters and setters. Then only the scheduler would block the EDT as long as another Thread was touching the members. As no wait() and notify() calls arise this should not result in any deadlocks. The worst thing I could think of is that the responsiveness of the user interface may degrade if the EDT had to wait for a while as to many Threads were already waiting for synchronized accesss.
>
Edit:
Oh, and in the future, use the "*Code Formatting Tags*", see http://forum.java.sun.com/help.jspa?sec=formatting
Edited by: jboeing on Nov 13, 2007 1:14 PM
public class Apology{
    public static void main(String[] args){
        System.out.println("Thank you for your kind advice :-)");
        System.out.println("but please don't ask me why this is quoted style");
}Edited by: tog on Nov 14, 2007 6:08 PM

Similar Messages

  • Access to file server from outside the domain

    We have users from another domain who connect over VPN to our SAP.
    These users must drop a file on a certain server in our domain to create labels.
    The problem is that they are not users on the domain, so they don't have access rights. I tried with GUI_DOWNLOAD, but this function uses Windows Access Rights. What I need is that SAP (or some system user) just puts the file there whitout checking the access rights or that this putting is done under another user.
    Has somebody an idea or knows what function I can call to do this ?
    Thanks

    Hi Thomas,
    I’m writing to follow up with you on this post. Was the link above help you solve your issue?
    If you are satisfied the solution, I’d like to mark this issue as "Answered". Please also feel free to unmark the issue, with any new findings or concerns you may have.   
    Regards,
    Charlie Liao
    TechNet Community Support

  • Javaclassnotfound javax.swing.JPanel in a applet

    Hi,
    I have a applet which use a class which have the code
    import javax.swing.JPanel;
    public class WebPanel extends JPanel implements Runnable{
    Applet parent;
    i compile it with jdk1.2.2
    my problem is that when i try to run the applet on a Internet Explorer navigator it give me a
    javaclassnotfound javax.swing.JPanel
    problem.
    Javax.swing.JPanel is�nt in IExploter?
    Should i put the javax.swing.Jpanel class in the jar fije?
    Where i can find it?
    Thanks in advance.

    forgot to mention this...get the plug in here:
    http://java.sun.com/products/plugin/
    read the intstructions, u might have to do some 'applet conversion' ....u'll know what I mean when u install the plugin
    good luck

  • Can not access CRM from outside the office network - Access denied You do not have sufficient access rights or privileges to perform this action.

    Hi,
    I can not access CRM from outside the office network - Access denied You do not have sufficient access rights or privileges to perform this action.  I can access CRM with same user id and password from our office inside the network.  I can get
    the page to give login details once I have login details I got below error. Please help me to solve this issue.  It was working before.
    Access denied You do not have sufficient access rights or privileges to perform this action. 
    Regards,
    Noushad
    [email protected]

    On Premise system Configured with AD FS server for claims-based authentication you need to update your host file with server url to access it from outside office network.
    Refer
    this on how to update host file.
    Regards, Saad

  • Invoke an awt event from outside the swing application

    Is it possible to invoke an awt event triggered from outside the swing app? I am trying to implement a use case where i have to open a new tab in an already running swing app when a user clicks on a browser link.

    I have a desktop application that was invoked via webstart. The java webstart process started when the user clicked on a link that downloaded the swing application and now it runs in the clients JVM. Each browser click downloades and launches the application that performs a certain function. Now lets say, the user clicks on another link, then i don't want another java application to be launched. I want the same application that executes the function in lets say a new tab.
    Its kind of like you click on a link that somebody sent you in an outlook email. When you click on it and if firefox is already running, the link opens up in a new tab on an already running firefox browser. If firefox was not running, it starts a new firefox process.
    Hope this makes sense

  • Pages (or Numbers) Template Cannot Be Opened From Outside the Application

    Ever since the upgrade to Mavericks, I cannot open a Pages (or Numbers) template without being asked.....
    Do you want to add this custom template to the Template Chooser?  Then my only options are Cancel or Add to Template Chooser.
    If I cancel, it won't open anything.
    But this template is already in my Template Chooser.
    So the only way to open a template in Pages (or Numbers) is to open the application first, and then click "New", and choose the template.
    I can't figure out a way to open the template from outside the application, which is very very handy, rather than having to open the application every time that I want to access a template.
    How can I open a template simply by clicking on it?

    Yes, the problem is that opening the template from outside of the application will not open the application, showing the document.  I only get this....
    Do you want to add this custom template to the Template Chooser?  Then my only options are Cancel or Add to Template Chooser.
    If I cancel, it won't open anything. 
    But this template is already in my Template Chooser.
    Put your Pages or Numbers document on your desktop and open it by double-clicking it, and you'll understand.  You can't do it, even if the template is in your template chooser.
    The only way to do this now is to open the application, select "New", and the select the template.  So you cannot open a template from outside the application....only from within.

  • Numbers (or Pages) Template Cannot Be Opened From Outside the Application

    Ever since the upgrade to Mavericks, I cannot open a Numbers (or Pages) template without being asked.....
    Do you want to add this custom template to the Template Chooser?  Then my only options are Cancel or Add to Template Chooser.
    If I cancel, it won't open anything.
    But this template is already in my Template Chooser.
    So the only way to open a template in Numbers (or Pages) is to open the application first, and then click "New", and choose the template.
    I can't figure out a way to open the template from outside the application, which is very very handy, rather than having to open the application every time that I want to access a template.
    How can I open a template simply by clicking on it?

    Yes, the problem is that opening the template from outside of the application will not open the application, showing the document.  I only get this....
    Do you want to add this custom template to the Template Chooser?  Then my only options are Cancel or Add to Template Chooser.
    If I cancel, it won't open anything. 
    But this template is already in my Template Chooser.
    Put your Pages or Numbers document on your desktop and open it by double-clicking it, and you'll understand.  You can't do it, even if the template is in your template chooser.
    The only way to do this now is to open the application, select "New", and the select the template.  So you cannot open a template from outside the application....only from within.

  • Javax.swing.JPanel Help

    my application is sort of a game, i planned on having a JPanel subclass called EventPanel have an instance variable _curPanel.
    curPanel is of type JPanel. In the constructor  I can set curPanel to Other JPanel subclasses. I have another subclass of JPanel called MainScreen, which has the main screen for the game.
    I can set curPanel = new MainScreen(); in the constructor for eventPanel. And it works.
    But if I try to change _curPanel after i've made it, it wont show up. I have a method which signature 
    void setPanel(javax.swing.JPanel panel)
        _curPanel = panel;
        repaint();
    }to change the EventPanel, but nothing changes.
    In the MainScreen class there is a method call
    _eventPanel.setPanel(new NewPlayerPanel());and nothing changes in the code. I have a JTextArea logging info, and in the constructor for NewPlayerPanel at the end it prints a message in my JTextArea. The Panel is being created but not showing up.
    I have also tried creating the panel in an instance variable, setting it to setVisbile(true) and trying again and it doesnt work.

    In other words...
    char c=evt.getKeyChar();c is some character based on this event.
    if(c=='1'){Ok, let's say it is '1'...
    ...> char c2=evt.getKeyChar();Then c2 is also '1'.evt.getKeyChar() isn't going to magically change to be something different than it returned when you called it a few lines up before, so...>if(c2=='a')...this can never be true, given the above.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to access Oracle Enterpise Manager from outside my VM

    Hi,
    I've Oracle VM VirtualBox version 4.1.2 installed on the host Windows XP and pre-built Database App Development VM (Updated Nov. 2011) worked on it.
    Everything is OK, I have NAT network and can run Enterprise manager inside my VM on URL https://127.0.0.1:1158/em
    Pleas, describe shortly:
    1.How I can access enterpise manager from outside VM ?
    2.What I have to write (HOST, PORT etc) in my tnsnames.ora file on the host system for the VM Oracle server to connect it from the host system ?
    Sincerely,
    Alex
    Edited by: AlexR on Dec 31, 2011 5:24 PM

    Hi Alex,
    the host and port depends on your network setup of your VM.
    Do an ifconfig -a and see what IP adress your guest has.
    With this IP address you should be able to access EM from outside your VM (but on the VM host, not from outside the network) with the same port.
    Regards
    Sebastian

  • Refer ResourceBundle/external resources like icons from outside the Jar

    Hi,
    I have a swing application and I am using ResourceBundle to support internationalization. I also refer some icons.
    Now I have packaged my class file in a jar and I want to refer ResourceBundle and icons from outside the jar. This is to support runtime changing of values and icons without needing to recompile.
    When my code is in Eclipse and I try to refer the resource bundle, it is working fine. But as soon as I have a jar and try to refer the resource bundle from the class path, I am getting MissingResourceException.
    Please help.
    Regards,
    Manu

    As per my actual requirement, I wanted to have these properties files (resource bundles) and icons directly on the classpath, so that user has the convenience to modify them.
    I am not able to do so. I included the directory containing icons and resource bundle on the classpath, but i am not able to refer these icons from the main jar.So it works when the resources are in a 2nd jar, but not when they are in a folder that is in the classpath?
    Is the relative path of the resource files the same in both cases?
    In the simplest case (no nested folder), the icons are in the root of the jar, and the folder-equivalent is that they should be straight in the folder which you added in the classpath.
    Or are they (frequent case) in a nested folder, along your package structure, such as com/yourcompany/yourapp/gui/icon.jpg?
    In this latter case, you must not put folder "gui" in your classpath, but merely the folder which contains "com".
    I am just wild-guessing of course, for a more specific reply could you post a sketch of your jar/folder structure (in tags) and your command line, including
    the classpath part, in both the case that works and the one that doesn't?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How can I use an American credit card to pay for a membership from outside the US?

    How can I use an American credit card to pay for a membership from outside the US? My payment page is set up for Japanese credit cards. I can't change to the US store, because the "Select a Store" page just jumps to the "Products" page.
    Has anyone else had this problem? Any help would be much appreciated!

    Hi Batt5721,
    Welcome to Adobe Forums.
    The address and the country on the Credit Card should match the billing address then only payment would be possible.
    Thanks
    Garima

  • How to get the number of community members from outside the community

    Hi everyone.
    I need to know if there is any way to get the number of community members from outside the community, I mean, not using the "What's happening" webpart. I want to build up a page with a Webpart that summarize my three most visited communities indicating
    number of members, three last messages in the newsfeed, and number of posts in blog, wikis, document libraries, etc.
    Do I need statistics to get this kind of information? Should I use Sharepoint Object model instead?
    Here is an example of what I need:
    - Community name
    - Number of members
    - Community activity (messages, docs uploaded to library, etc)
    - Number of posts in calendar, blog, wiki that belongs to community
    Thank you all!

    Hi Thuan.
    Thanks for your answer but it does not help me because these communities are Sharepoint Communities not external sites so I need to get that information using SP object model and BCS in this case is useless.
    EDIT
    I found the solution using the search objects but I was only able to get members, discussions and replies
    using (ClientContext clientContext = new ClientContext("URL_OF_ENTERPRISE_SEARCH_CENTER"))
    KeywordQuery keywordQuery = new KeywordQuery(clientContext);
    keywordQuery.QueryText = "The_Name_of_the_Community WebTemplate:COMMUNITY";
    SearchExecutor searchExecutor = new SearchExecutor(clientContext);
    ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);
    clientContext.ExecuteQuery();
    System.Collections.Generic.IDictionary<string, object> ret = null;
    foreach (System.Collections.Generic.Dictionary<string, object> resultRow in results.Value[0].ResultRows)
    Console.WriteLine("{0}: {1} ({2})", resultRow["CommunityMembersCount"], resultRow["CommunityTopicsCount"], resultRow["CommunitiyRepliesCount"]);
    This is a Console Application.
    I hope someone helps

  • Premiere Pro CC's sequence lost. Is there a way to "search" for it from outside the project?

    I seem to have lost a sequence created in Premiere Pro CC. I can't find it anywhere inside the Project bin.
    We have so many same-name, older projects (between Auto-Save, different drives and so on) that looking inside each of them would take forever.
    But we do know the name of the sequence. I am wondering  if there is a way to "search" for a sequence name from outside the project?
    Thanks

    there is a way to "search" for a sequence name outside of the project,
    but it would be a pointless waste of time.
    sequences are only saved within the project file itself!!
    We have so many same-name, older projects (between Auto-Save, different drives and so on) that looking inside each of them would take forever.
    better get at it then!
    hahahahahahahaha!!!

  • Calling Options Team from outside the UK

    I am away on business and I need to call BT Options Team urgently due to a flood in my office back home. All numbers are 0800 numbers or go through to call waiting numbers with no idea how long it will take to get through. Having waited 45 minutes listening to the 'in a queue message' I had to hang up. Anyone know the correct number to call from outside the UK and how one can get through or email the team since there appears to be no one there.

    Hi daylight,
    Welcome to the forum.
    The Customer Options Team deals with cancellations so I'm not too sure how they can help if your premises are flooded, the Faults team might be a better team to speak to?
    I'll PM you their number (when calling from overseas) though if your account is a BT Business account the number will be different so I'll PM both.
    For future reference the BT Business Forum is at http://btb.lithium.com/t5/Forums/ct-p/forums
    Hope you get this sorted, I can only imagine how stressful this would be. You can also email in if you want, we'll need your BT account details and forum username sent to the email address registered against my profile.
    Thanks,
    Stephanie
    Stephanie
    BTCare Community Manager
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post. If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • I need to link to a screen within a movie from outside the movie

    Hi,
    That last question was answered so quickly, I'll ask this
    next one right away:
    I need to link to a screen within a movie from outside the
    movie (so for example, from file1.cp, I need to open file 2, screen
    4).
    Am I able to do this in Captivate 1?
    Thanks,
    Kim

    I've just gotten a chance to check out these responses. About
    the Flash - no can do. Don't have it. And about breaking the file
    apart, that would get messy because I have several files already.
    OK. At least I know my options are limited to linking to page 1
    from outside, so I'll have to be creative.
    Thanks for the response.
    Kim

Maybe you are looking for

  • MSI GT683DX-840US Will Not Boot

    Hello forum members, I have been the happy owner of a $1,400 MSI GT683DX-840US laptop for around three months now. When I first got the machine in June, I replaced the bloatware filled default install with a fresh copy of Windows 7 Ultimate x64. All

  • How to change Pricing date in VF02

    Hi, I want to change the Pricing date in the Invoice. I have created the Invoice but still the accounting entries are not posted. So now i want to change the Pricing date of the Invoice, how can i change the Pricing date. Thank U Uwanthi

  • Rep-163 Error in Reports 10g

    Hi All When I am running a report in 10g, I am facing following error. Terminated with error: <br>REP-163: Invalid value for keyword DESTYPE. Valid options are FILE, PRINTER, MAIL, INTEROFFICE, or CACHE. Kindly give any suggestions Best Regards,

  • ARTWORK AND PICTURES QUESTION

    I've been importing photos into my IPOD, but it seems everytime I bring in a new folder of pictures, it REPLACES the pictures I already have instead of just adding to them. Also, I've been selecting all my music and clicking the Get Artwork button. B

  • Personal LaserWriter 300 and Macintosh SE

    I have a Personal Laserwriter 300 and a Macintosh SE running system 6.0.8. After installing all the correct software, selecting the right settings (i think), and clicking print i get the message "There is a problem with the Printer. Check to make sur