Solaris 9 - Sun JRE 1.4.0_00-b05

T

Tony Morris

The following behaviour is observed only on Solaris 9 with Sun JRE
1.4.0.00-b05. Also, this behaviour is only observed when using the local
console of the Solaris machine - using a remote X server does not show the
problem.

The following sequence of events occurs:
- The user begins typing into a cell in the JTable.
- The user clicks and holds down the button with the mouse. The user has not
committed what they just typed in the JTable cell by pressing Enter or
anything equivalent.
- The cell that was being edited, clears (unexpectedly).
- The user releases the mouse button firing an ActionEvent.
- The user sees "editor is null" on standard out.

Following this same sequences of events again causes different behaviour
(the expected behaviour).
- The user begins typing into a cell in the JTable.
- The user clicks and holds down the button with the mouse. The user has not
committed what they just typed in the JTable cell by pressing Enter or
anything equivalent.
- The user releases the mouse button firing an ActionEvent.
- The cell that was being edited stops editing and the data is committed to
the model.
- The user sees nothing on standard out.

This "normal" behaviour is observed on subsequent "clicks of the button". It
is only the first time that the button is clicked with uncommitted (to the
model) data in the cell, that the unexpected behaviour is observed (cell
clearing before the ActionEvent followed by no CellEditor when the
ActionEvent is fired).

Sample Code:


// File: Test.javaimport javax.swing.*;import java.awt.*;import
java.awt.event.*; public class Test{ public static void main(String[] args)
{ JFrame f = new JFrame("Test"); f.getContentPane().add(new TPanel());
f.pack(); f.show(); }} class TPanel extends JPanel{ private JTable t;
private JButton b; public TPanel() { t = new JTable(10, 2); b = new
JButton("Click Me"); init(); } private void init() {
b.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent ae) { CellEditor editor =
t.getCellEditor(); if(editor != null) {
editor.stopCellEditing(); } else { System.out.println("editor
is null"); } } }); setLayout(new BorderLayout()); add(t,
BorderLayout.CENTER); add(b, BorderLayout.SOUTH); }}
Any suggestions are most appreciated.
Sun JRE bug searching has not revealed any clues so far.

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=009004

--
Tony Morris
(BInfTech, Cert 3 I.T.)
Software Engineer
(2003 VTR1000F)
Sun Certified Programmer for the Java 2 Platform (1.4)
Sun Certified Developer for the Java 2 Platform
 
T

Tony Morris

// File: Test.javaimport javax.swing.*;import java.awt.*;import
java.awt.event.*; public class Test{ public static void main(String[] args)
{ JFrame f = new JFrame("Test"); f.getContentPane().add(new TPanel());
f.pack(); f.show(); }} class TPanel extends JPanel{ private JTable t;
private JButton b; public TPanel() { t = new JTable(10, 2); b = new
JButton("Click Me"); init(); } private void init() {
b.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent ae) { CellEditor editor =
t.getCellEditor(); if(editor != null) {
editor.stopCellEditing(); } else { System.out.println("editor
is null"); } } }); setLayout(new BorderLayout()); add(t,
BorderLayout.CENTER); add(b, BorderLayout.SOUTH); }}
Any suggestions are most appreciated.
Sun JRE bug searching has not revealed any clues so far.

Same sample code, reformatted properly.


// File: Test.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Test
{
public static void main(String[] args)
{
JFrame f = new JFrame("Test");
f.getContentPane().add(new TPanel());
f.pack();
f.show();
}
}

class TPanel extends JPanel
{
private JTable t;
private JButton b;

public TPanel()
{
t = new JTable(10, 2);
b = new JButton("Click Me");

init();
}

private void init()
{
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
CellEditor editor = t.getCellEditor();

if(editor != null)
{
editor.stopCellEditing();
}
else
{
System.out.println("editor is null");
}
}
});

setLayout(new BorderLayout());
add(t, BorderLayout.CENTER);
add(b, BorderLayout.SOUTH);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top