From aff553e5b274e25d3db787b7928cd769f6f99630 Mon Sep 17 00:00:00 2001 From: Jacob van Mourik Date: Tue, 7 Feb 2017 21:43:41 +0100 Subject: [PATCH] Lots of improvements. #16 #17 #18 #19 --- .../java/com/jvms/i18neditor/LookAndFeel.java | 4 +- src/main/java/com/jvms/i18neditor/Main.java | 1 - .../com/jvms/i18neditor/editor/Editor.java | 151 ++++++++++----- .../i18neditor/editor/EditorSettings.java | 18 ++ .../i18neditor/editor/EditorSettingsPane.java | 32 +++- .../jvms/i18neditor/editor/ResourceField.java | 2 - .../i18neditor/editor/TranslationTree.java | 172 ++++++++++++++++-- .../com/jvms/i18neditor/swing/JTextArea.java | 2 +- .../com/jvms/i18neditor/swing/JTextField.java | 4 +- 9 files changed, 313 insertions(+), 73 deletions(-) diff --git a/src/main/java/com/jvms/i18neditor/LookAndFeel.java b/src/main/java/com/jvms/i18neditor/LookAndFeel.java index 6828af4..b532a9f 100644 --- a/src/main/java/com/jvms/i18neditor/LookAndFeel.java +++ b/src/main/java/com/jvms/i18neditor/LookAndFeel.java @@ -8,6 +8,6 @@ * @author Jacob */ public class LookAndFeel { - public final static int TEXT_FIELD_COLS = 25; - public final static Color TEXTFIELD_BORDER_COLOR = Color.LIGHT_GRAY; + public final static Color BORDER_COLOR = Color.LIGHT_GRAY; + public final static Color PRIMARY_COLOR = new Color(83, 125, 157); } diff --git a/src/main/java/com/jvms/i18neditor/Main.java b/src/main/java/com/jvms/i18neditor/Main.java index 965bf86..7bcc6ff 100644 --- a/src/main/java/com/jvms/i18neditor/Main.java +++ b/src/main/java/com/jvms/i18neditor/Main.java @@ -24,7 +24,6 @@ public static void main(String[] args) { if (!SystemUtils.IS_OS_LINUX) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - UIManager.put("Tree.drawDashedFocusIndicator", false); } catch (Exception e) { // } diff --git a/src/main/java/com/jvms/i18neditor/editor/Editor.java b/src/main/java/com/jvms/i18neditor/editor/Editor.java index 21e7315..bbcf789 100644 --- a/src/main/java/com/jvms/i18neditor/editor/Editor.java +++ b/src/main/java/com/jvms/i18neditor/editor/Editor.java @@ -1,10 +1,12 @@ package com.jvms.i18neditor.editor; import java.awt.BorderLayout; +import java.awt.Component; import java.awt.Container; import java.awt.Desktop; import java.awt.Dimension; import java.awt.Image; +import java.awt.KeyboardFocusManager; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; @@ -102,6 +104,7 @@ public Editor() { super(); setupUI(); setupFileDrop(); + setupGlobalKeyEventDispatcher(); } public void createProject(Path dir, ResourceType type) { @@ -372,7 +375,7 @@ public void showRenameTranslationDialog(String key) { boolean isReplace = newNode.isLeaf() || oldNode.isLeaf(); boolean confirm = Dialogs.showConfirmDialog(this, MessageBundle.get("dialogs.translation.conflict.title"), - MessageBundle.get("dialogs.translation.conflict.text." + (isReplace ? "replace" : "merge")), + MessageBundle.get("dialogs.translation.conflict.text." + (isReplace?"replace":"merge")), JOptionPane.WARNING_MESSAGE); if (confirm) { renameTranslationKey(key, newKey); @@ -403,7 +406,7 @@ public void showDuplicateTranslationDialog(String key) { boolean isReplace = newNode.isLeaf() || oldNode.isLeaf(); boolean confirm = Dialogs.showConfirmDialog(this, MessageBundle.get("dialogs.translation.conflict.title"), - MessageBundle.get("dialogs.translation.conflict.text." + (isReplace ? "replace" : "merge")), + MessageBundle.get("dialogs.translation.conflict.text." + (isReplace?"replace":"merge")), JOptionPane.WARNING_MESSAGE); if (confirm) { duplicateTranslationKey(key, newKey); @@ -560,6 +563,47 @@ public void launch() { } } + public void updateUI() { + TranslationTreeNode selectedNode = translationTree.getSelectedNode(); + + resourcesPanel.removeAll(); + resourceFields = resourceFields.stream().sorted().collect(Collectors.toList()); + resourceFields.forEach(field -> { + Locale locale = field.getResource().getLocale(); + String label = locale != null ? locale.getDisplayName() : MessageBundle.get("resources.locale.default"); + field.setEnabled(selectedNode != null && selectedNode.isEditable()); + field.setRows(settings.getInputHeight()); + resourcesPanel.add(Box.createVerticalStrut(5)); + resourcesPanel.add(new JLabel(label)); + resourcesPanel.add(Box.createVerticalStrut(5)); + resourcesPanel.add(field); + resourcesPanel.add(Box.createVerticalStrut(10)); + }); + + Container container = getContentPane(); + if (project != null) { + container.add(contentPane); + container.remove(introText); + List resources = project.getResources(); + editorMenu.setEnabled(true); + editorMenu.setEditable(!resources.isEmpty()); + translationTree.setEditable(!resources.isEmpty()); + translationField.setEditable(!resources.isEmpty()); + } else { + container.add(introText); + container.remove(contentPane); + editorMenu.setEnabled(false); + editorMenu.setEditable(false); + translationTree.setEditable(false); + translationField.setEditable(false); + } + translationField.setVisible(settings.isShowKeyField()); + + updateTitle(); + validate(); + repaint(); + } + private void clearUI() { translationField.clear(); translationTree.clear(); @@ -584,14 +628,14 @@ private void setupUI() { translationField = new TranslationField(); translationField.addKeyListener(new TranslationFieldKeyListener()); translationField.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createMatteBorder(1,0,0,1,LookAndFeel.TEXTFIELD_BORDER_COLOR), + BorderFactory.createMatteBorder(1,0,0,1,LookAndFeel.BORDER_COLOR), ((CompoundBorder)translationField.getBorder()).getInsideBorder())); JScrollPane translationsScrollPane = new JScrollPane(translationTree); translationsScrollPane.getViewport().setOpaque(false); translationsScrollPane.setOpaque(false); translationsScrollPane.setBorder( - BorderFactory.createMatteBorder(0,0,0,1,LookAndFeel.TEXTFIELD_BORDER_COLOR)); + BorderFactory.createMatteBorder(0,0,0,1,LookAndFeel.BORDER_COLOR)); translationsPanel = new JPanel(new BorderLayout()); translationsPanel.add(translationsScrollPane); @@ -654,6 +698,61 @@ public void filesDropped(java.io.File[] files) { }); } + private void setupGlobalKeyEventDispatcher() { + KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(e -> { + if (!e.isAltDown() || e.getID() != KeyEvent.KEY_PRESSED) { + return false; + } + TreePath selected = translationTree.getSelectionPath(); + if (selected == null) { + return false; + } + boolean result = false; + int row = translationTree.getRowForPath(selected); + switch (e.getKeyCode()) { + case KeyEvent.VK_RIGHT: + if (translationTree.isExpanded(row)) { + translationTree.setSelectionRow(row+1); + } else { + translationTree.expandRow(row); + } + result = true; + break; + case KeyEvent.VK_LEFT: + if (translationTree.isCollapsed(row)) { + translationTree.setSelectionPath(selected.getParentPath()); + } else { + translationTree.collapseRow(row); + } + result = true; + break; + case KeyEvent.VK_UP: + translationTree.setSelectionRow(Math.max(0, row-1)); + result = true; + break; + case KeyEvent.VK_DOWN: + TreePath next = translationTree.getPathForRow(row+1); + if (next != null) { + translationTree.setSelectionPath(next); + } + result = true; + break; + } + if (result && !resourceFields.isEmpty()) { + Component comp = getFocusOwner(); + if (comp != null && (comp instanceof ResourceField || comp.equals(this))) { + TranslationTreeNode current = translationTree.getSelectedNode(); + if (!current.isLeaf() || current.isRoot()) { + requestFocusInWindow(); + } else if (comp.equals(this)) { + resourceFields.get(0).requestFocusInWindow(); + } + } + } + return result; + }); + } + private void setupResource(Resource resource) { resource.addListener(e -> setDirty(true)); ResourceField field = new ResourceField(resource); @@ -661,44 +760,6 @@ private void setupResource(Resource resource) { resourceFields.add(field); } - private void updateUI() { - TranslationTreeNode selectedNode = translationTree.getSelectedNode(); - - resourcesPanel.removeAll(); - resourceFields.stream().sorted().forEach(field -> { - Locale locale = field.getResource().getLocale(); - String label = locale != null ? locale.getDisplayName() : MessageBundle.get("resources.locale.default"); - field.setEditable(selectedNode != null && selectedNode.isEditable()); - resourcesPanel.add(Box.createVerticalStrut(5)); - resourcesPanel.add(new JLabel(label)); - resourcesPanel.add(Box.createVerticalStrut(5)); - resourcesPanel.add(field); - resourcesPanel.add(Box.createVerticalStrut(10)); - }); - - Container container = getContentPane(); - if (project != null) { - container.add(contentPane); - container.remove(introText); - List resources = project.getResources(); - editorMenu.setEnabled(true); - editorMenu.setEditable(!resources.isEmpty()); - translationTree.setEditable(!resources.isEmpty()); - translationField.setEditable(!resources.isEmpty()); - } else { - container.add(introText); - container.remove(contentPane); - editorMenu.setEnabled(false); - editorMenu.setEditable(false); - translationTree.setEditable(false); - translationField.setEditable(false); - } - - updateTitle(); - validate(); - repaint(); - } - private void updateHistory() { List recentDirs = settings.getHistory(); if (project != null) { @@ -762,6 +823,8 @@ private void storeEditorState() { props.setProperty("minify_resources", settings.isMinifyResources()); props.setProperty("resource_name", settings.getResourceName()); props.setProperty("check_version", settings.isCheckVersionOnStartup()); + props.setProperty("input_height", settings.getInputHeight()); + props.setProperty("key_field", settings.isShowKeyField()); if (!settings.getHistory().isEmpty()) { props.setProperty("history", settings.getHistory()); } @@ -792,6 +855,8 @@ private void restoreEditorState() { settings.setMinifyResources(props.getBooleanProperty("minify_resources", false)); settings.setResourceName(props.getProperty("resource_name", DEFAULT_RESOURCE_NAME)); settings.setCheckVersionOnStartup(props.getBooleanProperty("check_version", true)); + settings.setInputHeight(props.getIntegerProperty("input_height", 5)); + settings.setShowKeyField(props.getBooleanProperty("key_field", true)); } private class TranslationTreeMouseListener extends MouseAdapter { @@ -836,7 +901,7 @@ public void valueChanged(TreeSelectionEvent e) { translationField.setValue(key); resourceFields.forEach(f -> { f.setValue(key); - f.setEditable(node.isEditable()); + f.setEnabled(node.isEditable()); }); // Restore scroll position diff --git a/src/main/java/com/jvms/i18neditor/editor/EditorSettings.java b/src/main/java/com/jvms/i18neditor/editor/EditorSettings.java index 3135615..0280c07 100644 --- a/src/main/java/com/jvms/i18neditor/editor/EditorSettings.java +++ b/src/main/java/com/jvms/i18neditor/editor/EditorSettings.java @@ -19,6 +19,8 @@ public class EditorSettings { private List lastExpandedNodes; private String lastSelectedNode; private boolean checkVersionOnStartup; + private int inputHeight; + private boolean showKeyField; public int getWindowPositionX() { return windowPositionX; @@ -107,4 +109,20 @@ public boolean isCheckVersionOnStartup() { public void setCheckVersionOnStartup(boolean checkVersionOnStartup) { this.checkVersionOnStartup = checkVersionOnStartup; } + + public int getInputHeight() { + return inputHeight; + } + + public void setInputHeight(int rows) { + this.inputHeight = rows; + } + + public boolean isShowKeyField() { + return showKeyField; + } + + public void setShowKeyField(boolean showKeyField) { + this.showKeyField = showKeyField; + } } diff --git a/src/main/java/com/jvms/i18neditor/editor/EditorSettingsPane.java b/src/main/java/com/jvms/i18neditor/editor/EditorSettingsPane.java index 1e44ee6..b7239ba 100644 --- a/src/main/java/com/jvms/i18neditor/editor/EditorSettingsPane.java +++ b/src/main/java/com/jvms/i18neditor/editor/EditorSettingsPane.java @@ -8,6 +8,7 @@ import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JSlider; import com.jvms.i18neditor.swing.JTextField; import com.jvms.i18neditor.util.MessageBundle; @@ -41,7 +42,7 @@ private void setupUI() { // New project settings JPanel fieldset2 = createFieldset(MessageBundle.get("settings.fieldset.newprojects")); - JPanel resourcePanel = new JPanel(new GridLayout(0, 1)); + JPanel resourceNamePanel = new JPanel(new GridLayout(0, 1)); JLabel resourceNameLabel = new JLabel(MessageBundle.get("settings.resourcename.title")); JTextField resourceNameField = new JTextField(settings.getResourceName()); resourceNameField.addKeyListener(new KeyAdapter() { @@ -51,17 +52,40 @@ public void keyReleased(KeyEvent e) { settings.setResourceName(value.isEmpty() ? Editor.DEFAULT_RESOURCE_NAME : value); } }); - resourcePanel.add(resourceNameLabel); - resourcePanel.add(resourceNameField); - fieldset2.add(resourcePanel, createVerticalGridBagConstraints()); + resourceNamePanel.add(resourceNameLabel); + resourceNamePanel.add(resourceNameField); + fieldset2.add(resourceNamePanel, createVerticalGridBagConstraints()); JCheckBox minifyBox = new JCheckBox(MessageBundle.get("settings.minify.title")); minifyBox.setSelected(settings.isMinifyResources()); minifyBox.addChangeListener(e -> settings.setMinifyResources(minifyBox.isSelected())); fieldset2.add(minifyBox, createVerticalGridBagConstraints()); + // Editing settings + JPanel fieldset3 = createFieldset("Editing"); + + JCheckBox keyFieldBox = new JCheckBox("Show translation key field"); + keyFieldBox.setSelected(settings.isShowKeyField()); + keyFieldBox.addChangeListener(e -> { + settings.setShowKeyField(keyFieldBox.isSelected()); + editor.updateUI(); + }); + fieldset3.add(keyFieldBox, createVerticalGridBagConstraints()); + + JPanel resourceHeightPanel = new JPanel(new GridLayout(0, 1)); + JLabel resourceHeightLabel = new JLabel("Default input height"); + JSlider resourceHeightSlider = new JSlider(JSlider.HORIZONTAL, 1, 15, settings.getInputHeight()); + resourceHeightSlider.addChangeListener(e -> { + settings.setInputHeight(resourceHeightSlider.getValue()); + editor.updateUI(); + }); + resourceHeightPanel.add(resourceHeightLabel); + resourceHeightPanel.add(resourceHeightSlider); + fieldset3.add(resourceHeightPanel, createVerticalGridBagConstraints()); + setLayout(new GridBagLayout()); add(fieldset1, createVerticalGridBagConstraints()); add(fieldset2, createVerticalGridBagConstraints()); + add(fieldset3, createVerticalGridBagConstraints()); } } diff --git a/src/main/java/com/jvms/i18neditor/editor/ResourceField.java b/src/main/java/com/jvms/i18neditor/editor/ResourceField.java index 954e34a..3c86dc3 100644 --- a/src/main/java/com/jvms/i18neditor/editor/ResourceField.java +++ b/src/main/java/com/jvms/i18neditor/editor/ResourceField.java @@ -48,8 +48,6 @@ public int compareTo(ResourceField o) { } private void setupUI() { - setRows(10); - // Add focus traversal support setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null); setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null); diff --git a/src/main/java/com/jvms/i18neditor/editor/TranslationTree.java b/src/main/java/com/jvms/i18neditor/editor/TranslationTree.java index 2d65dde..859b9aa 100644 --- a/src/main/java/com/jvms/i18neditor/editor/TranslationTree.java +++ b/src/main/java/com/jvms/i18neditor/editor/TranslationTree.java @@ -1,18 +1,30 @@ package com.jvms.i18neditor.editor; +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Rectangle; import java.util.Enumeration; import java.util.List; -import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JTree; +import javax.swing.KeyStroke; +import javax.swing.UIManager; import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeWillExpandListener; +import javax.swing.plaf.basic.BasicTreeUI; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.ExpandVetoException; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; import com.google.common.collect.Lists; +import com.jvms.i18neditor.LookAndFeel; import com.jvms.i18neditor.util.ResourceKeys; /** @@ -58,6 +70,10 @@ public void expand(List nodes) { nodes.forEach(n -> expandPath(new TreePath(n.getPath()))); } + public void collapse(List nodes) { + nodes.forEach(n -> collapsePath(new TreePath(n.getPath()))); + } + public TranslationTreeNode addNodeByKey(String key) { TranslationTreeModel model = (TranslationTreeModel) getModel(); TranslationTreeNode node = model.getNodeByKey(key); @@ -131,22 +147,6 @@ public void clear() { setModel(new TranslationTreeModel()); } - private void setupUI() { - DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer)getCellRenderer(); - renderer.setLeafIcon(null); - renderer.setClosedIcon(null); - renderer.setOpenIcon(null); - renderer.setBorderSelectionColor(renderer.getBackgroundSelectionColor()); - renderer.setBorder(BorderFactory.createCompoundBorder(getBorder(), - BorderFactory.createEmptyBorder(2,2,2,2))); - - addTreeWillExpandListener(new TranslationTreeExpandListener()); - setEditable(false); - - // Remove F2 keystroke binding - getActionMap().getParent().remove("startEditing"); - } - private void duplicateNodeByKey(String key, String newKey, boolean keepOld) { TranslationTreeModel model = (TranslationTreeModel) getModel(); TranslationTreeNode node = model.getNodeByKey(key); @@ -180,9 +180,109 @@ private void duplicateNodeByKey(String key, String newKey, boolean keepOld) { setSelectedNode(node); } + private void setupUI() { + UIManager.put("Tree.repaintWholeRow", Boolean.TRUE); + + setUI(new TranslationTreeUI()); + setCellRenderer(new TranslationTreeCellRenderer()); + addTreeWillExpandListener(new TranslationTreeExpandListener()); + setEditable(false); + setOpaque(false); + setToggleClickCount(1); + + // Remove all key strokes + InputMap inputMap = getInputMap().getParent(); + for (KeyStroke k : getRegisteredKeyStrokes()) { + inputMap.remove(k); + } + } + + @Override + protected void paintComponent(Graphics g) { + Rectangle r; + g.setColor(getBackground()); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(LookAndFeel.PRIMARY_COLOR); + for (int i : getSelectionRows()) { + r = getRowBounds(i); + g.fillRect(0, r.y, getWidth(), r.height); + } + super.paintComponent(g); + } + + private class TranslationTreeCellRenderer extends DefaultTreeCellRenderer { + private final static long serialVersionUID = 3511394180407171920L; + + public TranslationTreeCellRenderer() { + super(); + setLeafIcon(null); + setClosedIcon(null); + setOpenIcon(null); + setRowHeight(Math.max(getRowHeight() + 6, 22)); + } + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, + boolean leaf, int row, boolean hasFocus) { + JLabel l = (JLabel) super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); + if (selected) { + l.setForeground(Color.WHITE); + } + l.setBackground(selected ? LookAndFeel.PRIMARY_COLOR : tree.getBackground()); + l.setOpaque(true); + return l; + } + } + + private class TranslationTreeUI extends BasicTreeUI { + private TranslationTreeToggleIcon expandedIcon = new TranslationTreeToggleIcon(TranslationTreeToggleIcon.Type.Expanded); + private TranslationTreeToggleIcon collapsedIcon = new TranslationTreeToggleIcon(TranslationTreeToggleIcon.Type.Collapsed); + + @Override + protected void paintVerticalLine(Graphics g, JComponent c, int y, int left, int right) {} + + @Override + protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left, int right) {} + + @Override + protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path) {} + + @Override + protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, + TreePath path, int row, boolean expanded, boolean hasBeenExpanded, boolean leaf) {} + + @Override + public Rectangle getPathBounds(JTree tree, TreePath path) { + if (tree != null && treeState != null) { + return getPathBounds(path, tree.getInsets(), new Rectangle()); + } + return null; + } + + @Override + public Icon getCollapsedIcon() { + return collapsedIcon; + } + + @Override + public Icon getExpandedIcon() { + return expandedIcon; + } + + private Rectangle getPathBounds(TreePath path, Insets insets, Rectangle bounds) { + bounds = treeState.getBounds(path, bounds); + if (bounds != null) { + bounds.x = 0; + bounds.y += insets.top; + bounds.width = tree.getWidth(); + } + return bounds; + } + } + private class TranslationTreeExpandListener implements TreeWillExpandListener { @Override - public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {} + public void treeWillExpand(TreeExpansionEvent e) throws ExpandVetoException {} @Override public void treeWillCollapse(TreeExpansionEvent e) throws ExpandVetoException { @@ -192,4 +292,40 @@ public void treeWillCollapse(TreeExpansionEvent e) throws ExpandVetoException { } } } + + private static class TranslationTreeToggleIcon implements Icon { + private final static int SIZE = 10; + private final Type type; + + public enum Type { + Collapsed, Expanded + } + + public TranslationTreeToggleIcon(Type type) { + this.type = type; + } + + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + g.setColor(UIManager.getColor("Tree.background")); + g.fillRect(x, y, SIZE, SIZE); + g.setColor(UIManager.getColor("Tree.hash").darker()); + g.drawRect(x, y, SIZE, SIZE); + g.setColor(UIManager.getColor("Tree.foreground")); + g.drawLine(x + 2, y + SIZE/2, x + SIZE - 2, y + SIZE/2); + if (type == Type.Collapsed) { + g.drawLine(x + SIZE/2, y + 2, x + SIZE/2, y + SIZE - 2); + } + } + + @Override + public int getIconWidth() { + return SIZE; + } + + @Override + public int getIconHeight() { + return SIZE; + } + } } diff --git a/src/main/java/com/jvms/i18neditor/swing/JTextArea.java b/src/main/java/com/jvms/i18neditor/swing/JTextArea.java index d9b80ce..1df1431 100644 --- a/src/main/java/com/jvms/i18neditor/swing/JTextArea.java +++ b/src/main/java/com/jvms/i18neditor/swing/JTextArea.java @@ -27,7 +27,7 @@ public class JTextArea extends javax.swing.JTextArea { public JTextArea() { super(); - Border border = BorderFactory.createLineBorder(LookAndFeel.TEXTFIELD_BORDER_COLOR); + Border border = BorderFactory.createLineBorder(LookAndFeel.BORDER_COLOR); setBorder(BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(6,8,6,8))); getDocument().addUndoableEditListener(e -> undoManager.addEdit(e.getEdit())); diff --git a/src/main/java/com/jvms/i18neditor/swing/JTextField.java b/src/main/java/com/jvms/i18neditor/swing/JTextField.java index ff12725..02c81c1 100644 --- a/src/main/java/com/jvms/i18neditor/swing/JTextField.java +++ b/src/main/java/com/jvms/i18neditor/swing/JTextField.java @@ -32,9 +32,9 @@ public JTextField() { * Constructs a {@link JTextField} with an initial text. */ public JTextField(String text) { - super(text, LookAndFeel.TEXT_FIELD_COLS); + super(text, 25); - Border border = BorderFactory.createLineBorder(LookAndFeel.TEXTFIELD_BORDER_COLOR); + Border border = BorderFactory.createLineBorder(LookAndFeel.BORDER_COLOR); setBorder(BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(6,8,6,8))); getDocument().addUndoableEditListener(e -> undoManager.addEdit(e.getEdit()));