This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Questions on Swing implementation maturity via an example


Hello,
I recently built CVS GCJ using the JHBuild instructions available at
http://people.redhat.com/fitzsim/gcj-and-jhbuild.html. I used a
/gcj/source, /gcj/build and /gcj/install directory structure to build -
modifying the excellent jhbuild instructions ever so slightly. On
completion I added /gcj/install/bin to the front of my PATH and changed
LD_LIBRARY_PATH to /gcj/install/lib. Then I decided to look for the test
cases to see what could be done.

Since I'm not entirely sure what wonka is and how it relates to mauve or
where any of the pre-built tests installed themselves to, I started with
some small Java examples of my own. The first couple 1 or 2 liners
worked fine and I was able to output to the console and get a Swing
JFrame on the screen. However, all my efforts to go beyond that ran into
difficulties.

For example, the code

import java.awt.event.*;
import javax.swing.*;

public class Test1
	implements ActionListener
{
  public static void main(String[] arguments)
  {
    JFrame frame = new JFrame();
    frame.setTitle("Test1");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JButton button = new JButton("button1");
    button.setActionCommand("button1");
    // The following line causes an error at compilation:
    // "error: Keyword this used outside of allowed context."
    //button.addActionListener(this);

    frame.add(button);

    frame.setSize(320, 240);
    frame.pack();
    frame.setVisible(true);
  } // main


  public void actionPerformed(ActionEvent e)
  {
    System.out.println("ActionPerformed: " + e.getActionCommand());
  } 
}

compiles (unless the indicated line is uncommented), links and runs. But
on any resize of the window runs into a NULL pointer exception.

Exception during event dispatch:
java.lang.NullPointerException
   at javax.swing.RepaintManager$RepaintWorker.run()
(/gcj/install/lib/lib-javax-swing.so.0.0.0)
   at java.awt.event.InvocationEvent.dispatch()
(/gcj/install/lib/lib-java-awt.so.0.0.0)
   at java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
(/gcj/install/lib/lib-java-awt.so.0.0.0)
   at java.awt.EventDispatchThread.run()
(/gcj/install/lib/lib-java-awt.so.0.0.0)
   at _Jv_ThreadRun(java.lang.Thread) (/gcj/install/lib/libgcj.so.6.0.0)
   at GC_start_routine (/gcj/install/lib/libgcj.so.6.0.0)
   at __clone (/lib/tls/libc-2.3.3.so)

Clicking on the button also causes an exception stack trace.

If this is expected at this point in time, consider this a bug report.
After reading some of the progress reports and browsing the classpath
mailing lists recently I was under the impression that the Swing work
was further along than would seem to be indicated by this example. If
this is the case, am I doing something else wrong in setting up the GCJ
environment?

Finally, one general question: while taking a look at the Classpath
status in comparison to Sun's J2SE SDK, it appears that the majority of
the J2SE packages are completed (at least if you pull in
Tritonus/Jessie/GNU Crypto/and some CORBA solution). Am I correct in
understanding that AWT and Swing are now the last major, remaining
pieces of the J2SE to complete for Classpath?

Impressive work!

Patrick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]