Results 1 to 2 of 2
  1. #1
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    259
    Rep Power
    10

    Default Adding JScrollPane to a JFrame

    Here is my code:

    Java Code:
    JTextArea activityTextArea = new JTextArea("Console Log Window");
    		activityTextArea.setBounds(10, 120, 200, 25);
    		activityTextArea.setBackground(black);
    		activityTextArea.setForeground(white);
    		activityTextArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    		//frame.add(activityTextArea);
    		
    		JScrollPane scroll = new JScrollPane (activityTextArea, 
    				   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    		scroll.setPreferredSize(new Dimension(200, 25));
    		frame.add(scroll);
    When I uncomment the one line, and comment the scrollpane stuff, the text box shows up.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Adding JScrollPane to a JFrame

    Do you have a question?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. adding keylistener to JFrame
    By Alkor in forum New To Java
    Replies: 3
    Last Post: 03-08-2012, 12:02 PM
  2. Replies: 4
    Last Post: 12-29-2011, 08:23 AM
  3. Adding JTable to empty JScrollPane
    By kbro3 in forum New To Java
    Replies: 4
    Last Post: 03-15-2011, 05:53 AM
  4. Adding jscrollpane when extending jpanel
    By phil128 in forum AWT / Swing
    Replies: 4
    Last Post: 01-18-2011, 11:30 PM
  5. Help adding JScrollBar/JScrollPane to JTextPane
    By crikey in forum AWT / Swing
    Replies: 7
    Last Post: 08-30-2010, 12:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •