List of utility methods to do JTextArea
void | copyFontAndMargins(final JTextArea target, final JComponent source) copy Font And Margins final Insets insets = source.getInsets();
target.setFont(source.getFont());
target.setMargin(insets);
|
JPanel | createTabArea(JTextArea area, int width) create Tab Area area.setEditable(false); area.setOpaque(false); area.setLineWrap(true); final JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS)); if (width > 0) panel.add(Box.createHorizontalStrut(width)); panel.add(area); ... |
void | display(JTextArea txtOutput, String text) display if (txtOutput != null) { txtOutput.setText(txtOutput.getText() + "\n" + text); } else { System.out.println(text); |
int | estimatedRows(JTextArea text) estimated Rows return (int) (((text.getText().length() / (text.getColumns() > 0 ? text.getColumns() : 80)) + 1 + text.getText().replaceAll("[^\\n]+", "").length()) / 2); |
JTextArea | fixTabKeys(JTextArea textArea) fix Tab Keys return textArea;
|
String | getAreaValue(JTextArea ta) get Area Value String ret = ta.getText().trim(); if (!ret.equals("")) { return ret; return null; |
JScrollPane | getTextAreaScrollPaneContainer(JTextArea textArea, int nbLines) get Text Area Scroll Pane Container JScrollPane ret = new JScrollPane(); textArea.setRows(nbLines); textArea.setColumns(20); ret.setViewportView(textArea); return ret; |
Dimension | getTextDimension(JTextArea textArea, Dimension maxDimension) get Text Dimension Font font = textArea.getFont(); FontMetrics metrics = textArea.getGraphics().getFontMetrics(font); int width = metrics.stringWidth(getLongestLine(textArea.getText())) + wPadding; int height = (metrics.getHeight() + hPadding) * countLines(textArea.getText()); if (width > maxDimension.width) width = maxDimension.width; if (height > maxDimension.height) height = maxDimension.height; ... |
void | initLogConsole(final JTextArea textArea) init Log Console OutputStream textAreaStream = new OutputStream() { public void write(int b) throws IOException { clearTextArea(textArea); textArea.append(String.valueOf((char) b)); public void write(byte b[]) throws IOException { clearTextArea(textArea); textArea.append(new String(b)); ... |
void | initTextAreaEdit(JTextArea j1) init Text Area Edit j1.setLineWrap(true); j1.setWrapStyleWord(true); |