Re: how to refresh jComboBox in popupMenuWillBecomeVisible



Rui napisal(a):
NB: I added a setSize() method after adding the ComponentListener to
insure that combo size will be calculated before the frame is made visible.

Thanks! It works. I do it finally in this way:

contentPane.addComponentListener(new
java.awt.event.ComponentAdapter() {
public void componentResized(ComponentEvent e) {
contentPane_componentResized(e);
}
});

void contentPane_componentResized(ComponentEvent e) {
System.out.println("content resized");
int frameCurrentHeight = contentPane.getHeight();
double comboYPosition = myCombo.getBounds().getY();
int fontSize = (int)myCombo.getFont().getSize() + 6;
myCombo.setFixedCellHeight(fontSize);
int rowCount = (int)((frameCurrentHeight - comboYPosition) /
fontSize) - 5;
myCombo.setMaximumRowCount(rowCount);
}


thanks
T.

.



Relevant Pages

  • Re: Creating a "movie" in Swing.
    ... get about 1 frame a second and I see about every 15th frame. ... public void paint{ ... can do to prevent the write coalescing with repaint(). ...
    (comp.lang.java.programmer)
  • Re: easy question
    ... textfield and when they click a button they create that many more ... components will be laid out anew within their container, but the frame won't be resized. ... public void actionPerformed{ ... private JFrame createFrame() { ...
    (comp.lang.java.programmer)
  • Re: label setCursor not working when main frame is maximized
    ... to listen for clicks but also when the mouse is over the label. ... when my frame & internal frame are their start up sizes, ... and MyInternalFrame that extends JInternalFrame. ... public void mouseClicked{ ...
    (comp.lang.java.programmer)
  • Problem resizing applet frame
    ... I can't seem to get this darn frame to resize when the applet ... static volatile Graphics currentGraphics; ... public void start{ ...
    (comp.lang.java.programmer)
  • Re: Graphics question
    ... Frame frame1 = new Frame; ... Panel panel = new Panel; ... private class MouseMotionHandler implements MouseMotionListener { ... } public void mouseDragged{ ...
    (comp.lang.java.programmer)