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

After mac os sierra update facing scrolling issue with Java applications like Intellij

This is a known bug, likely caused by the JDK: It looks like JDK issue and is reproducible with a simple scrollable JList. Sierra generates much more events than El Captain. These events contain values ~0.1 instead of expected ~1. But Java converts these small number to 1 anyway. Edit: see also this OpenJDK bug: … Read more

How to get rid of the border with a JTable / JScrollPane

Use BorderFactory.createEmptyBorder() instead of null… by using: sp.setBorder(createEmptyBorder()); it works. Your main method becomes: public static void main(String[] args) { JFrame frame = new TestScrollPane(); JPanel panel = new JPanel(); JTable table = new JTable(); panel.setLayout(new BorderLayout()); panel.add(new JLabel(“NORTH”), BorderLayout.NORTH); panel.add(new JLabel(“SOUTH”), BorderLayout.SOUTH); JScrollPane sp = new JScrollPane(table); sp.setBorder(BorderFactory.createEmptyBorder()); panel.add(sp, BorderLayout.CENTER); frame.add(panel); frame.setVisible(true); }

JTable with horizontal scrollbar

First, add your JTable inside a JScrollPane and set the policy for the existence of scrollbars: new JScrollPane(myTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); Then, indicate that your JTable must not auto-resize the columns by setting the AUTO_RESIZE_OFF mode: myJTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

JTable Scrolling to a Specified Row Index

It’s very easy, JTable has scrollRectToVisible method too. If you want, you can try something like this to make scrollpane go to to the bottom if a new record is added : jTable1.getSelectionModel().setSelectionInterval(i, i); jTable1.scrollRectToVisible(new Rectangle(jTable1.getCellRect(i, 0, true))); Where i is last added record.

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