I am using a simple "graph widget" (a subclass of JComponent that
overrides the paint() method) as a cell renderer in a simple
JTable.
This works fine on Linux and Windows (you see the /\ /\ in each cell),
but on Mac OS X (also with Java 1.6) the cells are empty (just plain
white window).
A minimal example that shows this behavior is attached.
Do you have any ideas?
Thanks in advance!
--
Felix Natter
[...]
> public void paint(Graphics g) {
Override paintComponent():
<http://java.sun.com/products/jfc/tsc/articles/painting/index.html>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
> In article <87bpij3...@etchy.mobile.lcn>,
> Felix Natter <felix....@smail.inf.fh-brs.de> wrote:
>
> > I am using a simple "graph widget" (a subclass of JComponent that
> > overrides the paint() method) as a cell renderer in a simple JTable.
> >
> > This works fine on Linux and Windows (you see the /\ /\ in each
> > cell), but on Mac OS X (also with Java 1.6) the cells are empty (just
> > plain white window).
> >
> > A minimal example that shows this behavior is attached. Do you have
> > any ideas?
> [...]
> > public void paint(Graphics g) {
>
> Override paintComponent():
>
> <http://java.sun.com/products/jfc/tsc/articles/painting/index.html>
And I just confirmed that that will work on MacOS X, with Java 1.6
(Tested with OS 10.5, Intel HW)
--
Thomas A. Russ, USC/Information Sciences Institute
Others have addressed the main points, but I see another problem - you aren't
doing GUI on the Event Dispatch Thread (EDT).
public static void main(String[] args) {
TestJTable5 frame = new TestJTable5();
frame.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
System.exit(0);
}
});
//frame.pack();
frame.setVisible(true);
}
All those GUI calls and constructors should be moved to the EDT, most easily
by using java.awt.EventQueue.invokeLater() of a new Runnable around the calls
in your main().
--
Lew