/** * Sets the minimum number of rows that will be displayed * * @param minRows The minimum number of rows. */ public void setMinRows(int minRows) { _minRows = minRows; setRows(clipRowCount(getRows())); }
@Override public Dimension getPreferredScrollableViewportSize() { Dimension size = getPreferredSize(); if (getMinRows() != 0 && getMaxRows() != 0) { size.height = Math.max(getHeight(getMinRows()), Math.min(getHeight(getMaxRows()), size.height)); } return size; }
private int getHeight(int rows) { Insets insets = getInsets(); return rows * getRowHeight() + insets.top + insets.bottom; }
AutoResizingTextArea ta = new AutoResizingTextArea(text); ta.setMaximumSize(new Dimension(99999, 1)); ta.setForeground(TEXT_COLOR); ta.setLineWrap(true); ta.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { ta.setOpaque(false); ta.setWrapStyleWord(true); ta.setEditable(false); date.setAlignmentX(Component.LEFT_ALIGNMENT); p.add(date); ta.setAlignmentX(Component.LEFT_ALIGNMENT); p.add(ta);
private JComponent createWktInputPanel() { final JTextArea textArea = new AutoResizingTextArea(3, 30); //Overrides behavior when set enabled textArea.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (textArea.isEnabled()) { textArea.setBackground(Color.WHITE); } else { textArea.setBackground(new Color(240, 240, 240)); } } }); bindingContext.bind(BinningFormModel.PROPERTY_KEY_WKT, textArea); bindingContext.bindEnabledState(BinningFormModel.PROPERTY_KEY_WKT, false, BinningFormModel.PROPERTY_KEY_MANUAL_WKT, false); textArea.setEnabled(false); return new JScrollPane(textArea); }
/** * Sets the number of visible rows. The row value will be forced to the boundaries of the range [minRows ... * maxRows] if it is outside that range. * * @param rows The number of rows to show */ @Override public void setRows(int rows) { int oldRow = super.getRows(); int newRow = clipRowCount(rows); super.setRows(newRow); numberOfRowsUpdated(oldRow, newRow); }
@Override public void setDocument(Document doc) { Document document = getDocument(); if (document != null && _listener != null) { document.removeDocumentListener(_listener); } super.setDocument(doc); if (doc != null) { if (_listener == null) { _listener = new ResizingDocumentListener(); } doc.addDocumentListener(_listener); } updateSize(); }
/** * Gets the parent scroll pane if any. * * @return the parent scroll pane. If not found, null will be returned. */ private JScrollPane getParentScrollPane() { Component parent = getParent(); if (parent != null && parent instanceof JViewport) { return (JScrollPane) parent.getParent(); } return null; } }
private JComponent createWktInputPanel() { final JTextArea textArea = new AutoResizingTextArea(3, 30); //Overrides behavior when set enabled textArea.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (textArea.isEnabled()) { textArea.setBackground(Color.WHITE); } else { textArea.setBackground(new Color(240, 240, 240)); } } }); bindingContext.bind(BinningFormModel.PROPERTY_KEY_WKT, textArea); bindingContext.bindEnabledState(BinningFormModel.PROPERTY_KEY_WKT, false, BinningFormModel.PROPERTY_KEY_MANUAL_WKT, false); textArea.setEnabled(false); return new JScrollPane(textArea); }
/** * Sets the maximum number of rows that will be displayed. * * @param maxRows The maximum number of rows. */ public void setMaxRows(int maxRows) { _maxRows = maxRows; setRows(clipRowCount(getRows())); }