Results 1 to 5 of 5

Thread: JTextArea

  1. #1
    larry_d1990 is offline Member
    Join Date
    Jan 2011
    Posts
    11
    Rep Power
    0

    Default JTextArea

    My program has trouble showing the entire JTextArea. In my program I have a JPanel, that I've also drawn on using the paint method, and a jTextArea (all within one jframe). My JTextArea dimensions are 200, 500, however there is only a small white area which expands when typing. Ideally, I want both my drawing within the jpanel, and the jtextarea next to it and completely white to the specifications 200,500. Help please!!!!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    It's hard to know what your problem is based on the description you give, but guesses include incorrect use of layout managers and incorrect painting (e.g., why are you painting in paint, not in paintComponent?). For more specific help, consider creating and posting an SSCCE (see link below) and giving us more information about the problem.

    Much luck.

  3. #3
    larry_d1990 is offline Member
    Join Date
    Jan 2011
    Posts
    11
    Rep Power
    0

    Default

    Sorry I've not been correct, it's a line graph and I have a constructor consisting of...

    {
    super(true);

    canvas = new JPanel(true);
    text = new JTextArea();
    canvas.setPreferredSize(new Dimension(500, 500));
    text.setPreferredSize(new Dimension(200, 500));
    canvas.setBorder(BorderFactory.createLineBorder(Co lor.black));
    text.setBorder(BorderFactory.createLineBorder(Colo r.black));

    add(canvas); add(stats);
    }

    and a paint method...

    {
    g.drawRect(50, 50, 400, 400);
    int xy = 70;
    for(int i = 0; i < 20; i++)
    {
    g.drawLine(xy, 50, xy, 450);
    g.drawLine(50, xy, 450, xy);
    xy+=20;
    }
    g.setColor(Color.red);
    g.drawLine(90, 50, 90, 450);
    }

    it also has a main method

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Again, I'm not sure what's going on based on the information provided. Again, please read the link about creating and posting an SSCCE (it's in my signature links below). Also please check the link on how to use code tags. Luck.

  5. #5
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Can you provide a couple screenshots? Like, one of the spec, and one of what you're getting and then explain the discrepancy?

Similar Threads

  1. JTextArea
    By PhQ in forum AWT / Swing
    Replies: 10
    Last Post: 03-28-2010, 07:17 PM
  2. JTextArea on PopUp -JTextArea isn't editable
    By Richy76 in forum AWT / Swing
    Replies: 3
    Last Post: 02-01-2010, 08:51 PM
  3. Tab key in JTextArea
    By KristoZ in forum New To Java
    Replies: 1
    Last Post: 09-25-2009, 08:27 PM
  4. About JTEXTAREA
    By makpandian in forum AWT / Swing
    Replies: 4
    Last Post: 03-19-2009, 07:53 AM
  5. JTextArea
    By saytri in forum New To Java
    Replies: 0
    Last Post: 01-13-2008, 02:07 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
  •