JComponent () { final class MyTextField extends JTextField { MyTextField() { super(""); addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (!e.isTemporary()) { selectAll(); } } }); } @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); return new Dimension(200, d.height); } } JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbConstraints = new GridBagConstraints(); gbConstraints.insets = JBUI.insets(4, 0, 8, 8); gbConstraints.fill = GridBagConstraints.VERTICAL; gbConstraints.weightx = 0; gbConstraints.weighty = 1; gbConstraints.anchor = GridBagConstraints.EAST; JLabel label = new JLabel(IdeBundle.message("label.line.column")); panel.add(label, gbConstraints); gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.weightx = 1; myField = new MyTextField(); panel.add(myField, gbConstraints); myField.setText(String.format("%d:%d", getLine() + 1, getColumn() + 1)); if (ApplicationManager.getApplication().isInternal()) { gbConstraints.gridy = 1; gbConstraints.weightx = 0; gbConstraints.weighty = 1; gbConstraints.anchor = GridBagConstraints.EAST; final JLabel offsetLabel = new JLabel(IdeBundle.message("label.offset")); panel.add(offsetLabel, gbConstraints); gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.weightx = 1; myOffsetField = new MyTextField(); panel.add(myOffsetField, gbConstraints); myOffsetField.setText(String.valueOf(getOffset())); DocumentAdapter valueSync = new DocumentAdapter() { boolean inSync; @Override protected void textChanged(@NotNull DocumentEvent e) { if (inSync) return; inSync = true; String s = "<invalid>"; JTextField f = null; try { if (e.getDocument() == myField.getDocument()) { f = myOffsetField; Coordinates p = getCoordinates(); s = p == null ? s : String.valueOf(coordinatesToOffset(p)); } else { f = myField; int offset = StringUtil.parseInt(myOffsetField.getText(), -1); Coordinates p = offset >= 0 ? offsetToCoordinates(Math.min(getMaxOffset() - 1, offset)) : null; s = p == null ? s : String.format("%d:%d", p.row + 1, p.column + 1); } f.setText(s); } catch (IndexOutOfBoundsException ignored) { if (f != null) f.setText(s); } finally { inSync = false; } } }; myField.getDocument().addDocumentListener(valueSync); myOffsetField.getDocument().addDocumentListener(valueSync); } return panel; }