Added 'Font Size Override' property to most components that display text

to allow control over font size
This commit is contained in:
bancika
2020-12-13 20:42:26 +01:00
parent 695710f34f
commit 2a063c84cd
40 changed files with 257 additions and 72 deletions
@@ -39,8 +39,9 @@ public class IntEditor extends DoubleTextField {
public IntEditor(final PropertyWrapper property) {
setLayout(new BorderLayout());
if (property.isReadOnly())
setEnabled(false);
setValue((double) (Integer) property.getValue());
setEnabled(false);
if (property.getValue() != null)
setValue((double) (Integer) property.getValue());
addPropertyChangeListener(DoubleTextField.VALUE_PROPERTY, new PropertyChangeListener() {
@Override
@@ -142,45 +142,49 @@ public class PropertyEditorDialog extends ButtonDialog {
gbc.weightx = 1;
gbc.insets = new Insets(2, 2, 2, 2);
Component editor = FieldEditorFactory.createFieldEditor(property);
editor.addKeyListener(new KeyAdapter() {
try {
Component editor = FieldEditorFactory.createFieldEditor(property);
editor.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
getButton(OK).doClick();
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
getButton(CANCEL).doClick();
}
}
});
editorPanel.add(editor, gbc);
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
getButton(OK).doClick();
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
getButton(CANCEL).doClick();
if (property.isDefaultable()) {
gbc.gridx = 2;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
if (saveDefaults && !property.isReadOnly()) {
editorPanel.add(createDefaultCheckBox(property), gbc);
}
}
});
editorPanel.add(editor, gbc);
if (property.isDefaultable()) {
gbc.gridx = 2;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
if (saveDefaults && !property.isReadOnly()) {
editorPanel.add(createDefaultCheckBox(property), gbc);
}
}
if (property.getName().equalsIgnoreCase("value")) {
componentToFocus = editor;
}
// Make value field focused
try {
if (componentToFocus == null
&& property.getGetter().getName().equalsIgnoreCase("getValue")) {
if (property.getName().equalsIgnoreCase("value")) {
componentToFocus = editor;
}
} catch (Exception e1) {
LOG.warn("Could not determine editor component to focus", e1);
// Make value field focused
try {
if (componentToFocus == null
&& property.getGetter().getName().equalsIgnoreCase("getValue")) {
componentToFocus = editor;
}
} catch (Exception e1) {
LOG.warn("Could not determine editor component to focus", e1);
}
gbc.gridy++;
} catch (Exception e) {
LOG.error("Error creating editor for " + property.getName(), e);
}
gbc.gridy++;
}
return editorPanel;