It doesn’t work because you didn’t attach the ScrollPane to the JFrame.
Also, you don’t need 2 JScrollPanes:
JFrame frame = new JFrame ("Test"); JTextArea textArea = new JTextArea ("Test"); JScrollPane scroll = new JScrollPane (textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); frame.add(scroll); frame.setVisible (true);
Related Posts:
- Difference between java.exe and javaw.exe
- Simple Java 2D graphics: draw a rectangle?
- Resizing image in Java
- Java: Difference between the setPreferredSize() and setSize() methods in components
- How do you add an ActionListener onto a JButton in Java
- How to make PopUp window in java
- How to use Java AWT setBackground
- JFrame in full screen Java
- Java: Custom Buttons in showInputDialog
- java.awt.EventQueue.invokeLater explained
- KeyPressed event in java
- How change the color arrowIcon to JMenu when it is selected
- Getting a HeadlessException: No X11 DISPLAY variable was set
- error upon assigning Layout: BoxLayout can’t be shared
- How do I draw a triangle?
- Java: Rotating Images
- JOptionPane YES NO OPTION
- How do I draw a triangle?
- What does “AL lib: alc_cleanup: 1 device not closed” mean?
- Java GUI: about getContentPane( ) method and content
- How to center the text in a JLabel?
- How to add an image to a JPanel?
- How to repaint a JPanel after have drawn on it?
- Implementing an actionlistener to a JTextField
- How to Set JPanel’s Width and Height?
- addMouseListener for a JPanel
- Java Wait for thread to finish
- Swing/Java: How to use the getText and setText string properly
- What does super.paintComponent(g) do?
- How to Set the Background Color of a JButton on the Mac OS
- Java Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
- Popup Message boxes
- Exception in thread “AWT-EventQueue-0”?
- make a JLabel wrap it’s text by setting a max width
- Keylistener not working for JPanel
- setMnemonic() and call a method by pressing the key
- the getSource() and getActionCommand()
- How to programmatically close a JFrame
- How does addNotify() and requestFocus() work in Java with JPanel?
- DTO and DAO concepts and MVC
- Adding JPanel to JFrame
- Adding image to JFrame
- How to Retrieve value from JTextField in Java Swing?
- Setting background color for a JFrame
- What does .pack() do?
- Setting background images in JFrame
- Java Swing revalidate() vs repaint()
- How does paintComponent work?
- How can I set size of a button?
- Java Swing setting JPanel Size
- How to draw a circle with given X and Y coordinates as the middle spot of the circle?
- JOptionPane Yes or No window
- What is the best way to implement constants in Java?
- What is the reason behind “non-static method cannot be referenced from a static context”?
- What does ” || ” mean in Java? [duplicate]
- max value of integer
- “Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G
- “int cannot be dereferenced” in Java
- What is a Key-Value Pair?
- What is a serialVersionUID and why should I use it?
- SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”
- The difference between += and =+
- exception in initializer error in java when using Netbeans
- What does “?” mean in Java?
- what does Dead Code mean under Eclipse IDE Problems Section
- Print in new line, java
- How to override equals method in Java
- Java compressing Strings
- Can an abstract class have a constructor?
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- “NoClassDefFoundError: Could not initialize class” error
- Recursive print Factorial
- Generate a random double in a range
- Eclipse “Error: Could not find or load main class”
- How to get locator of current web element?
- javax.naming.NameNotFoundException
- How to print out all the elements of a List in Java?
- If Java is Strongly typed then why does this code compile?
- Error: cannot find symbol ArrayList
- Using Math.round to round to one decimal place?
- How to replace a substring of a string
- accessing a variable from another class
- “Javac” doesn’t work correctly on Windows 10
- How to extract a substring using regex
- .class vs .java
- Case expressions must be constant expressions for static final int?
- try catch ArrayIndexOutOfBoundsException?
- Response has aready been committed
- “Source folder is not a Java project” error in eclipse
- How to memory profile in Java?
- java.lang.IllegalThreadStateException
- What is an
method in Java? Can it be overridden? - The sum of all squares between 1 and 100 inclusive?
- How do I initialize a byte array in Java?
- How to map a composite key with JPA and Hibernate?
- Javac “cannot find symbol”
- Byte and char conversion in Java
- Java “lambda expressions not supported at this language level”
- How to specify filepath in java?
- Issue installing Netbeans in Windows 10: Java SE Development Kit (JDK) was not found on this computer