-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8u31
-
x86
-
os_x
FULL PRODUCT VERSION :
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.10.2
A DESCRIPTION OF THE PROBLEM :
The worst bugs are the random ones.
This is something that I cannot understand. I am using JList (in JScrollPane) to display list of available assignments for students. 90% of time everything is working perfect, but from time to time comes the following situation:
JList becomes tiny in height. First time I was confused. It seemed like the method setVisibleRowCount suddenly understood the number 8 as eight pixels not eight lines. After I changed the number to 60 (for example), everything seemed working fine again, but the next day the component became huge in size (extremely high). I taught it was a random bug, replaced the 60 with 8 again and wanted to forget it, but it comes again and again.
It is coming randomly and nothing helps. When it came last time: I restarted my hardware (MacBook), I have deleted all compiled classes and rebuild the project from the ground, I replaced GridBagLayout with BorderLayout and the behaviour persisted. (!) It seems like something is deeply burrowed there and it comes up only in some “magic” time frame, because the next day everything is fine again. I do not understand it.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
It is random. I would like to be more helpful, but it is really random and nothing helps.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JList should be as high as the argument says in lines, not in pixels.
ACTUAL -
JList will become suddenly very tiny in height.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
None. It is just a strange behaviour.
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
// This is nested class originally. I extracted it from my application:
// import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import javax.swing.WindowConstants;
@SuppressWarnings("serial")
public class AssignmentsListDialog extends JDialog
{
// Serial ID – generated by serialver -show tool
// private static final long serialVersionUID = -7303684451597223309L;
// Empty list constant
private final String[] emptyList = new String[] {};
// List
public final JLabel label =
new JLabel("List of assignments:");
private JScrollPane scroll;
private JList<String> list;
// Buttons
public final JButton select = new JButton("Select");
public final JButton read = new JButton("Read");
public final JButton close = new JButton("Close");
// Panel
// public final JPanel scrollPanel = new JPanel();
public final JPanel commonButtonsPanel = new JPanel();
// Mouse double click adapter
private MouseAdapter assignmentDoubleClick = new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
JList<?> myList = (JList)e.getSource();
if (e.getClickCount() == 2 &&
!myList.isSelectionEmpty()) onSelectButton();
}
};
// Constructor
public AssignmentsListDialog(JFrame owner, boolean allowRead)
{
super(owner, "Assignments…", true);
// Initialize scroll panel
list = new JList<String>(emptyList);
list.setVisibleRowCount(8);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addMouseListener(assignmentDoubleClick);
scroll = new JScrollPane(list);
// Buttons
select.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent e) { onSelectButton(); }});
if (allowRead)
read.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent e) { onReadButton(); }});
close.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent e) { onCloseButton(); }});
commonButtonsPanel.add(select);
if (allowRead) commonButtonsPanel.add(read);
commonButtonsPanel.add(close);
// Dialog layout
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constr = new GridBagConstraints();
setLayout(gridbag);
constr.insets = new Insets(2, 6, 2, 6);
constr.anchor = GridBagConstraints.PAGE_START;
constr.gridy = 0;
constr.weighty = 0.5;
constr.fill = GridBagConstraints.NONE;
gridbag.setConstraints(label, constr);
add(label);
constr.anchor = GridBagConstraints.CENTER;
constr.gridy = 1;
constr.weighty = 1.0;
constr.fill = GridBagConstraints.BOTH;
gridbag.setConstraints(scroll, constr);
add(scroll);
constr.fill = GridBagConstraints.NONE;
constr.anchor = GridBagConstraints.PAGE_END;
constr.gridy = 2;
constr.weighty = 0.5;
gridbag.setConstraints(commonButtonsPanel, constr);
add(commonButtonsPanel);
/** – the same situation :-(
setLayout(new BorderLayout());
add(label, BorderLayout.PAGE_START);
add(scroll, BorderLayout.CENTER);
add(commonButtonsPanel, BorderLayout.PAGE_END);
/**/
// reset();
pack();
setVisible(true);
}
private void onSelectButton()
{
// Something to do…
}
private void onReadButton()
{
}
private void onCloseButton()
{
// reset();
setVisible(false);
}
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
new AssignmentsListDialog(frame, true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None. Just waiting for the next day…
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.10.2
A DESCRIPTION OF THE PROBLEM :
The worst bugs are the random ones.
This is something that I cannot understand. I am using JList (in JScrollPane) to display list of available assignments for students. 90% of time everything is working perfect, but from time to time comes the following situation:
JList becomes tiny in height. First time I was confused. It seemed like the method setVisibleRowCount suddenly understood the number 8 as eight pixels not eight lines. After I changed the number to 60 (for example), everything seemed working fine again, but the next day the component became huge in size (extremely high). I taught it was a random bug, replaced the 60 with 8 again and wanted to forget it, but it comes again and again.
It is coming randomly and nothing helps. When it came last time: I restarted my hardware (MacBook), I have deleted all compiled classes and rebuild the project from the ground, I replaced GridBagLayout with BorderLayout and the behaviour persisted. (!) It seems like something is deeply burrowed there and it comes up only in some “magic” time frame, because the next day everything is fine again. I do not understand it.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
It is random. I would like to be more helpful, but it is really random and nothing helps.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JList should be as high as the argument says in lines, not in pixels.
ACTUAL -
JList will become suddenly very tiny in height.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
None. It is just a strange behaviour.
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
// This is nested class originally. I extracted it from my application:
// import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import javax.swing.WindowConstants;
@SuppressWarnings("serial")
public class AssignmentsListDialog extends JDialog
{
// Serial ID – generated by serialver -show tool
// private static final long serialVersionUID = -7303684451597223309L;
// Empty list constant
private final String[] emptyList = new String[] {};
// List
public final JLabel label =
new JLabel("List of assignments:");
private JScrollPane scroll;
private JList<String> list;
// Buttons
public final JButton select = new JButton("Select");
public final JButton read = new JButton("Read");
public final JButton close = new JButton("Close");
// Panel
// public final JPanel scrollPanel = new JPanel();
public final JPanel commonButtonsPanel = new JPanel();
// Mouse double click adapter
private MouseAdapter assignmentDoubleClick = new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
JList<?> myList = (JList)e.getSource();
if (e.getClickCount() == 2 &&
!myList.isSelectionEmpty()) onSelectButton();
}
};
// Constructor
public AssignmentsListDialog(JFrame owner, boolean allowRead)
{
super(owner, "Assignments…", true);
// Initialize scroll panel
list = new JList<String>(emptyList);
list.setVisibleRowCount(8);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addMouseListener(assignmentDoubleClick);
scroll = new JScrollPane(list);
// Buttons
select.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent e) { onSelectButton(); }});
if (allowRead)
read.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent e) { onReadButton(); }});
close.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent e) { onCloseButton(); }});
commonButtonsPanel.add(select);
if (allowRead) commonButtonsPanel.add(read);
commonButtonsPanel.add(close);
// Dialog layout
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constr = new GridBagConstraints();
setLayout(gridbag);
constr.insets = new Insets(2, 6, 2, 6);
constr.anchor = GridBagConstraints.PAGE_START;
constr.gridy = 0;
constr.weighty = 0.5;
constr.fill = GridBagConstraints.NONE;
gridbag.setConstraints(label, constr);
add(label);
constr.anchor = GridBagConstraints.CENTER;
constr.gridy = 1;
constr.weighty = 1.0;
constr.fill = GridBagConstraints.BOTH;
gridbag.setConstraints(scroll, constr);
add(scroll);
constr.fill = GridBagConstraints.NONE;
constr.anchor = GridBagConstraints.PAGE_END;
constr.gridy = 2;
constr.weighty = 0.5;
gridbag.setConstraints(commonButtonsPanel, constr);
add(commonButtonsPanel);
/** – the same situation :-(
setLayout(new BorderLayout());
add(label, BorderLayout.PAGE_START);
add(scroll, BorderLayout.CENTER);
add(commonButtonsPanel, BorderLayout.PAGE_END);
/**/
// reset();
pack();
setVisible(true);
}
private void onSelectButton()
{
// Something to do…
}
private void onReadButton()
{
}
private void onCloseButton()
{
// reset();
setVisible(false);
}
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
new AssignmentsListDialog(frame, true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None. Just waiting for the next day…