JComponent () { myPanel = new JPanel(new GridBagLayout()); myStartIndex = new JTextField(5); myEndIndex = new JTextField(5); myEntriesLimit = new JTextField(5); final FontMetrics fontMetrics = myStartIndex.getFontMetrics(myStartIndex.getFont()); final Dimension minSize = new Dimension(myStartIndex.getPreferredSize()); minSize.width = fontMetrics.stringWidth("AAAAA"); myStartIndex.setMinimumSize(minSize); myEndIndex.setMinimumSize(minSize); myEntriesLimit.setMinimumSize(minSize); JLabel startIndexLabel = new JLabel(JavaDebuggerBundle.message("label.array.renderer.configurable.start.index")); startIndexLabel.setLabelFor(myStartIndex); JLabel endIndexLabel = new JLabel(JavaDebuggerBundle.message("label.array.renderer.configurable.end.index")); endIndexLabel.setLabelFor(myEndIndex); JLabel entriesLimitLabel = new JLabel(JavaDebuggerBundle.message("label.array.renderer.configurable.max.count1")); entriesLimitLabel.setLabelFor(myEntriesLimit); myPanel.add(startIndexLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsRight(8), 0, 0)); myPanel.add(myStartIndex, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insetsRight(8), 0, 0)); myPanel.add(endIndexLabel, new GridBagConstraints(2, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsRight(8), 0, 0)); myPanel.add(myEndIndex, new GridBagConstraints(3, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBInsets.emptyInsets(), 0, 0)); myPanel.add(entriesLimitLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(4, 0, 0, 8), 0, 0)); myPanel.add(myEntriesLimit, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(4, 0, 0, 8), 0, 0)); myPanel.add(new JLabel(JavaDebuggerBundle.message("label.array.renderer.configurable.max.count2")), new GridBagConstraints(2, GridBagConstraints.RELATIVE, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsTop(4), 0, 0)); // push other components up myPanel.add(new JLabel(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBInsets.emptyInsets(), 0, 0)); final DocumentListener listener = new DocumentListener() { private void updateEntriesLimit() { final boolean state = myIndexUpdateEnabled; myIndexUpdateEnabled = false; try { if (myEntriesLimitUpdateEnabled) { myEntriesLimit.setText(String.valueOf(getInt(myEndIndex) - getInt(myStartIndex) + 1)); } } finally { myIndexUpdateEnabled = state; } } @Override public void changedUpdate(DocumentEvent e) { updateEntriesLimit(); } @Override public void insertUpdate(DocumentEvent e) { updateEntriesLimit(); } @Override public void removeUpdate(DocumentEvent e) { updateEntriesLimit(); } }; myStartIndex.getDocument().addDocumentListener(listener); myEndIndex.getDocument().addDocumentListener(listener); myEntriesLimit.getDocument().addDocumentListener(new DocumentListener() { private void updateEndIndex() { final boolean state = myEntriesLimitUpdateEnabled; myEntriesLimitUpdateEnabled = false; try { if (myIndexUpdateEnabled) { myEndIndex.setText(String.valueOf(getInt(myEntriesLimit) + getInt(myStartIndex) - 1)); } } finally { myEntriesLimitUpdateEnabled = state; } } @Override public void insertUpdate(DocumentEvent e) { updateEndIndex(); } @Override public void removeUpdate(DocumentEvent e) { updateEndIndex(); } @Override public void changedUpdate(DocumentEvent e) { updateEndIndex(); } }); return myPanel; }