Inner Classes - when to use with Swing?

Hi again,
I was creating a GUI with JTabbedPane as content pane, while doing the single panes in the different tabs i started wondering about some design issues.
Let�s say you have a pane that is composed of 3 "subpanes" ( containing all the interaction components ). Should i write "normal" classes for each of the subpanes or is it more reasonable to define them as inner classes of the "main" panel - that�s at least what i thought because those 3 smaller panels are bound to the main panel for their lifetime...
Any design tips about inner classes and swing or even inner classes in general, i�d really appreciate.
Thx

The concept of inner classes design in java is (I hope) they provide 'composite aggregation' relation with the contained class.
Means that the (inner) class cannot exists alone and provide functionalities like other classes. Inner classes refer to the "contains" relationship in the UML.
The other regular associations say, having a value oject model to an UI are Structural Aggregation, means that the value object can be used in the UI and also separately.
For your case the inner classes are not suitable. You may have to find a suitable mechanism to get the individual tab panes. Probably use an interface to bridge the three tab panes and use an manager class, pass and id to the manager class and get the required Tabbed pane.
Thanks,
ananth
Hi again,
I was creating a GUI with JTabbedPane as content pane,
while doing the single panes in the different tabs i
started wondering about some design issues.
Let�s say you have a pane that is composed of 3
"subpanes" ( containing all the interaction components
). Should i write "normal" classes for each of the
subpanes or is it more reasonable to define them as
inner classes of the "main" panel - that�s at least
what i thought because those 3 smaller panels are
bound to the main panel for their lifetime...
Any design tips about inner classes and swing or even
inner classes in general, i�d really appreciate.
Thx

Similar Messages

  • Hi! Has anybody succeeded in using Presonus Audio box 22 vsl with Os Mountain Lion? They doesn´t seem to connect. No problems when i used with Snow Leopard. I upgraded: Now is Kreonika not happy. Not happy at all!

    Hi! Has anybody succeeded in using Presonus Audio box 22 vsl with Os Mountain Lion? They doesn´t seem to connect.
    No problems when i used with Snow Leopard. I upgraded: Now Kreonika is not happy. Not happy at all!

    In cases like this, if you have an Apple store near by, they will most likely install the OS free of charge for you, if you can't bring your Apple ID along to prove you've paid for it.
    Would that work out for you?

  • Can't find class when i use java.awt.Panel

    I got a Pocket PC with CE 3.0
    I made my first PJava application just a few hours ago. And it works fine. But when i introduce a Panel to improve the interface then application fails on the Pocket PC with the error message "could not find class application". When i remove the Panel it works fine again.
    I thought that java.awt.* is part of PJava. And even if not i should be able to introduce even a java.lang.* class to the PJava application if i use the JAR.
    Any suggestion?

    you should provide more detail about your deployment procedures.
    There are many ways to get this message. AWT in fact is part of pJava and works fine for most of us. So I assume the deployment is the problem. Have you checked the actual content of the JAR? Have you provided a path statement? How do you call your app (shortcut?)

  • Why does my hotmail account will no longer allow me to reply, foreward or create new email when in use with the firefox browser but allow me to do those things when using IE?

    5-6 days ago my hotmail account began to say words to the effect that it could not perform the above described actions. I sent a few inquiries but have received no response. I opened a gmail with which seems to work just fine except for one aspect which I will mention later. When I opened IE(without add-ons) and accessed hotmail the above mentioned actions seem to work just fine. I have used firefox as my browser for about 6-7 years with no problems. The computer i use is still the same and i have made no changes other than to install MS updates which occur automatically. I'm puzzled. Can you assiist?
    The issue I'm having with gmail is that I cannot figure out how to force a log-in asking for username and password and how to force an explicit logout.
    Any assistance will be greatly appreciated.
    Phil Bayles

        I'm sorry you have not been able to utilize your text messaging AlaynaFHirsch. I recommend downloading the new software to your phone. It will definitely help with functionality issues. Are you using a 3rd party messaging application? Have you tried to perform a restore on your account?
    KinquanaH_VZW
    Follow us on Twitter @vzwsupport

  • Issue with XML post when port used with server name

    Hi Guys,
    We are currently using an agent on our application servers which puts a server in "inservice standby" if the CPU load on the system goes above 75%. This agent is using an XML post on the CSM to achieve this and put the server back inservice using XML post as well.
    Currently we are trying to use the same agent for another application which has a port number defined as well and it does not seem to work.
    To give an example where it works:
    serverfarm TEST
    nat server
    nat client TEST
    real name BLABLA
    inservice
    The example where it does not work:
    serverfarm TEST
    nat server
    nat client TEST
    real name BLABLA 50000
    When we get the server name via XML we see that CSM returns the name as BLABLA: 50000 however using the same in the script does not work.
    Would someone know how to put the port number in an XML script so that the CSM understands which server need to be changed.
    Thanks,
    Murtaza

    It would be some thing in line with the following example
    <?xml version="1.0" ?>
    The DTD for CSM XML will let you know what tags and attributes are available to use:
    http://www.cisco.com/univercd/cc/td/doc/product/lan/cat6000/mod_icn/csm/csm4
    _1_2/icn/xmldtd.htm
    HTH
    Syed

  • Visa Control grayed out when executable used with Run-time Engine

    When I run an executable on a machine with only the Run-time Engine the Visa Control for Com Ports is grayed out. I'm guessing that I am missing a library, but do not know which one.

    You need to install the VISA run-time. If you are just using VISA for serial communication, then there is an option on the app builder (Installer Settings>Advanced) for Serial Port Support. This will add a much smaller version of the VISA run-time engine to the installer you create. If you are using GPIB, etc., you have to install the hardware driver (i.e. NI-GPIB) and the full VISA run-time engine.

  • What  kind of classes I can use with JSP in tomcat? Please Help

    Hi people, I tried use the classes that I did for others application and it throw this exception :
    "org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Compiling 1 source file
    D:\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\matriculaOnLine\valide_jsp.java:14: cannot access matriculaOnLine.Connect
    bad class file: D:\Apache Group\Tomcat 4.1\webapps\ROOT\WEB-INF\classes\matriculaOnLine\Connect.class
    class file contains wrong class: Conexao
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    private Connect conn = new Connect(driver,url,login,password);
    ^
    1 error"
    I used the Connect class with java apps and it work but with JSP on TomCat4.1.27
    Can someone help me, please?
    Tiago - [email protected]

    Hi Tiago,
    I have some problems in my mind.
    Which databse you are using? and Which database driver you are using for connecting database?
    Also can you please give a code snapet that you written for connecting databse?
    ----------Milind

  • How does time machine work when being used with a mac pro?

    How does time machine work when backing up a mac pro?
    Considering the fact that the mac pro can hold 8TB and a external (non NAS) hard drive can hold only 2TB does time machine only backup the OS disk.

    macnewcomer22 wrote:
    Considering the fact that the mac pro can hold 8TB and a external (non NAS) hard drive can hold only 2TB does time machine only backup the OS disk.
    Time Machine will backup everything by default, on every disk in your Mac.
    Choose System Preferences > Options to exclude items. You could exclude everything except your OS...but I'd think it is your data that's more important to you, if you have to make choices.
    See...
    http://discussions.apple.com/thread.jspa?threadID=1964018
    While it's true you can store almost 8TB, how much do you think you'll actually store? If you have 1TB of data you want to store then a 2TB drive can do it. Also when your TM drive begins to get full it will begin deleting the oldest backups to make room.
    You could also get a Drobo with 8 bays...
    http://www.drobo.com/products/index.php
    -mj

  • Outlook 365 not bringing in emails when not used with Microsoft 365 Exchange

    We have a number of clients who were all using Outlook 2003 on Windows XP and needed to be migrated off once support ended. We have upgraded them all to Windows 7 and Office 365 including Outlook 365/2013 but as we were not able to move their domains to
    Microsoft exchange we are running Outlook connected to their email provider running IMAP email. Unless Outlook is working in Safe Mode, folders will not sync and new emails will not download. This has become such a problem that we have had to downgrade each
    client to Outlook 2010.
    It appears to us that Outlook 365 only works correctly if the domain and mail is hosted on Microsoft 365 exchange. Is this true as we have not read this anywhere and it has cost our company a lot of time and money.
    John Kirkby
    The IT Guys (WA)
    http:\\www.itguyswa.com

    Hi John,
    Since the folders and new mails can be synced in Outlook safe mode, I think the issue may be caused by any add-ins or third-party DLLs.
    In Outlook safe mode, there are some features and add-ins disabled in Outlook. We need to review the disabled features and find out which is the cause of the issue. To get the detailed steps about safe mode troubleshooting, please refer to the
    Step 6: Start Outlook in safe mode part in the following KB:
    http://support.microsoft.com/kb/2934538/en-us
    Hope it helps.
    Regards,
    Winnie Liang
    TechNet Community Support

  • No WLan Connectivity when Lan used with WRT54G

    I have a desktop-PC (Win XP-SP2) connected to Lan-port 1 on the WRT54G (v8.00.2)
    Every time the PC is on (even at boot prompt) I cannot connect any laptop (win or Linux) via WLan. If a WLan connention is already established when is PC is started, then the connection fails immediately, the network is no more visible in the available network list.
    I searched the net as well as this forum and found some aparently similar problems, but never a solution.
    Can anyone help, please?

    Try connecting the different PC to the router hard-wired and check if you are getting the same problem...? If you do not get the same problem then,try to update the driver of the NIC(wired ethernet adapter) on your computer.

  • Why and how to use "inner class"

    When i am learning advanced java language features,
    i could not understand why and when to use the "inner class",
    who can give me some examples?
    Thanks!

    You would use an inner class when an object needs visibility of the outer class. This is akin to a C++ friend.
    An example of this is an iterator. An iterator over some collection is typically implemented as an inner class of the collection class. The API user asks for an Iterator (from the Collection) and gets one - in fact they receive an instance of an inner class, but doesn't care. The iterator needs to be inner, as the iterator needs to see the internal data structures of the outer (collection) class.
    This could also be done with an anonymous class, as mentioned by spenhoet above. However, in the case of a collection, the role of the iterator is clear - thus it deserves its own class. And often there is more than one place an iterator can be returned (e.g. see java.util.List, which has several methods that return Iterators/ListIterators), thus it must be put in its own class to allow reuse of the code by outer class.

  • Getting the full value out Jdeveloper when used with Toplink.

    Hi guys. Okay, I am going to show my ignorance of Toplink and maybe even Java!
    But, I don't understand the toplink mapping process. I have done some tutorials on OTN that have me use the Table-to-Object wizard on Jdeveloper. That worked great.
    But now as I use my own real database, the tables have forgein key relationships between multiple tables and such. When I tired the same excercise with these tables, I get a crazy StackOverflowError when I try to run my test app.
    I notice that when I create the Objects at the same time, there are collections and links put in between the classes, but when I do them one at a time, I get just POJOs basically.
    So what I don't understand is, Am I supposed to bring my objects to Toplink, already created and oriented to each other?
    And what are all those links between classes when I use the wizard?

    I was looking for the exact version to have the engineers review what might have caused the issue. 10.1.3 developer preview 4 has been thoroughly tested and we have not been able to get a stack overflow exception during the POJO generation from tables.
    I would like to get a schema creation script that we could use to reproduce this issue. I can be contacted at douglas.clarke at oracle.com.
    Doug

  • Creating Private Inner Classes in Separate Files

    I sometimes find myself wanting to use private inner classes to do things, but then moving the classes to separate files and giving them package access just because I don't like having single large files.
    Is there a way to create private inner classes on a class but just save them in another file?
    Thanks,
    John

    For me, short file sizes usually make design structure
    more clear. This can make maintenance easier. It can
    also make browsing the code easier, even if you have a
    good editor or IDE. It is also less intimadating
    psychologically (for me, anyway) to work with a number
    of small files, each one with a distinct purpose, than
    it is to open up a monster, even if the monster does
    represent a coherent design unit in some sense. I
    think this psychological impact may be more important
    than most people give it credit for.The psychological impact is lessened if you use an IDE like VisualAge (where only one method at a time is generally displayed) or use the "Show Source Of Selected Element Only" option in Eclipse.
    It's one thing to say a method should be short and a class should have as few methods as possible. Those forces reduce complexity and ease maintenance. It's another to say a source file should be short. A source file is just a storage artifact; source code could be stored in a database without changing how the programmer interacts with it. The fact that the standard java compiler requires the implementation of nested classes to be stored inside the source file of their containing class is a minor inconvenience. Don't let it discourage you from using inner classes when they make sense. The design should not be driven by source file size considerations.
    >
    But you have added code only with the sole intent of
    making a source file smaller. If Java had amechanism
    for storing nested classes in other files youwouldn't
    do this. My point below was that you shouldn't let
    source file size override the decision to use anested
    class.Why shouldn't I let it? There are plenty of
    non-trivial benefits (the ones I gave above, for
    starters) to working with smaller files.Because all of those benefits can be gained from using a decent IDE. Eclipse is free. It can show only the current method and it can collapse nested classes.
    You say "If
    Java had a mechanism...." Well, I could answer: It
    does have such a mechanism, and that mechanism is
    packages.Packages are not a mechanism for creating private inner classes in separate files. Eclipse has a mechanism for making the fact that they reside in the same source file a non-issue.
    >>
    I am not being cavalier. I have no argument, onlyan
    opinion.Again, you are perfectly entitled to your opinion.
    But if it is truly an opinion, and nothing more, why
    bother telling me about it. You might as well post
    your favorite color. It is the reasons for your
    opinion that interest me, and you still have not
    really given any.I have had lengthy arguments about the issue of method and class size. Like I said before, I prefer very small classes and methods. I also think the number of nested classes should be as small as possible. But I have no problem with large files. Files are just one way to organize source code. The size of the things in the files matters, not the files themselves.

  • Application & JApplet - Inner Classes

    Hi,
    I am having problems understanding the purpose of Inner Classes.
    1. Is purpose of inner class in an Application to take care of what init method
    takes care of in a JApplet. I believe init method in JApplet brings up the browser and
    xecutes statements in init()?
    2. Is it possible to write the enclosed Application without using an Inner Class?
    If so, can someone please show me how?
    3. Is it possible to write the enclosed JApplet using an inner Class?
    If so, can someone please show me how?
    Maybe if I see how an Application and JApplet are written with and without inner classes, this may help me understand.
    Thank you.
    //APPLICATION USING AN INNER CLASS
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    //outerclass
    public class InnerTest extends JFrame
    private JTextField numField, sumField;
    private int sum = 0;
    public InnerTest()
    super("Inner Test");
    Container c = getContentPane();
    c.setLayout(new FlowLayout());
    ActionEventHandler handler = new ActionEventHandler();
    numField = new JTextField(10);
    sumField = new JTextField(10);
    numField.addActionListener(handler);
    c.add(numField);
    c.add(sumField);
    public static void main(String args[])
    InnerTest win = new InnerTest();
    win.setSize(400, 140);
    win.show();
    //Innerclass
    private class ActionEventHandler implements ActionListener
    public void actionPerformed(ActionEvent e)
    sum += Integer.parseInt(numField.getText()); // access to sum and numField
    numField.setText("");
    sumField.setText(Integer.toString(sum));
    JAPPLET
    Below is modification of above code to a JApplet
    without using inner class. I have CAPITALIZED MODIFICATIONS.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class InnerTest extends JAPPLET
    private JTextField numField, sumField;
    private int sum = 0;
    public VOID INIT()
    super("Inner Test");
    Container c = getContentPane();
    c.setLayout(new FlowLayout());
    ActionEventHandler handler = new ActionEventHandler();
    numField = new JTextField(10);
    sumField = new JTextField(10);
    numField.addActionListener(THIS);
    c.add(numField);
    c.add(sumField);
    public void actionPerformed(ActionEvent e)
    sum += Integer.parseInt(numField.getText()); // access to sum and numField
    numField.setText("");
    sumField.setText(Integer.toString(sum));

    1. Is purpose of inner class in an Application to
    take care of what init method
    takes care of in a JApplet. I believe init method in
    JApplet brings up the browser and
    xecutes statements in init()?No. The init() method of an applet is similar to the constructor for an application. It is used to initialize data for the applet, the same data you will initialize in the constructor of the application.
    >
    2. Is it possible to write the enclosed Application
    without using an Inner Class?Yes it is possible. The power of an inner class is that is has access even to private member variables of the enclosing class. In your case the event handler has access to the private variables: numField and sumField. If you do not use an inner class you have to pass a reference to your frame in the event handler's constructor and access the variables through that reference. But in this case you do not have access to private variables. So you must provide methods to access those variables or you must change theri visibility.
    ActionEventHandler handler = new ActionEventHandler(this);Provide accessor methods in InnerTest class:
    public String getTextString(){
         return numField.getText();
    public void setTextString(String text){
         numField.setText(text);
    }As for the applet it works just as your application in this case, you can use inner classes or not but with the same restrictions.
    I hope you can understand what I tried to explain.

  • Inner class access to its creator

    Hi there,
    From a subclass of Action I have created as a (non-static) inner class of a JFrame, I wish to reference the parent JFrame in a JFileChooser invocation, so something like:JFileChooser.showSaveDialog(**this**);with **this** being the parent JFrame.
    One option I can think of is to pass through "this" when I instantiate the action, but I wondered if there was a language construction that provided this information directly.
    I tried a search through the forums using "parent of an inner class" but found nothing useful. Is there a mechanism to provide this, or is passing "this" through to the inner class the only option?
    Thanks for any help you can provide.
    Tim

    To access wrapper instance of inner class, you can use WRAPPER_INSTANCE_CLASS.this keyword.
    For example:
    public class a {
       int value = 0;
       public void doSomething() {
          Object dummy = new Object() {
              public String toString() {
                  a.this.setSomething(10);
                  return a.this.toString();
          System.out.println(dummy);
       public void setSomething(int x) {
          value = x;
       public String toString() {
          return "class a, the value now is " + value;
       public static void main (String s[]) {
           new a().doSomething();
    }note that I use a.this.setSomething(10);
    a is the wrapper class, so a.this refers to the wrapper instance, not current instance.
    rgds,
    Alex

Maybe you are looking for