Add scroll into text area

After adding JTextArea into JScrollPane here: scroll = new JScrollPane(display); You don’t need to add it again into other container like you do: middlePanel.add(display); Just remove that last line of code and it will work fine. Like this: middlePanel=new JPanel(); middlePanel.setBorder(new TitledBorder(new EtchedBorder(), “Display Area”)); // create the middle panel components display = new JTextArea(16, … Read more

Centering Text in a JTextArea or JTextPane – Horizontal Text Alignment

You need to use a JTextPane and use attributes. The following should center all the text: StyledDocument doc = textPane.getStyledDocument(); SimpleAttributeSet center = new SimpleAttributeSet(); StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER); doc.setParagraphAttributes(0, doc.getLength(), center, false); Edit: Vertical centering is not supported as far as I know. Here is some code you might find useful: Vertical Alignment of JTextPane

How to set AUTO-SCROLLING of JTextArea in Java GUI?

When using JDK1.4.2 (or earlier) the most common suggestion you will find in the forums is to use code like the following: textArea.append(…); textArea.setCaretPosition(textArea.getDocument().getLength()); However, I have just noticed that in JDK5 this issue has actually been resolved by an API change. You can now control this behaviour by setting a property on the DefaultCaret … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)