Generics in swing?

Just wondering -- Are there any plans to use generics with swing classes? In particular, ListModel, TableModel, and (perhaps) TreeModel? After all, the default implementations of the first two must now be based on Vector<E> ...

Practical answer: I'd settle for Swing being updated to use JFC collection classes instead of Vector,
Hashtable and Dictionary...
Theoretical Answer: So then you could pass your DefaultTableModel constructor a
List<? extends List<Object>>. Woopdeedoo... For generics to rock, from the strong typing point
of view, you should be able to have, say different classes for different columns, and have that checked
at compile-time. That's way beyond what generics can or ever will do.
Positive Answer: well, generics have peeped out in a few places (like Class and Comparable), maybe
this is the kick-in the pants that will get Swing to be updated a bit. It may not help, but it couldn't hurt...

Similar Messages

  • Swing components in applet not working in web browser

    Hi Guys,
    I've created an applet which makes use of some swing components, but unfortunately, not all of them function properly in my web browser (internet explorer or Mozilla Firefox). Its mainly the buttons; the last buttons works and displays the correct file within the broswer, but the first 5 buttons do not work...
    any help please on how I can sort this problem out?
    Heres the code for my applet:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.applet.*;
    public class MainAppWindow extends JApplet
    int gapBetweenButtons = 5;
    final JPanel displayPanel = new JPanel(new BorderLayout());
    public void init()
       //Panel for overall display in applet window.
       JPanel mainPanel = new JPanel(new BorderLayout());
       mainPanel.add(new JLabel(new ImageIcon(getClass().getResource("images/smalllogo2.gif"))),BorderLayout.NORTH);
       //sub mainPanel which holds all mainPanels together.
       JPanel holdingPanel = new JPanel(new BorderLayout());
       //Panel for displaying all slide show and applications in.
       displayPanel.setBackground(Color.white);
       displayPanel.add(new JLabel(new ImageIcon(getClass().getResource("images/IntroPage.jpg"))),BorderLayout.CENTER);
       displayPanel.setPreferredSize(new Dimension(590,400));
       JPanel buttonPanel = new JPanel(new GridLayout(6,1,0,gapBetweenButtons));
       buttonPanel.setBackground(Color.white);
       JButton button1 = new JButton("User guide");
       button1.addActionListener(
         new ActionListener() {
              public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll(); // If there are any components in the mainPanel, remove them and then add label
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/UserGuide.jpg")));
                   displayPanel.revalidate(); // Validates displayPanel to allow changes to occur onto it, allowing to add different number images/applicaions to it.
       JButton button2 = new JButton("What is a Stack?");
       button2.addActionListener(
       new ActionListener() {
               public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/WhatIsAStack.jpg")));
                   displayPanel.revalidate();
       JButton button3 = new JButton("STACK(ADT)");
       button3.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/StackADT.jpg")));
                   displayPanel.revalidate();
       JButton button4 = new JButton("Stacks in the Real World");
       button4.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/StacksInTheRealWorld.jpg")));
                   displayPanel.revalidate();
       JButton button5 = new JButton("DEMONSTRATION");
       button5.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                 if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                 Demonstration app = new Demonstration();
                 JPanel appPanel = app.createComponents();//gets the created components from Demonstration application.
                 appPanel.setBackground(Color.pink);
               displayPanel.add(appPanel);
               displayPanel.revalidate();
       JButton button6 = new JButton("Towers Of Hanoi");
       button6.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                     if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                     TowerOfHanoi app = new TowerOfHanoi();
                     JPanel appPanel = app.createComponents();//gets the created components from Towers of Hanoi
                     JPanel mainPanel = new JPanel();//panel used to centralise the application in center
                     mainPanel.add(appPanel);
                     mainPanel.setBackground(Color.pink); //sets mainPanel's background color for 'Towers Of Hanoi'
                     displayPanel.add(mainPanel);
                     displayPanel.revalidate();
       //adding buttons to the buttonPanel.
       buttonPanel.add(button1);
       buttonPanel.add(button2);
       buttonPanel.add(button3);
       buttonPanel.add(button4);
       buttonPanel.add(button5);
       buttonPanel.add(button6);
       JPanel p = new JPanel(); // Used so that the buttons maintain their default shape
       p.setBackground(Color.white);
       p.add(buttonPanel);
       holdingPanel.add(p,BorderLayout.WEST);
       holdingPanel.add(displayPanel,BorderLayout.CENTER);
       //Positioning of holdingPanel in mainPanel.
       mainPanel.add(holdingPanel,BorderLayout.CENTER);
       //indent mainPanel so that its not touching the applet window frame.
       mainPanel.setBorder(BorderFactory.createEmptyBorder(10,20,10,20));
       mainPanel.setBackground(Color.white);
       mainPanel.setPreferredSize(new Dimension(850,600)); //size of applet window
       mainPanel.setOpaque(false); // Needed for Applet
       this.setContentPane(mainPanel);
    }

    Thanks for the response. I don't quite understand what you're talking about though. I have, in my humble knowledge, done nothing with packages. I have put the applet class (WiaRekenToolActiz.class is the applet class) in the jar file wia_actiz_archive.jar. From what I read on the tutorial, java looks for the applet class in all the jar files specified. Since I put my CODEBASE as the main url, I thought it baiscally didn't matter where you out the html file.
    I shall include the complete html page complete with applet tag to perhaps illuminate a bit more what I mean...
    <html>
    <head>
    <title>Wia Rekenmodule hello!</title>
    </head>
    <body bgcolor="#C0C0C0">
    <applet
    CODEBASE= "http://www.creativemathsolutions.nl/test"
    ARCHIVE= "Actiz/wia_actiz_archive.jar, Generic/wia_archive.jar"
    CODE="WiaRekenToolActiz.class" 
    WIDTH=915 HEIGHT=555
    >
    <PARAM NAME = naam VALUE = "Piet Janssen">
    <PARAM NAME = gebdag VALUE = "01">
    <PARAM NAME = gebmaand VALUE = "06">
    <PARAM NAME = gebjaar VALUE = "1970">
    <PARAM NAME = geslacht VALUE = "man">
    <PARAM NAME = dienstjaren VALUE = "10">
    <PARAM NAME = salaris VALUE = "56500">
    <PARAM NAME = deeltijdpercentage VALUE = "100">
    <PARAM NAME = accountnaam VALUE = "Zorginstelling 'De Zonnebloem'">
    </applet>
    </body>
    </html>

  • Error while running Swing program on FreeBSD

    Hi,
    I am trying to run simple swing program "helloworld"
    but while executing it gives following error on FreeBSD
    Exception in thread "main" java.lang.UnsatisfiedLinkError:
    /usr/local/linux-sun-jdk1.4.2/jre/lib/i386/libawt.so: libXp.so.6:
    cannot open shared object file: No such file or directory
            at java.lang.ClassLoader$NativeLibrary.load(Native Method)
            at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1477)
            at java.lang.Runtime.loadLibrary0(Runtime.java:788)
            at java.lang.System.loadLibrary(System.java:834)
            at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
            at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
            at java.awt.EventQueue.<clinit>(EventQueue.java:80)
            at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1170)
            at JPanels.main(JPanels.java:29)
    Should i install XFree86-libs package on FreeBsd
    configuration
    FreeBSD 4.10-BETA (GENERIC)
    I am using following packages
    linux-sun-jdk-1.4.2.04 Sun Java Development Kit 1.4 for Linux
    linux_base-8-8.0_4 Base set of packages needed in Linux mode (only for i386)
    linux_devtools-8.0_1 Packages needed for doing development in Linux mode
    libtool-1.3.5_1 Generic shared library support script
    gmake-3.80_1 GNU version of 'make' utility
    automake-1.4.5_9 GNU Standards-compliant Makefile generator (legacy version
    GCC 2.95.4
    gdb 4.18
    ld 2.12.1 supported emulation elf_i386
    regards
    Man479

    This is not really a Swing question. You should install the library which satisfies the lookup of libXp.so.6 .
    I quess the jre for this platform is compiled against this version. Looks to me like some X related library, maybe google can resolve a solution/package to install?
    Greetz

  • Bind variable value to a Swing component

    I'm totally lost in this one. I've been reading Swing tutorials and books and cant figure it out.
    I have an array of objects and their value is constantly changing as the program runs. What I want is their value reflected inside some Swing componentes. Let's say a bunch of JTextFields and on each one I want to display the value of the objects inside the array and when some of the objects value change, that change is reflected in the value displayed in the corresponding JTextField. Of course the JTextFields could be changed to lets say a JTable. Also the code responsable for changing the displayed value must be independent of the code that change the value of the objects (so the GUI part is independent of the main program)
    Can this be done somehow?? if so, could someone point me in the right direction, maybe with some tutorial/book/url ???
    Thanks a lot, and if something makes no sense, I'll try to explain better.

    Do you know about MVC (Mode View Controller) design? This is exactly what it is all about. There are many different types of implementations of MVC out there (of course in Swing also, before people start to yell at me) but all in all the spirit is pretty much the same.
    Now, for your particular problem, you have different solutions that really depends on what these objects are, what they should look like in the view and whether or not they should be editable in the view. Could you be a little bit more explicit on the matter.
    I can at least give you the idea in general terms. Let's call your objects Entry instances. They should be contained in some kind of a container class, called EntryContainer for example. The EntryContainer should act as a Facade (see the corresponding design pattern) for the rest of your application (that is, the code that change the values of the entries).
    Now, provided you have chosen a internal container (Set, List...). An Entry[] will do fine if you know that the number of entries will not change. In the opposite case, I would suggest a List instance. Then, you add the add/remove/update/whatever public methods to your EntryContainer class.
    What you have now is your model.
    Then, on to the Controller. In Java, it is easy to have a controller subclass its corresponding model. So you create EntryContainerCtrl for instance and EntryCtrl as well. Each controller should hold a reference on its presentation. The best way is to have your presentation hidden behind a generic interface (to guarantee independance from a given implementation as you pointed out in your post).
    The presentation itself should be given a link to its corresponding Controller in order to refresh.
    What you can do now is override the accessors of your model in the controller class. In each of these methods, you call super.method() of course and you add interaction with the presentation to take into account the changes.
    This is just to give you an idea of how it can be done in theory. With such a "design pattern" you can even come to a point where you can dynamically change the presentation.
    Right now, the best for you is to explain a little bit more about your specific problem and I'll be happy to help you design it in a <humble opinion>nice and efficient</humble opinion>

  • A Listener solution based on Generics and Dynamic Proxies

    Listeners are common in the java world, espacially in swing. It is easy to implement a listener, and it is easy to call an existing method that notifies all registered listeners, but it's laborious to implement this notification code itself.
    I present a small, typesafe solution called GenericListeners based on Dynamic Proxies and Generics that reduces the notification code to just a single line of code:
    IGenericListeners<FooListener> fooListeners = GenericListeners.create(FooListener.class);If FooListener looks like
    public interface FooListener {
      public onEnter(int id);
      public onExit();
    }then you can register and call Listeners with
    fooListeners.addListener(foo);
    fooListeners.call().onEnter(1);If you are interested, please have a look at
    http://www.sebastian-baltes.de/SebWiki/Wiki.jsp?page=GenericListeners
    What do you think about this?
    Message was edited by:
    Sebastian_Baltes

    Interesting point, and so I've done some tests:
    0:00:01.391 - plainest implementation
    0:00:02.469 - GenericListeners
    0:00:03.422 - javax.swing.event.EventListenerListI used a test that registers a listener and calls it 10,000,000 times in a for loop on Java 6, AMD Athlon 3000.
    I would say that GenericListeners performs well, especially compared to the EventListenerList that is used in all swing components. The problem with EventListenerList is that it stores different classes of listeners at once and has to find the right ones every time you raise an event. For my tests, I only stored one single listener into the list.
    You can imagine how bad the performance of the swing implementation would be if you have a real life example with a lot of different listener classes.

  • Deploy Swing Java DB application in Jdeveloper 11g

    Hi
    I created a simple Swing Java DB application in Jdeveloper 11g,
    after I deploy this simple swing application, I try to run the jar file, I got the following error:
    C:\Jdev1013\jdevhome\jdev\mywork\Application2\Client\deploy>java -jar myJar.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jbo/uicli/controls/JUPanel
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    Caused by: java.lang.ClassNotFoundException: oracle.jbo.uicli.controls.JUPanel

    Hi Shay,
    Thanks for your response.
    The following is what I did:
    1. connect JavaDB on my C drive by using generic jdbc
    2. create EO, VO and AM manually based on one JavaDB table (Please note: When I use the BC4J wizard, I can only create VO, the EO is empty)
    3. run BC4J tester to insert and update data
    4. created an ADF Swing application by dragging the EMPview from data control to the editor
    5. save the project and run java class
    6. create the deployment profile by following your instruction,
    and select all libraries from the Contributors list when I create the file groups
    7. deploy the jar file without any error
    8. run the jar file and get the following error:
    C:\Jdev1013\jdevhome\jdev\mywork\Application2\Client\deploy>java -jar myJar.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jbo/uicli/controls/JUPanel
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    Caused by: java.lang.ClassNotFoundException: oracle.jbo.uicli.controls.JUPanel
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    ... 12 more
    Could not find the main class: client.PanelDerbydbView. Program will exit.
    Thanks

  • Help on Generic Plugable module

    Hi to all
    I am going to create a generic plugable module for swing application. My project is a xml editor that create jtree from xml files
    and now i want some nodes on jtree that are part of generic plugable module, if i remove this module then my existing work should work properley , Please help me if someone give me example or an idea then it will be great help for me.
    Thanx

    Hi ,
    can u share ur experience for correcting this error .
    and how can i define deleta for this data sources ...
    the delta is based on the Udate field ( calander day ) ...
    i assign points....
    Regards,
    PSR

  • Daul language support to swing application

    hi
    i want to develop the swing application, which has to support two Language say Thai and english, regardless of windows settings (i.e.windows language settings)
    It may be thai window with thai keyboard or English windows
    pls suggest some solution
    rgds
    Venki

    There is a an internationalization forum which might be more helpful.
    http://forum.java.sun.com/forum.jsp?forum=16
    General internationalization can be broken into the following:
    1 - Text
    a. Program specific - never visible to user
    b. User specific - not used by the application (like text on a button)
    c. Mixed - used by the user and the application. For example a spelling checker needs to look at words.
    2 - Cultural differences
    More generic and harder to classify. For instance a 'nice' GUI in hebrew would be oriented right to left rather than left to right. This is different than simply displaying different messages. Another is icons. A icon that means something in one culture can have a completely different meaning in another (like the US hand single for 'ok'.) Another is that at least one language has numbers that have 'sex', consequently a statement like "File 1 was not found" where "1" is dynamically generated does not have a textual representation.
    Some Solution (probably not even close to all):
    1a. nothing needs to be done.
    1b. Use a resource file - see java.util.ResourceBundle. Verify that display texts always 'fits' for the targeted language. Keep in mind that outsourcing this can take a lot of time, so plan accordingly.
    1c. Use a translation layer. It starts with a given language and translates into a fixed set. A translator is needed for each target language.
    2. This requires at least one reviewer, preferably native, who is familar with the language.

  • Generic Property Editor-like panel for generic variable editing

    I am looking for a TreeTable like interface to modify a rather large list of hierarchical parameters. These parameters for example can be a bunch of class variables that may be written to a "configuration file" later on. For example:
    ParamSetA (expand/collapse available)
    |-------> ParamA1_name, ParamA1_value
    |-------> ParamA2_name, ParamA2_value
    |-------> ParamSetB
    |-------> ParamB1_name, ParamB1_value
    |-------> ParamB2_name, ParamB2_value
    ParamSetC (expand/collapse available)
    |-------> ParamC1_name, ParamC1_value
    |-------> ParamC2_name, ParamC2_value
    |-------> ParamC3_name, ParamC3_value
    ...(etc)
    Ideally, I really like the built-in property editor found say in NetBeans, or those used to edit bean properties. An example is found [in this image|http://java.sun.com/docs/books/tutorial/figures/javabeans/customization.gif], But I am not sure how to implement it so that it edits generic data (i.e. class variables) and not specific bean data.
    I understand regular tables are editable, but I like being able to expand/collapse sets to simplify the view. I understand TreeTables are available, but I haven't seen implementations for things other than a file browser, but I'm fairly new to swing.
    Any recommendations on built-in java capabilities that will help with this above concept?
    Thank you.

    You are going to have to pick a specific tree table. Hard to help you with an implementation when you haven't even chosen which component you are using. I recommend SwingX's TreeTable:
    [https://swingx.dev.java.net/]
    Questions regarding it should probably be posted on their forum rather than here though.

  • Best practice or good pattern for developing complex swing UI

    When I develop some a bit complex swing UI which maybe contain many labels, fields etc. my code becomes massive. Especially when I use GridbagLayout, when there are many components on a panel, if I want to add or remove or change one component's position sometimes I need to modify many x, y to adjust. Are there any good pattern or solution for dealing with this? Should I write my own layout? Or to find a UI designer Plugin in eclipse (but I feel the codes generated by designer are usually hard to maintain)? Thanks.

    I've recently been working with GridBagLayout. My current solution for working with this layout is to, whenever possible, create a panel builder class that builds the panel. This only works well, however, if your panel layout can be described in a generic fashion.
    For example, I have a particular layout I want to use that consists of headers that can span the entire width of a panel with sections between the headers that consist of two roughly centered columns such that each section has the same center line between the columns. I can accomplish this with GridBagLayout. So I wrote a panel builder with methods addHeader(Component) and addRow(leftComponent, rightComponent), a few other helper methods, and behind the scenes, it prepares it all using a GridBagLayout.
    Sort of like this:
    MyPanelBuilder builder = new MyPanelBuilder();
    builder.addHeading("Section 1");
    builder.addRow(fooPanel, barPanel);
    builder.addHeading("Section 2");
    builder.addRow(aPanel, bPanel);
    builder.addRow(cPanel, dPanel);
    JPanel myPanel = builder.build();Behind the scenes, the panel builder keeps a list of everything it needs to add to the panel. Then when build is called, it lays it all out in a panel using GridBagLayout and returns it.
    As for extending JFrame for your main application frame and JPanel for specific purpose application panels, I'm still not convinced it's a bad idea.

  • My source does not compile in 1.5 because of generics in libraries

    Hi,
    I have a problem with my source codes written for 1.3 and 1.4 java. I have been implementing Iterator, Collection, List and extending ArrayList in many ocassions. All works as expected in 1.4 but if I try to compile it with 1.5 it does not compile. I do receive many errors which generally speaking are showing that compiler does think that X subclass is not the same as a subclass of X<?> generic which simply makes all my code to not compile.
    Does anybody had similar problems with their code? Does anybody knows how to rewrite problematic code so that it will compile under BOTH 1.4 and 1.5 without -source 1.4 option?
    Some examples, stripped to problematic parts:
    public class CSectionList extends ArrayList
    public final boolean add(Object element)
                 int p = Collections.binarySearch(this,element);
    /** Here comes error:
    cannot find symbol
    symbol  : method binarySearch(sztejkat.utils.CSectionList,java.lang.Object)
    location: class java.util.Collections
                    int p = Collections.binarySearch(this,element);
              if (p<0)
    public class CMemoryViewTable extends JTable
    /** Here comes error:
    name clash: setDefaultRenderer(java.lang.Class,javax.swing.table.TableCellRenderer) in sztejkat.hdl.debugger.ui.CMemoryViewTable and setDefaultRenderer(java.lang.Class<?>,javax.swing.table.TableCellRenderer) in javax.swing.JTable have the same erasure, yet neither overrides the other
    public class CMemoryViewTable extends JTable
        public void setDefaultRenderer(Class columnClass,
                                             TableCellRenderer renderer)
              if (renderer!=null)
                   super.setDefaultRenderer(columnClass,new CCursorRenderer(renderer));
              }else
               super.setDefaultRenderer(columnClass,null);
    }In first example it seems to not catch that my CSectionList is a List<>, while in second it does not treat Class and Class<> equally what makes compiler to think that I don't override setDefaultRenderer method what I actually wanted to do (and did in 1.4).
    Please help...
    regards,
    Tomasz Sztejka
    P.S.
    Where the source compatibility have gone between 1.4 and 1.5? If it will look like this I strongly vote to NOT touch java language specification - it was very nice, simple and clear language. With autoboxing and generics it starts to do a lot of things behind my back what I don't like - this is why I moved from C++ to Java - hate what C++ did with overloaded operators. But maybe I'm just to stupid.

    Hi,
    I'm still not getting a good grip on generics, and still think they are not necessary.True, but when you have assembler you might not need C or Java. With assembler, you can write the most efficient programmes, but fixing a bug is not easy. With the higher level of C and Java, fewer trivial errors are made. The introduction of generics is another step towards compile-time bug prevention.
    Will your request block me from having a set of different classes,
    derived from different superclasses, all
    implementing Comparable in the way, that they use
    instanceof to check for proper relation (ie. I would
    like to sorting to sort all classes A by some value
    and all classes B to land in front of list)?Regarding raw classes, my request will change the erased interface of Comparable from
    int compareTo(Object o);to
    int compareTo(Comparable o);This would mean that all non-generic implementions of Comparable would have to be modified. I should have requested this enhancement ten years ago, but back then I did not know about Java at all :(
    Where largest common superclass is Object (ie Asuper
    is not instanceof Bsuper and vice-versa).
    Will soring list of such objects (both A and B) will
    be legal after your RFE ?Both A and B implement Comparable, so that should not be a problem.

  • ADF Swing with POJO Business Service - How To?

    Does anyone have or know of any sample code demonstrating an ADF Swing Application
    with a Master-Detail on a Business Service implemented through POJOs (not Toplink, but
    generic JavaBeans)? Please note that I am not looking for an ADF BC example!
    I need to connect to a legacy backend which does not provide a JCA
    conforming interface, so using Toplink is out of the question. I will use
    vendor-specific technology to retrieve data and put these data into
    simple JavaBeans to represent my business layer. On top of this (i. e.
    in a 2-tier architecture) I would like to implement a Swing client using
    ADF data controls and ADF data bindings.
    Thanks for your help,
    Sebastian Millies

    Hi,
    thanks for the (partial) answer. Which blog would that be, by the way?
    An additional thought: Chapter 31 of the "Developer’s Guide For Forms/4GL Developers"
    10g Release 3 (10.1.3.0), B25947-01 mentions data control adapters as an alternative to
    Java Beans to represent the data source. Why is it alternative?
    It seems that a data control adapter provides a way to specify available ui controls,
    access data source meta data and invoke operations. Couldn't this also be used in the
    scenario that I described? Would it be possible to provide the metadata to the
    adapter in the form of a BeanInfo class, or an xsd-file generated from a JavaBean?
    Perhaps I'm totally off-track here ...
    -- Sebastian

  • Need an overall brief view of developing a J2EE/Swing application

    Hello there
    I am curious to know how does a J2EE, JFC/Swing application work? I mean the front-end is coded in Swing. The backend is, say Oracle. How is the information sent to the database and retrievd back?? I know it is not so easy to explain about that here and there might be several ways as well. But if anyone could suggest me a place wherein I can get a fair idea, that would be great. Say, for example, there is a bank bank website and online transactions have to take place.... Or a purchase made at Amazon. I just want to know the various Java APIs involved in the process.
    Thak you so much. It would be of great help

    Hi,
    As you have said, at client end is a Swing GUI. The user requests usually goes either via specialized high level library, like java.sql/javax.sql for ODBC databases acces, java.rmi/CORBA for invoking some code on server, or goes directly through low level sockets (java.net) if speciall communication protocol is required.
    The exact way informations goes depends on backend implementation and protocol it uses. In most generic case, when both sides are specialized applications written in java the RMI will be propably easiest and most powerfull method.
    Ofcourse you are aware, that everything above can be done totally without java using good old CGI or PHP scripts as actually amazon.com does. If you are going to build web based front-end I strongly recommend to do it without java at user side - old CGI approach is in my opinion fastest and most user friendly way to do it (ie. think about poor creature which is using their cell-phone with www browser to see page full of java applets)

  • Download older version of Swing app using JWS

    Hi
    In my project, I have a Swing GUI which is launched using Java Web Start.
    I have to sometimes move the Swing app to a previous version i.e. I deploy a previous version of the WAR file (which has on old timestamp). But, since JWS looks for only the latest version of the Jar file, it doesn't download that Jar file.
    I looked in jnlp specification and found that cache management is done by two ways:
    1) When there is no version, timestamp is used. (as in my case)
    2) When a version is specified, then a new version is downloaded using URL/version-id pair.
    So, is there some other way I can force the app to be downloaded every time the timestamp changes on the server (whether old or new).
    Or, is there a way to include the information URL/version-id in my WAR file and force the old version to be downloaded.
    The JWS version is: 1.4.2_11.
    Your comments and suggestions are appreciated.
    Thanks

    You might 'touch' the old jar to give it a newer timestamp.
    There are a variety of tools that will do this, (including most server 'control panels'), but here is a link to the Ant based 'Touch' task.
    <http://ant.apache.org/manual/CoreTasks/touch.html>
    So, the process might be to get the old WAR, then use the Ant tasks:
    - Unzip - to extract the components
    - Touch - to put a new timestamp on the old jar file
    - War - to create the 'new' war, with updated timestamp
    - FTP (optional ant task) - to upload the lot.
    Combine those 4 tasks, and it could make for a relatively simple and painless build file for a generic fix.

  • Extending a class that uses Generics

    I'm trying to create a TableModel where the model deals with rows of data. Each row must be of the same "type", hence the need for generics. My RowTableModel is abstract. I'm trying to provide a concrete implentation for a model to use a List (ie. Vector or ArrayList) as the row type. But I can't figure out how to genericize the ListTableModel.
    import java.util.*;
    import javax.swing.table.*;
    abstract class Row2TableModel<T> extends AbstractTableModel
        protected List<T> modelData;
        private List<String> columnNames;
        private Class[] columnClasses;
        private Boolean[] isColumnEditable;
        public Row2TableModel(List<String> columnNames)
            this(new ArrayList<T>(), columnNames);
        public Row2TableModel(List<T> modelData, List<String> columnNames)
            setDataAndColumnNames(modelData, columnNames);
    //  Implement the TableModel interface
        public Class getColumnClass(int column)
            return Object.class;
        public int getColumnCount()
            return columnNames.size();
        public String getColumnName(int column)
            return "something";
        public int getRowCount()
            return modelData.size();
        public boolean isCellEditable(int row, int column)
            return true;
    //  Example of custom methods
        public T getRow(int row)
            return modelData.get( row );
        public void insertRow(int row, T rowData)
            modelData.add(row, rowData);
            fireTableRowsInserted(row, row);
        protected void setDataAndColumnNames(List<T> modelData, List<String> columnNames)
            this.modelData = modelData;
            this.columnNames = columnNames;
            columnClasses = new Class[getColumnCount()];
            isColumnEditable = new Boolean[getColumnCount()];
            fireTableStructureChanged();
        class List2TableModel extends Row2TableModel
            public List2TableModel(List<String> columnNames)
                super(columnNames);
            public List2TableModel(List<List> modelData, List<String> columnNames)
                super(modelData, columnNames);
        //  Provide implementation of TableModel methods
            public Object getValueAt(int row, int column)
                List rowData = (List)getRow( row );
                return rowData.get( column );
            @SuppressWarnings("unchecked")
            public void setValueAt(Object value, int row, int column)
                List rowData = (List)getRow( row );
                rowData.set(column, value);
                fireTableCellUpdated(row, column);
    }

    Hi,
    You mean something like that in your impementation
    class List2TableModel extends Row2TableModel<List<Integer>> {
              public List2TableModel(List<String> columnNames) {
                   super(columnNames);
              public List2TableModel(List<List<Integer>> modelData, List<String> columnNames) {
                   super(modelData, columnNames);
              // Provide implementation of TableModel methods
              public Integer getValueAt(int row, int column) {
                   List<Integer> rowData = (List<Integer>) getRow(row);
                   return rowData.get(column);
              }Regards,
    Alan Mehio
    London,UK

Maybe you are looking for

  • A zillion questions about setting up and using external hard drive

    Hello. I recently purchased a Cavalry 440GB CACE USB/FW800 7200 RPM 3.5 in Mac Formatted hard drive. My Mac is a Power PC G4 using OS X 10.2.8. After much back and forth with the Cavalry support desk, I was able to connect it to my Mac. (The USB cabl

  • Adobe fails to respond to support issue for 30 days.

    I moved to a new MacBookPro. I attempted to register my CS6 Design & Web Premium to which I upgraded in April 2013 for this new machine. The license says it is good on one work machine and one home machine. I took my old MacBook Pro home. The Adobe s

  • Window 8.1 Upgrade

    Several weeks ago I tried to upgrade to 8.1.  It was a disaster.  After an hour on the tech support line and reconfiguring to Windows 8, I decided to wait awhile.  The problem seemed to be something about the drivers supplied with 8.1.  Does anyone k

  • Extra space between paragraphs: is there a way to delete that?

    I am importing text from a word document to format in InDesign. It' 150 pages of a book that I'll layout. I made a mistake when writing the book with word by creating a space between every paragraph, which I now want to get rid of. Is there a way to

  • JRun session id being re-used

    We are using JRun 4.0 on our server in conjunction with MS IIS 6.0 to support dynamic JSP pages and Java Serlvets. We are using URL Encoding to support session handling. In the jrun- web.xml file we have the following parameters to disable the use of