Beispiel #1
0
 private static int getSpinnerBaseline(JSpinner spinner, int height) {
   JComponent editor = spinner.getEditor();
   if (editor instanceof JSpinner.DefaultEditor) {
     JSpinner.DefaultEditor defaultEditor = (JSpinner.DefaultEditor) editor;
     JTextField tf = defaultEditor.getTextField();
     Insets spinnerInsets = spinner.getInsets();
     Insets editorInsets = defaultEditor.getInsets();
     int offset = spinnerInsets.top + editorInsets.top;
     height -= (offset + spinnerInsets.bottom + editorInsets.bottom);
     if (height <= 0) {
       return -1;
     }
     return offset + getSingleLineTextBaseline(tf, height);
   }
   Insets insets = spinner.getInsets();
   FontMetrics fm = spinner.getFontMetrics(spinner.getFont());
   return insets.top + fm.getAscent();
 }