Inheritance In Swing

Hi,
I have a confusion in understanding the behaviour of below code
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Test extends JPanel
     private static final String butHireLabel = "Hire";
     private static final String butFireLabel = "Fire";
     private JButton butFire;
     private JButton butHire;
     private JTextField txtEmployeeName;
     public Test()
          super(new BorderLayout());
          butHire = new JButton(butHireLabel);
          butHire.setEnabled(false);
          butFire = new JButton(butFireLabel);
          txtEmployeeName = new JTextField(10);
          //Create a panel that uses BoxLayout.
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new BoxLayout(buttonPane,
                                           BoxLayout.LINE_AXIS));
        buttonPane.add(butFire);
        buttonPane.add(Box.createHorizontalStrut(5));
        //buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
        buttonPane.add(txtEmployeeName);
        buttonPane.add(Box.createHorizontalStrut(5));
        buttonPane.add(butHire);
        buttonPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
        add(buttonPane, BorderLayout.PAGE_END);          
     public static void createAndShowGUI()
          //Window decoration
          JFrame.setDefaultLookAndFeelDecorated(true);
          //Create and setup window
          JFrame frame = new JFrame("List Demo");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          //Create and setup window pane
          JComponent newContentPane = new Test();          newContentPane.setOpaque(true);
          frame.setContentPane(newContentPane);
          //Display window
          frame.pack();
          frame.setVisible(true);
     public static void main(String[] args)
          // Schedule a job for event-dispatching thread
          // Creating and displaying this application GUI
          javax.swing.SwingUtilities.invokeLater(new Runnable()
               public void run()
                    createAndShowGUI();
When I extend JFrame the code marked bold gives type casting error.
This may be very trivial but as I am in the learning stage I cannot understand the behaviour.
Thanks,
Reena

Sorry the line of error wasn't clear in my previous post.
When JFrame is extended instead of JPanel in the above code the typecasting error is generated at below line
JComponent newContentPane = new Test();
Thanks,
Reena

Similar Messages

  • How to inheritance a super class without no-argument constructor

    i try to inheritance javax.swing.tree.DefaultTreeModel:
    public class myTreeModel extends DefaultTreeModel
    but the compiler say:
    'constructor DefaultTreeModel() not found in class javax.swing.tree.DefaultTreeModel'
    and stoped.
    How can I get around this?
    THANK YOU for your consideration.

    Inside myTreeModel, i tried several things:
    1. add a no-argument constructor;
    Your no argument constructor should be either one of the below :
    public myTreeModel() {
       super(new DefaultMutableTreeNode());
    public myTreeModel() {
       super(new DefaultMutableTreeNode(), true);
    2. add a contructor with (DefaultTreeNode) argument;
    Your constructor with tree node argument should be either one of the below :
    public myTreeModel(DefaultMutableTreeNode node) {
       super(node);
    public myTreeModel(DefaultMutableTreeNode node) {
       super(node, true);
    }You would get an error if you did the following:
    public myTreeModel() {
    public myTreeModel(DefaultMutableTreeNode node) {
    }In both of the cases the default no arguement constructor of the super class is called implicitly like:
    public myTreeModel() {
       super();
    public myTreeModel(DefaultMutableTreeNode node) {
       super();
    }In this case the call super() is refering to a no arguement constructor in DefaultTreeModel. However, no such constructor exists in the DefaultTreeModel class resulting in a compile time error.
    Note: You do not need to use DefaultMutableTreeNode. You an use some other class that implements the TreeNode interface.

  • Legacy code refactoring

    I have inherited a swing Applet project and there's a bunch of dodgy code, once of them is that the first parameter in most of the constructors is an "owner" reference to the Japplet extension.
    Because the code parts are not decoupled it is hard to extract functional units in order to use them for tests, demos or to re-use them in other projects.
    Looking at the code (30 .java modules) about half of the units reference the "owner" to access up to 50 different properties and methods. It's been suggested that I uses the interface segregation principle ("Refactoring: Improving the Design of Existing Code", Martin Fowler) to refactor to use an interface rather than the applet reference.
    Are there any other suggestions on how to reference the Applet in the other Java units without the code being so coupled?
    All comments are appreciated.
    Thanks, Tom.

    I would use interfaces, but I would also look at the code and wonder why 30 classes need to access 50 methods in this monster class. You might be able to move some logical code together or create some utility classes.

  • PL/SQL and Java Swing interface

    Everybody in this forum knows that Oracle is the best database around
    with many functionalities, stability, performance, etc. We also know
    that PL/SQL is a great language to manipulate information directly
    in the database with many built in functions, OOP capability,
    transaction control, among other features. Today an application that
    manipulates information, which needs user interface, requires components
    to be developed using different technologies and normally running in
    different servers or machines. For example, the interface is done using
    a dynamic HTML generator like JSP, PHP, PL/SQL Web Toolkit, etc.
    This page is executed in an application server like Oracle iAS or
    Tomcat, just to name two, which in turn access a database like Oracle to
    build the HTML. Also rich clients like Java applets require an intermediate
    server to access the database (through servlets for example) although
    it is possible to access the database directly but with security issues.
    Another problem with this is that complexity increases a lot, many
    technologies, skills and places to maintain code which leads to a greater
    failure probability. Also, an application is constantly evolving, new
    calculations are added, new tables, changed columns. If you have an
    application with product code for example and you need to increase its
    size, you need to change it in the database, search for all occurrences
    of it in the middle-tier code and perhaps adjust interfaces. Normally
    there is no direct dependency among the tier components. On another
    issue, many application interfaces today are based on HTML which doesn't
    have interactive capabilities like rich-client interfaces. Although it
    is possible to simulate many GUI widgets with JavaScript and DHTML, it is
    far from the interactive level we can accomplish in rich clients like
    Java Swing, Flash MX, Win32, etc. HTML is also a "tag-based" language
    originally created to publish documents so even small pages require
    many bytes to be transmitted, far beyond of what we see on the screen.
    Even in fast networks you have a delay time to wait the page to be
    loaded. Another issue, the database is in general the central location
    for all kinds of data. Most applications relies on it for security,
    transaction and availability. My proposal is to use Oracle as the
    central location for interface, processing and data. With this approach
    we can create not only the data manipulation procedures in the database,
    but procedures that also control and manage user interfaces. Having
    a Oracle database as the central location for all components has many
    advantages:
    - Unique point of maintenance, backup and restore
    - Integrated database security
    - One language for everything, PL/SQL or Java (even both if desired)
    - Inherited database cache, transaction and processing optimizations
    - Direct access to the database dictionary
    - Application runs on Oracle which has support for many platforms.
    - Transparent use of parallel processing, clusters and future
    background technologies
    Regarding the interface, I already created a Java applet renderer
    which receives instructions from the database on how to create GUI
    objects and how to respond to events. The applet is only 8kb and can
    render any Swing or AWT object/event. The communication is done
    through HTTP or HTTPS using Oracles's MOD_PLSQL included in the Apache
    HTTP server which comes with the database or application server (iAS).
    I am also creating a database framework and APIs in PL/SQL to
    create and manipulate the client interface. The applet startup is
    very fast because it is very small, you don't need to download large
    classes with the client interface. Execution is done "on-demand"
    according to instructions received from the database. The instructions
    are very optimized in terms of network bandwidth and based on preliminary
    tests it can be up to 1/10 of a similar HTML screen. Less network usage
    means faster response and means that even low speed connections will
    have a good performance (a future development can be to use this in
    wireless devices like PDAs e even cell phones, just an idea for now).
    The applet can also be executed standalone by using Java Web Start.
    With this approach no business code, except the interface, is executed
    on the client. This means that alterations in the application are
    dynamically reflected in the client, no need to "re-download" the
    application. Events are transmitted when required only so network
    usage is minimized. It is also possible to establish triggering
    events to further reduce network usage. Since the protocol used is
    HTTP (which is stateless), the database framework I am creating will
    be responsible to maintain the state of connections, variables, locks
    and session information, so the developer don't need to worry about it.
    The framework will have many layers, from communication up to
    application so there will be pre-built functions to handle queries,
    pagination, lock, mail, log, etc. The final objective is to have a
    rich client application integrated into the database with minimum
    programming and maintenance requirements, not forgetting customization
    capabilities. Below is a very small example of what can de done. A
    desktop with two windows, each window with two fields, a button with an
    image to switch the values, and events to convert the typed text when
    leaving the field or double-clicking it. The "leave" event also has an
    optimization to only be triggered when the text changes. I am still
    developing the framework and adjusting the renderer but I think that all
    technical barriers were transposed by now. The framework is still in
    the early stages, my guess is that only 5% is done so far. As a future
    development even an IDE can be created so we have a graphical environment
    do develop applications. I am willing to share this with the PL/SQL
    community and listen to ideas and comments.
    Example:
    create or replace procedure demo1 (
    jre_version in varchar2 := '1.4.2_01',
    debug_info in varchar2 := 'false',
    compress_buffer in varchar2 := 'false',
    optimize_buffer in varchar2 := 'true'
    ) as
    begin
    interface.initialize('demo1_init','JGR Demo 1',jre_version,debug_info,compress_buffer,optimize_buffer);
    end;
    create or replace procedure demo1_init as
    begin
    toolkit.initialize;
    toolkit.create_icon('icon',interface.global_root_url||'img/switch.gif');
    toolkit.create_internal_frame('frame1','Frame 1',50,50,300,136);
    toolkit.create_label('frame1label1','frame1',10,10,50,20,'Field 1');
    toolkit.create_label('frame1label2','frame1',10,40,50,20,'Field 2');
    toolkit.create_text_field('frame1field1','frame1',50,10,230,20,'Field 1','Field 1',focus_event=>true,mouse_event=>true);
    toolkit.create_text_field('frame1field2','frame1',50,40,230,20,'Field 2','Field 2',focus_event=>true,mouse_event=>true);
    toolkit.set_text_field_event('frame1field1',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 1','false');
    toolkit.set_text_field_event('frame1field2',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 2','false');
    toolkit.set_text_field_event('frame1field1',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 1','false');
    toolkit.set_text_field_event('frame1field2',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 2','false');
    toolkit.create_button('button1','frame1',10,70,100,25,'Switch','Switch the values of "Field 1" and "Field 2"','S','icon');
    toolkit.set_button_event('button1',toolkit.action_performed_event,'demo1_switch_fields(''frame1field1'',''frame1field2'')','frame1field1:'||toolkit.get_text_method||',frame1field2:'||toolkit.get_text_method);
    toolkit.create_internal_frame('frame2','Frame 2',100,100,300,136);
    toolkit.create_label('frame2label1','frame2',10,10,50,20,'Field 1');
    toolkit.create_label('frame2label2','frame2',10,40,50,20,'Field 2');
    toolkit.create_text_field('frame2field1','frame2',50,10,230,20,'Field 1','Field 1',focus_event=>true,mouse_event=>true);
    toolkit.create_text_field('frame2field2','frame2',50,40,230,20,'Field 2','Field 2',focus_event=>true,mouse_event=>true);
    toolkit.set_text_field_event('frame2field1',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 1','false');
    toolkit.set_text_field_event('frame2field2',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 2','false');
    toolkit.set_text_field_event('frame2field1',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 1','false');
    toolkit.set_text_field_event('frame2field2',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 2','false');
    toolkit.create_button('button2','frame2',10,70,100,25,'Switch','Switch the values of "Field 1" and "Field 2"','S','icon');
    toolkit.set_button_event('button2',toolkit.action_performed_event,'demo1_switch_fields(''frame2field1'',''frame2field2'')','frame2field1:'||toolkit.get_text_method||',frame2field2:'||toolkit.get_text_method);
    end;
    create or replace procedure demo1_set_upper as
    begin
    toolkit.set_string_method(interface.global_object_name,toolkit.set_text_method,upper(interface.array_event_value(1)));
    toolkit.set_text_field_event(interface.global_object_name,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(1)),'false');
    end;
    create or replace procedure demo1_set_lower as
    begin
    toolkit.set_string_method(interface.global_object_name,toolkit.set_text_method,lower(interface.array_event_value(1)));
    toolkit.set_text_field_event(interface.global_object_name,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(1)),'false');
    end;
    create or replace procedure demo1_switch_fields (
    field1 in varchar2,
    field2 in varchar2
    ) as
    begin
    toolkit.set_string_method(field1,toolkit.set_text_method,interface.array_event_value(2));
    toolkit.set_string_method(field2,toolkit.set_text_method,interface.array_event_value(1));
    toolkit.set_text_field_event(field1,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(2)),'false');
    toolkit.set_text_field_event(field2,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(1)),'false');
    toolkit.set_text_field_event(field1,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(2)),'false');
    toolkit.set_text_field_event(field2,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(1)),'false');
    end;

    Is it sound like Oracle Portal?
    But you want to save a layer 9iAS.
    Basically, that was the WebDB.(Oracle changed the name to Portal when version 3.0)
    Over all, I agree with you.
    >>Having a Oracle database as the central location for all components has many
    >>advantages:
    >>
    >>- Unique point of maintenance, backup and restore
    >>- Integrated database security
    >>- One language for everything, PL/SQL or Java (even both if desired)
    >>- Inherited database cache, transaction and processing optimizations
    >>- Direct access to the database dictionary
    >>- Application runs on Oracle which has support for many platforms.
    >>- Transparent use of parallel processing, clusters and future
    >>background technologies
    I would like to build 'ZOPE' inside Oracle DB as a back-end
    Using Flash MX as front-end.
    Thomas Ku.

  • Custom Inherited/Derived Class & the Data Warehouse

    Hi there,
    I'd like to reference an older post by Travis in regards to getting a Custom Class into the Dataware House:
    DW Reporting on Custom Class
    Scenario:
    I've created an Inherited/Derived Class, with its own Form (not an
    Extension).
    This Class Inherits from the Base Incident Class.
    Inherited Class has two (2) new properties (a String and a List Property).
    Class and Form is all working well within the SCSM Console.
    By default, this class is inheriting all the Relationships (like AssignedTo, AffectedUser, CreatedBy, HasConfigItem) from the Base Incident Class without me having to do anything in the mp apart from including the <Reference> & <TypeProjection>
    components.
    To get this class I am aware that it has
    to be defined - as in a new dimension has to be created for this Derived Class.
    Questions:
    1. Is it recommended to have these dimension/s in a separate sealed mp, or include it with the derived Class mp (sealed) - is there a best practice?
    2. Online resources (technet and other) state a dimension has to be created for the new Class <Dimensions>, but do I also need to include <Outriggers> as well as <Facts>
    for this Class?

    In JDeveloper 10.1.2, I configure in adfjclient_binding.xml:
    <controlDefinition name="JTable Ext"
    className="com.lib.swing.JTableExt"
    classPath=""
    shortLabel="JTableExt"
    longLabel="com.lib.swing.JTableExt"
    tooltipText="com.lib.swing.JTableExt"
    bindingType="DCTable"
    icon="/oracle/ideimpl/resource/images/palette/JTable.gif">
    <useTemplate>
    <![CDATA[${FieldName}.setBinding(panelBinding,"${BindingName}","${IteratorBinding.getId()}")]]>
    </useTemplate>
    <imports>
    <![CDATA[javax.swing.JTable;javax.swing.table.TableModel;com.lib.swing.JTableExt]]>
    </imports>
    </controlDefinition>
    and In my projects, I only drag and drop JTableExt into my form, it auto generate code:
    jTableExt1.setBinding(panelBinding, "SubProfileTypeView2", "SubProfileTypeView1Iterator");
    because setBinding function of JTableExt in my library, it contains setmodel function and some other function.
    Now, In JDeveloper 10.1.3, I drag and drop JTableExt into my form and I have to code one line:
    jTableExt1.setBinding(panelBinding, "SubProfileTypeView2", "SubProfileTypeView1Iterator");
    Which way is there, I haven't to code?
    Jacque

  • How to use mousedown applet function in swing?

    hai,
    i need to use the applet mousedown function in swing..
    is there any way to use it or any other alternative is available for this?
    if can provide me a sample code.

    >
    i need to use the applet mousedown function in swing..>There is no such class as 'applet' in the JRE, Swing has an upper case 1st letter, functions in Java are generally referred to as methods, and there is no 'mousedown' method in the JRE.
    OTOH a Swing JApplet inherits the mouseDown method from Component, and it was deprecated in Java 1.1. The documentation (JavaDocs) provides instructions on what to use instead.
    >
    is there any way to use it or any other alternative is available for this?
    if can provide me a sample code.>If can provide me cash. Short of that, you might actually need to do some research/coding of your own.
    As an aside. What does any of this have to do with Java 2D?

  • Help with RMI using inheritance program

    Hi all, im having trouble starting (and finding info on how to) to convert this program to use RMI. I have just completed re-structuring the program to use extended inheritance along with a Access Database.
    Whats the first step i need to take.
    Any help will be much appreciated. THANKS ALL
    import java.sql.*;
    import javax.swing.*;
    import java.util.*;
    public class Database {
       public java.sql.Connection connection;
       public void connect() 
          String url = "jdbc:odbc:groupTask2";  
          String username = "admin";   String password = "teama";
          // Load the driver to allow connection to the database
          try {
             Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
             connection = java.sql.DriverManager.getConnection(url, username, password );
          catch ( ClassNotFoundException cnfex ) {
             System.err.println("Failed to load JDBC/ODBC driver->"  + cnfex);
          catch ( SQLException sqlex ) {
             System.err.println( "Unable to connect->" + sqlex );
       public void showTeams()
          java.sql.Statement statement;
          java.sql.ResultSet resultSet;
          try {
             String query = "SELECT Team_name FROM Team_class";
             statement = connection.createStatement();
             resultSet = statement.executeQuery( query );
             displayResultSet( resultSet );
             statement.close();
          catch ( SQLException sqlex ) {
             sqlex.printStackTrace();
       public void showPlayers()
          java.sql.Statement statement;
          java.sql.ResultSet resultSet;
          String team = null;
          try {
             String s = JOptionPane.showInputDialog("Please select Team: \n\n1. Panthers \n2. Quails \n3. Bears \n4. Nevils \n ");
             int a = Integer.parseInt(s);
             switch (a){
                 case 1: team = "Panthers";
                         break;
                 case 2: team = "Quails";
                         break;
                 case 3: team = "Bears";
                         break;
                 case 4: team = "Nevils";
                         break;
             String query = "SELECT player_id, First_name, Last_name FROM Player_class WHERE Team_name LIKE '"+team+"'";
             statement = connection.createStatement();
             resultSet = statement.executeQuery( query );
             displayResultSet( resultSet );
             statement.close();
          catch ( SQLException sqlex ) {
             sqlex.printStackTrace();
       public void update()
          java.sql.Statement statement;
          java.sql.Statement statement2;
          java.sql.ResultSet resultSet;
          String field = null;
          try {
             String a = JOptionPane.showInputDialog("Please Enter the player ID:");
             int id = Integer.parseInt(a);
             String b = JOptionPane.showInputDialog("Which field would you like to update? \n\n1. First name \n2. Last name \n3. Address \n ");
             int choice = Integer.parseInt(b);
             switch (choice){
                 case 1: field = "First_name";
                         break;
                 case 2: field = "Last_name";
                         break;
                 case 3: field = "address";
                         break;
             String val = JOptionPane.showInputDialog("Please enter new " +field);
             String query = "UPDATE Player_class SET "+field+" = '"+val+"' WHERE player_id = "+id;
             statement = connection.createStatement();
             statement.executeQuery( query );
             statement.close(); 
          catch ( SQLException sqlex ) {
             sqlex.printStackTrace();
       public void displayResultSet( ResultSet rs )
          throws SQLException
          // position to first record
          boolean moreRecords = rs.next();  
          // If there are no records, display a message
          if ( ! moreRecords ) {
                System.out.println( "ResultSet contained no records" );
                return;
          System.out.println( "" );
          try {
             java.sql.ResultSetMetaData rsmd = rs.getMetaData(); 
             // Get column heads
             for ( int i = 1; i <= rsmd.getColumnCount(); ++i ) {
                 System.out.print(rsmd.getColumnName( i ) + "\t");
             System.out.println();
             do {// get row data
                  displayNextRow( rs, rsmd );
             } while ( rs.next() );
          catch ( SQLException sqlex ) {
             sqlex.printStackTrace();
       public void displayNextRow( ResultSet rs, 
                                  ResultSetMetaData rsmd )
           throws SQLException
          for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
             switch( rsmd.getColumnType( i ) ) {
                case java.sql.Types.VARCHAR:
                      System.out.print (rs.getString( i )+"\t\t" );
                   break;
                case java.sql.Types.INTEGER:
                      System.out.print ( rs.getLong( i ) + "\t\t") ;
                   break;
                default: 
                   System.out.println( "Type was: " + 
                      rsmd.getColumnTypeName( i ) );
             System.out.println();
       public void shutDown()
          try {
             connection.close();
          catch ( SQLException sqlex ) {
             System.err.println( "Unable to disconnect->" + sqlex );
       public static void main( String args[] ) 
           int sel = 0;
           Menu M = new Menu();
           Database app = new Database();
           sel = M.mainmenu(sel);
           while (sel > 0 && sel < 5){
           switch (sel){
               case 1: app.connect();
                       app.showTeams();
                       app.shutDown();
                       sel = M.mainmenu(sel);
                       break;
               case 2: app.connect();
                       app.showPlayers();
                       app.shutDown();
                       sel = M.mainmenu(sel);
                       break;
               case 3: app.connect();
                       app.update();
                       app.shutDown();
                       sel = M.mainmenu(sel);
                       break;
    class Menu{ 
        int choice = 0;
        int temp = 0; 
        public Menu(){
        public int mainmenu(int val){ 
            String a = JOptionPane.showInputDialog("TEAM MENU \n\nPlease select an option by entering " + 
                    "the corresponding number: \n\n1. Display Teams \n2. Show Players \n3. Update a Player \n4. Search \n "); 
            val= Integer.parseInt(a); 
            return val; 
        public int setChoice(int val){
            choice = val;
            return choice;

    Well, I'd say a starting point is to split the functionality into "client" and "server". This will wind up as two programs, the client making - remote - requests of the server.
    A fairly natural way would be to assign viewing/display to the client, direct access to the database to the server. So then you have to figure out
    o what kinds of requests can go acrross the divide.
    o what kind of data will be returned.
    This may not be that easy, because things that the server can do easily (like I/O) cnnot be carried back and forth in RMI calls.)

  • Question about inheritance

    I'm attempting to write Monopoly and I'm having some inheritance problems. Every space on the board is first and foremost of type BoardSpace however some of them are of type Property which extends BoardSpace and some are of type Chance/Community which also extend BoardSpace etc. Depending on what type of space it is something different happens. Right now heres how a couple of classes look. I'm having a problem where if I land on a space that doesn't define its own action method, it defaults to the BoardSpace action method as it should yet it goes into that if statement even when it clearly shouldn't be. Like if I land in jail, it will still go into that if statement, and it will print Jail (3 times). Is this something funky with inheritance?
    BoardSpace:
    public class BoardSpace extends JPanel
         Location loc;
         String name;
         public BoardSpace(String s, Location l)
              loc = l;
              name = s;
         public void action(Player p)
              if(name.equals("Go"));//If name is "go" how can it also be "jail" ?
                   System.out.println(name);
                   System.out.println(this.name);
                   System.out.println(p.spot.name);
                   p.money+=200;
    }Property:
    import javax.swing.*;
    public class Property extends BoardSpace
         Player owner = null;
         public Property(String s, Location l)
              super(s,l);
         public void action(Player p)
              if(owner!=null && owner!=p)
                   JOptionPane.showMessageDialog(this,"You landed on "+this.name+".\n This property is owned by Player" +owner.number+".\n You owe $5");
              else
                   JOptionPane.showInputDialog("Buy?");
    }

    duckbill wrote:
    Hint: you can launch JOptionPane dialogs without a single panel, frame etc...
    #You can also launch dialogs with panels, frames, etc... but without subclassing Property from JPanel
    Edited by: DrLaszloJamf on Oct 3, 2007 12:42 PM

  • Inheritance problems

    I'm trying to work out a problem with a project I'm working on that uses inheritance.
    the superclass consists of a prebuild GUI using swing, when more then one class enherits from the superclass for some reason its like they are sharing the subclass, any changes to the GUI done in one subclass affects the other, so if I add a JScrollPane to the Container from the inherited class it stayes after the window is closed AND its there when the other subclass runs.
    What I want is for both subclasses to have their own instances of the subclass, or in other words I don't want the changes done in one subclass to affect the other subclass, is this possible?
    My best guess is that instead of getting their own copy of the subclass they are sharing the same one so when one subclass does any changes the other reflects those changes because they are working with the exact same instance of the superclass. I have an idea of what my problem is I just don't know how to stop it from hapening.

    It seems to me you are very confused as to how your inheritance tree works and from your description there is a clear design fault. It may well be you are diasy-chaining your classes and have got design in a fart with logic and flow - ie:
    class A{ // superclass
    class B extends A{} // so if B is an application GUI
    class C extends B{} // C gets messed up
    class D extends C{} // and application GUI D gets knackered too
    This type of design rarely works well (if at all). You need to literally go back to the 'drawing board' and consider what you're trying to do with good design principles.
    I'm not sure anyone here can really help you with this unless you give a detailed description of what you're trying to do (not code), though from what I CAN gather it should be something like;-
    class AllComponentsFrame{}
    /* class AmendedComponentsFrame1 extends AllComponentsFrame{} // maybe? */
    class FinalGUI1 extends AllComponentsFrame{}
    class FinalGUI2 extends AmendedComponentsFrame1 {}

  • Window inheritance problem, implementation question

    This is a multi-part message in MIME format.
    --------------F5AF60803BB8EFA34C8D4288
    Content-Type: multipart/alternative;
    boundary="------------24CDBE5DFBEC0C4205C15C80"
    --------------24CDBE5DFBEC0C4205C15C80
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Hi!
    I have a window inheritance and implementation question. I'm using
    Forte 3.0.J.1.
    I have a super (base) window with a PushButton on it. I want to
    handle the Click event of the button in this super window therefore
    I create an event handler.
    <MyBtn> : PushButton
    I create a sub window inheriting from the previous super window.
    I put some data widgets on it and group all of them (the inherited
    button as well) into a GridField. When I set the mapped type of the grid
    the name of the inherited PushButton widget changes:
    <MainGrid.MyBtn> : PushButton
    When I run the application I get a SystemException with the
    message:
    Attempt to register an event on a NIL object (qqds_C_FieldWidget, 10).
    Traceback:
    SuperWindow.EH at line 0
    SubWindow.Display at line 5
    C++ Method(s)
    UserApp.Run at offset 105
    It is quite understandable that in runtime there is no widget called
    <MyBtn>
    and the event handler of the super class fails.
    But what I don't know : after specifing a mapped type of a GridField why
    changes
    the name of those widgets that haven't got mapped type e.g.: PushButton,
    PictureButton etc.
    How to solve this situation?
    I made a sall example which i send in attachment.
    Thanks for any help and advice in advance...
    Attila Racz Lufthansa Systems
    Hungary
    BUD LSYH
    E-mail: [email protected] .-``'.
    Tel.: (36 1) 431-2910 .` .' Mazsa ter 2-6.
    Fax : (36 1) 431-2977 _.-' '._ H-1107 Budapest,
    Hungary
    --------------24CDBE5DFBEC0C4205C15C80
    Content-Type: text/html; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
    <html>
    <tt>    Hi!</tt><tt></tt>
    <p><tt>I have a window inheritance and implementation question. I'm using</tt>
    <br><tt>Forte 3.0.J.1.</tt><tt></tt>
    <p><tt>I have a super (base) window with a PushButton on it. I want to</tt>
    <br><tt>handle the Click event of the button in this super window therefore</tt>
    <br><tt>I create an event handler.</tt><tt></tt>
    <p><tt>&lt;MyBtn> : PushButton</tt><tt></tt>
    <p><tt>I create a sub window inheriting from the previous super window.</tt>
    <br><tt>I put some data widgets on it and group all of them (the inherited</tt>
    <br><tt>button as well) into a GridField. When I set the mapped type of
    the grid</tt>
    <br><tt>the name of the inherited PushButton widget changes:</tt><tt></tt>
    <p><tt>&lt;MainGrid.MyBtn> : PushButton</tt><tt></tt>
    <p><tt>When I run the application I get a SystemException with the</tt>
    <br><tt>message:</tt><tt></tt>
    <p><tt>Attempt to register an event on a NIL object  (qqds_C_FieldWidget,
    10).</tt>
    <br><tt>      Traceback:</tt>
    <br><tt>          SuperWindow.EH
    at line 0</tt>
    <br><tt>          SubWindow.Display
    at line 5</tt>
    <br><tt>          C++ Method(s)</tt>
    <br><tt>          UserApp.Run
    at offset 105</tt><tt></tt>
    <p><tt>It is quite understandable that in runtime there is no widget called
    &lt;MyBtn></tt>
    <br><tt>and the event handler of the super class fails.</tt><tt></tt>
    <p><tt>But what I don't know : after specifing a mapped type of a GridField
    why changes</tt>
    <br><tt>the name of those widgets that haven't got mapped type e.g.: PushButton,</tt>
    <br><tt>PictureButton etc.</tt><tt></tt>
    <p><tt>How to solve this situation?</tt>
    <br><tt>I made a sall example which i send in attachment.</tt><tt></tt>
    <p><tt>Thanks for any help and advice in advance...</tt><tt></tt>
    <p><tt>---------------------------------------------------------------------------</tt>
    <br><tt> Attila Racz                                    
    Lufthansa Systems Hungary</tt>
    <br><tt>                                                
    BUD LSYH</tt>
    <br><tt>E-mail: [email protected]      
    .-``'.</tt>
    <br><tt>Tel.: (36 1) 431-2910               
    .`   .'     Mazsa ter 2-6.</tt>
    <br><tt>Fax : (36 1) 431-2977           
    _.-'     '._    H-1107 Budapest, Hungary</tt>
    <br><tt>---------------------------------------------------------------------------</tt>
    <br><tt></tt> </html>
    --------------24CDBE5DFBEC0C4205C15C80--
    --------------F5AF60803BB8EFA34C8D4288
    Content-Type: application/x-zip-compressed;
    name="Inh.zip"
    Content-Transfer-Encoding: base64
    Content-Disposition: inline;
    filename="Inh.zip"
    UEsDBBQAAAAIAAdlGicvhmSHbAUAAFITAAAHAAAASW5oLnBleO1YbW/bNhD+bAP+D/yWDGsN
    Uq9WvQxwHQfx4MSGra7oR0qkYq2yZEhys/z73ZGSLdty0A7rMAyloDfy7rkXUndHBfIpTok/
    n8/INF3LPC6nm23yMU6HvW6vG6dhshOyILdxsU34yyLP/pBhOWyM3OV8I5+z/DN03o9WZLGc
    LyZL/xOZFrM4yHn+Qm7I3Wi2mijEt2/Jyh8tfXI3X34cLW/JeDZarcjtBO7LkT+dP6563SjL
    n3kuCFntAlBFZM8kLsiGb7dSDI+GtzJvIQAhk8fbV0W0afJhuZovT+hOodpoGlhj6PBHjz5Q
    3E0fp8cg7YNNbnI78kfE/7SYtANcGm9iVMYejYYJL4p2d5FYT3tBojzbnEx0/0NRcyBMr7vm
    BdnugiQOCdnIcp2JmmPYOjhN43J4yii/yLQka56KROZkcn/904Ekz0DH8qXX7RRrnktxc82T
    JHu+ydI3JPsi8zwWUr0IGfFdUt5kUYTsnTLnacHDMs5Snnw11yYDBbNvkSPioszjYFc2eKKo
    yaQJlT297s82s5nlmIxiY1zouyO9SJqUUdVv4N2gdTPgcCj1LDqgFCAYMHlRFClyC4gjeGDM
    UO+MucijxuumhQTBgEacKgh63oDVQTFnzRPIClfFrFsNwUAlEw4G4sQZp6HNUS2iFrXh7tQj
    GkITVF6AM9j36WYq6mN/2ACFZCFCGIreRlyXo4OspnfwuOQdJUZroeTbIojwbMjWB6prUYvT
    g/2H5gmcVGDzxBEzNvSO4wxqg04ENLyDWnjqSbnnxF4XDjRvAHCGGrGpbQnXswzXcqTqsQDC
    YMeHspUpW+u5ETCNpmfD1TDAV9KmbIBaqBO1ONhso7su2BxKhNCsh8ZogBConOVEsGY9Fyeq
    uQpcxj3mhXhwEyGovkq8OpI5zMMFzs2BYzim6wJxUJFTxRKGwC6hT4aKkTZARA2FWjCT4aut
    kO1I4+NKhdgIi8SSpufpGCZTQVRAHDZD41miOQmMx9mx34il/0Rk/N+EvY7yZxKnkj9JyPzX
    0NVJoUSA56vLPry6GDINt4ogzPwRMpXFP0ImvRgyQzRP6QrB0xIOczxHWq5rwN1SYQLXQ6vF
    qMnAthzbHbgWBDQGsZZ5kmpnhwctVNixB14Ik214ATVNd6/HSThtWy3KnRiQIdKJI2ZsSgt2
    mGDDhWgHBln6rTkjVBnC6oVcLefq+6h8Ze0ZcWIG6lF5rrnAIdQqPc0aH6LuoHkCRUs+Aojj
    lNSaj4yTfBSGDp46FwHEIR01nOfSr85FB0MgHb2ai/ilXAQQ+OBxvHKFHqiUCTklYt7XZCeA
    eC1BUWapfkfovKQMMJRQtxatVie3TnRgAsOKoQDBxVqrfVrj1GQ8Ok9r9X6hbS+w3ymsJsvf
    p+MJmb//bTJu37G8RtLcc9S7opYtS8tQgxO3MjDWyto61uB9mPj389vz4b/fet0qOe/LgX6V
    w3vdADfKvW4hk6g/38pUbVr0TibJsi2K7mxzmQNZUcoc0179TApMdP39RqfzvJYpKXnxub9a
    70oQkxKRIYf8UxUFOJUKelgJHCdZIbVEGNJKDr+DtViUHExVWmPXd5S8rwC+wdP/Pf8drPjX
    PHi8iW6qgOtsr0Kvq5z1y8PL+zL9FRwRh5+1s5T/Fjwv+7Ps6eEp7y925QzqtuurBti7d0ec
    VZnW9G/1sbZ9jM3fQSBwnG22vIyDOInLlxnwJ1ATUqwZq78N/ssWy8TRYjGbjtXPFRxcSqw8
    Qyg8Gz+SOg9QnMb+OpdcqAF/+UH1T1P44KAUbtJW/6Eeqyq0quvjKxxbleCBOH160FMJBave
    ENwcvoo3dcl+U1f02gvaD2d/zf4CUEsBAhQAFAAAAAgAB2UaJy+GZIdsBQAAUhMAAAcAAAAA
    AAAAAQAgALaBAAAAAEluaC5wZXhQSwUGAAAAAAEAAQA1AAAAkQUAAAAA
    --------------F5AF60803BB8EFA34C8D4288--

    import javax.swing.JOptionPane;
    public class Test{
         public static void main(String[] args)
              String newItem = "Item";
              float newSerial = 4234;
              float newCode = 3424;
              int newBase = 1000;
              boolean YesWarranty = true;
              boolean NoWarranty = true;
              Machinery test1 = new Machinery(newItem, newCode, newSerial, newBase, YesWarranty, NoWarranty);
              JOptionPane.showMessageDialog(null, "Item: " + test1.getItem() + " Serial: " + test1.getSerial() + " Code: " + test1.getCode()
              + " Warranty: " + test1.IncludeWarranty() + " No Warranty: " + test1.ExcludeWarranty()+ " Base: " + test1.getPrice());
    }Tested with this and it seems to be ok?
    Changed my final code too because it seemed to always add the 10% whether YesWarranty was true or false, so made it
              if (TrueWarranty==true) //There is a warranty, it returns the base price plus 10%
                   return (base+((base/100)*10));May have posted here too early if it does work, but there is another part so if ive trouble with that il be back :P
    Edited by: dave_the_bear on 16-Nov-2010 07:17
    Changed base to double and used the *0.1 method

  • Request for feedback:  implementing Swing-based drawers

    Good day.
    I've inherited some code to which I need to add a 'dresser drawer' like functionality. Click on a logical 'open' button and the drawer opens, revealing, or displaying as the case may be, a JPanel with more stuff in it. Click on a logical 'close' button and the drawer closes, leaving its container in the visual state in which it started. A familiar example of this effect might be something like the Mac Dock in 'auto hide' mode, where the Dock moves in and out of sight and addressability with some pointer action. The Dock is always 'there', but sometimes just not visible. So it would be with the drawer.
    I am wondering if a solution would be based loosely on theDrawer.setVisible(), or whether something that sets the drawer's component width or height to 0 for-hide would be more likely.
    Can anyone offer guidance on how to approach this using standard Swing techniques?
    Thanks.

    You are on the right track with the setVisible method. It will hide and visibly behave like the component was never added to the layout of the component it is contained in.
    For example, say I have 2 panels and two buttons. Panel A is the main container of Panel B and the two buttons. Button A is the 'Open' button, and Button B is the 'Close' button. Panel B was added to Panel A but immediately set to be not visible. Pressing the 'Open' button will toggle the Panel B setVisible method to true and show the panel and it's contents. Obviously the 'Close' button is the opposite.
    By doing this it is very easy to have a collapse and expand functionality with your components.

  • Constructors and Inheritance in Java

    Hi there,
    I'm going over access modifiers in Java from this website and noticed that the following output is displayed if you run the snippet of code.
    Cookie Class
    import javax.swing.*;
    public class Cookie {
         public Cookie() {
              System.out.println("Cookie constructor");
         protected void foo() {
              System.out.println("foo");
    }ChocolateChip class
    public class ChocolateChip extends Cookie {
         public ChocolateChip() {
              System.out.println("ChocolateChip constructor");
         public static void main(String[] args) {
              ChocolateChip x = new ChocolateChip();
              x.foo();
    }Output:
    Cookie constructor
    ChocolateChip constructor
    fooI've been told that constructors are never inherited in Java, so why is "Cookie constructor" still in the output? I know that ChocolateChip extends Cookie, but the Cookie constructor isn't enacted when the new ChocolateChip object is defined... or is it?
    If you can shed any light on this, I would greatly appreciate it.
    Many thanks!

    896602 wrote:
    I've been told that constructors are never inherited in JavaThat is correct. If they were inherited, that would mean that, just by virtue of Cookie having a c'tor with some particular signature, ChocoChip would also "automatically" have a c'tor with that same signature. However, that is not the case.
    , so why is "Cookie constructor" still in the outputBecause invoking a constructor always invokes the parent class's c'tor before any of our own c'tor's body executes, unless the first statement is this(...), to invoke some other c'tor of ours. If this is the case, eventually down the line, some c'tor of ours will not have an explicit this(...) call. It will either have an explicit super(...) call, or no call at all, which ends up leading to the compiler generating a call to super().
    Note that the ability to call super(...) does not mean that that c'tor was inherited.
    I know that ChocolateChip extends Cookie, but the Cookie constructor isn't enacted when the new ChocolateChip object is defined... or is it?Yes, it is. As I pointed out above, if we don't explicitly call this(...) or super(...), then a call to super() is inserted by the compiler.

  • Trying to use Inheritance?

    Here is what I am doing:
    Reading a text file that has information about employee's.
    Each line of text looks like this example:
    Jane Rivers 902-A 05/16/2001 1 16.25
    Name, Employee Number(The last letter determines the department name), Date of Hire, Dept., Number, Pay Rate
    The driver is named Employees.
    Class Employee contains Employee Name, Employee Number, and Hire Date in the fields.
    Class ProductionWorker has to inherits from Employee class.
    It contains the Shift Number and Hourly Pay Rate.
    I do not see how I can get the information into the ProductionWorker class?
    The program currently runs and will print out the information from the Employee Class.
    I do not see how to get the information that I need stored in the ProductionWorker class and then the driver obtain that information to be printed?
    Any suggestions or solutions would be greatly appreciated.
    Here is the code:
    import java.util.Scanner; //needed for Scanner
    import java.io.*; //needed for PrintWriter and IOException
    import java.util.StringTokenizer; //needed for StringTokenizer
    public class Employees
         public static void main(String[] args) throws IOException
              // Create a Scanner object for keyboard input
              Scanner keyboard = new Scanner(System.in);
              // open file
              File myFile = new File("Information.txt");     
              Scanner inputFile = new Scanner(myFile);
              // Read lines from the file until no more are left.
              while (inputFile.hasNext())
              // Read the next line of information
              String employeeInfo = inputFile.nextLine();
              Employee info = new Employee(employeeInfo);
              System.out.print(info.getEmpFirstName() + " ");
              System.out.print(info.getEmpLastName() + " ");     
              System.out.print(info.getEmpNum() + " ");
              System.out.print(info.getEmpDept() + " ");
              System.out.println(info.getEmpHireDate() + " ");
              // closes file
              inputFile.close();
    import java.util.Scanner; //needed for Scanner
    import java.io.*; //needed for PrintWriter and IOException
    import java.util.StringTokenizer; //needed for StringTokenizer
    public class Employee
         String employeeInformation;
         private String empDept;
         String empFirstName;
         String empLastName;
         String empNum;
         String empHireDate;
         String empShiftNumber;
         String empHourlyPay;
         public Employee(String empInfo)
              employeeInformation = empInfo;
              StringTokenizer employInfo = new StringTokenizer(employeeInformation);
              empFirstName = employInfo.nextToken();
              empLastName = employInfo.nextToken();
              empNum = employInfo.nextToken();
              empHireDate = employInfo.nextToken();
              empShiftNumber = employInfo.nextToken();
              empHourlyPay = employInfo.nextToken();
         public void setEmployeeInformation(String set)
              employeeInformation = set;     
         public String getEmpFirstName()
              return empFirstName;
         public String getEmpLastName()
              return empLastName;
         public String getEmpNum()
              return empNum;
         public String getEmpDept()
              if(empNum.endsWith("H"))
                   empDept = "Human Resourses";
              if(empNum.endsWith("A"))
                   empDept = "Accounting";
              if(empNum.endsWith("P"))
                   empDept = "Production";
              if(empNum.endsWith("S"))
                   empDept = "Shipping";
              return empDept;
         public String getEmpHireDate()
              return empHireDate;
    public class ProductionWorker extends Employee
         String empShiftNumber;
         String hourlyPayRate;
         String employeeInfo;
         public ProductionWorker(String empInfo)
              super(empInfo);
              employeeInfo = empInfo;
         public void setEmpShiftNumber(String shiftNum)
              empShiftNumber = shiftNum;
         public void setEmpHourlyPayRate(String hourlyPay)
              hourlyPayRate = hourlyPay;
         public String getEmpShiftNumber()
              if(empShiftNumber == "1")
                   empShiftNumber = "Morning Shift ";
              if(empShiftNumber == "2")
                   empShiftNumber = "Swing Shift ";
              if(empShiftNumber == "3")
                   empShiftNumber = "Night Shift ";
              return empShiftNumber;
         public String getEmpHoulyPayRate()
              return hourlyPayRate;
    }

    import java.util.Scanner; //needed for Scanner
    import java.io.*; //needed for PrintWriter and IOException
    import java.util.StringTokenizer; //needed for StringTokenizer
    public class Employees
         public static void main(String[] args) throws IOException
              // Create a Scanner object for keyboard input
              Scanner keyboard = new Scanner(System.in);
              // open file
              File myFile = new File("Information.txt");     
              Scanner inputFile = new Scanner(myFile);
              // Read lines from the file until no more are left.
              while (inputFile.hasNext())
              // Read the next line of information
              String employeeInfo = inputFile.nextLine();
              StringTokenizer employInfo = new StringTokenizer(employeeInfo);
              String empFirstName = employInfo.nextToken();
              String empLastName = employInfo.nextToken();
              String empNum = employInfo.nextToken();
              String empHireDate = employInfo.nextToken();
              String empShiftNumber = employInfo.nextToken();
              String empHourlyPay = employInfo.nextToken();
              Employee info = new Employee(empFirstName, empLastName, empNum, empHireDate);
              ProductionWorker obj = new ProductionWorker(empShiftNumber, empHourlyPay);
              System.out.print(info.getEmpFirstName() + " ");
              System.out.print(info.getEmpLastName() + " ");     
              System.out.print(info.getEmpNum() + " ");
              System.out.print(info.getEmpDept() + " ");
              System.out.println(info.getEmpHireDate() + " ");
              System.out.println(obj.getEmpShiftNumber());
              // closes file
              inputFile.close();
    import java.util.Scanner; //needed for Scanner
    import java.io.*; //needed for PrintWriter and IOException
    import java.util.StringTokenizer; //needed for StringTokenizer
    public class Employee
         String employeeInformation;
         private String empDept;
         String empFirstName;
         String empLastName;
         String empNum;
         String empHireDate;
         public Employee(String empFN,String empLN,String empNumber,String empHD)
              empFirstName = empFN;
              empLastName = empLN;
              empNum = empNumber;
              empHireDate = empHD;
         public void setEmpFirstName(String set)
              empFirstName = set;     
         public void setEmpLastName(String set)
              empLastName = set;     
         public void setEmpNum(String set)
              empNum = set;     
         public void setEmpHireDate(String set)
              empHireDate = set;     
         public String getEmpFirstName()
              return empFirstName;
         public String getEmpLastName()
              return empLastName;
         public String getEmpNum()
              return empNum;
         public String getEmpDept()
              if(empNum.endsWith("H"))
                   empDept = "Human Resourses";
              if(empNum.endsWith("A"))
                   empDept = "Accounting";
              if(empNum.endsWith("P"))
                   empDept = "Production";
              if(empNum.endsWith("S"))
                   empDept = "Shipping";
              return empDept;
         public String getEmpHireDate()
              return empHireDate;
    import java.util.Scanner; //needed for Scanner
    import java.io.*; //needed for PrintWriter and IOException
    import java.util.StringTokenizer; //needed for StringTokenizer
    public class ProductionWorker extends Employee
         String empShiftNumber;
         String hourlyPayRate;
         public ProductionWorker(String empSN, String empHPR)
              empShiftNumber = empSN;
              hourlyPayRate = empHPR;
         public void setEmpShiftNumber(String set)
              empShiftNumber = set;
         public void setEmpHourlyPayRate(String set)
              hourlyPayRate = set;
         public String getEmpShiftNumber()
              if(empShiftNumber == "1")
                   empShiftNumber = "Morning Shift ";
              if(empShiftNumber == "2")
                   empShiftNumber = "Swing Shift ";
              if(empShiftNumber == "3")
                   empShiftNumber = "Night Shift ";
              return empShiftNumber;
         public String getEmpHoulyPayRate()
              return hourlyPayRate;
    }I get the following Error
    ProductionWorker.java:12: cannot find symbol
    symbol : constructor Employee()
    location: class Employee
         ^
    1 error

  • Swing is great !!!!!

    Hi guys I've been working in swing for a last 5 years developing a client server and a GUI library. I've been working in coding our java beans (MyJTable, MyPopupDataTextField etc,etc) and our data JDBC beans.
    The only thing I could say now is that the library is becoming very productive and that I'm enjoying swing programming !!! I'm sure that all work I have done in swing it would be more difficult implementing in dot net. I really learned a lot watching sun's swing code !!! Really the best GUI toolkit !!! Thanks to all swing team, and people who are in java forums for helping me during these years !!!!
    (The only painfull thing was switching from jdk1.3.1 to jdk1.4.2, lot of focus issues).

    I am not good at English, but I think swing is awful
    bad...I think the Swing developers were given a pretty tough egg to crack and they produced something that is reasonably flexible and gets the job done. Overall I doubt I could have done as good a job given ten times the time to do it. That being said, there is definitely a lot in Swing to learn from through examples of what not to do. Some horrible abuses of concrete inheritance (DefaultTableCellRenderer for example) and other bad code so I wouldn't call it ideal or even the "best".

  • How to use annotation with GUI in swing

    hi,
    i am new to annotation. I know how to use this with classes, methods and java elements. I am developing a tool in applet to post comment on my notepad, but unable to find that how to use this with GUI of swing. I have gone through most of forums and tutorials but got no idea. Anyone could give me little idea.
    Thanks

    >
    i need to use the applet mousedown function in swing..>There is no such class as 'applet' in the JRE, Swing has an upper case 1st letter, functions in Java are generally referred to as methods, and there is no 'mousedown' method in the JRE.
    OTOH a Swing JApplet inherits the mouseDown method from Component, and it was deprecated in Java 1.1. The documentation (JavaDocs) provides instructions on what to use instead.
    >
    is there any way to use it or any other alternative is available for this?
    if can provide me a sample code.>If can provide me cash. Short of that, you might actually need to do some research/coding of your own.
    As an aside. What does any of this have to do with Java 2D?

Maybe you are looking for

  • Report for Pending F& C forms(stock transfers& sales)for tax requirement &

    Dear all, I have query regarding pending forms, F form required fields are, from wherehouse to wherehouse doc type, inv no, invdate, product code, description, quantity, standard cost, amount. C forms required fields are, Customer code, name and addr

  • Element casting problem in XML

    I'm having trouble reading an XML document.. When I have a NodeList and get its childnodes with the method getChildNodes(), the resulting NodeList is unable to cast items to Element using the item()-method. If I try to read a certain group of element

  • Using LabJack VIs in LabVIEW

    Hi, I'm using LabVIEW with a third party DAQ card, the LabJack U12. I know that its drivers are supported by LabVIEW, but I can't figure out how to add the LabJack VIs to the library. when I added the includes VIs into the user library, then ran LabV

  • Why can't I save pictures onto my computer from Facebook??

    My family posts pictures and I want to save to my computer but it doesn't show file as a jpg file only a document file.

  • Material component not deployed in ms04

    Hi, May I request your assistance on my issue? When I run the MS04 one of the component material is not displaying. I have change the planning period and run again the MS03 for a specific material which is the finished material. Can you help me under