• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTextPane going wild, need help

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working with Java and Swing for the last couple of months and I never encountered anything like this, maybe someone around here can help me.
I'm creating an AI system for data analysis, nothing 2big but as a nice little project. Atm I'm building a UI for testing / control purposes and I've ran into a problem I can't seem to solve.

In short I got a JMenuBar, JPanel, JTextPane, JTextArea, JLabel & JButton in my frame. The problem is happening when I'm making an input to my JTextArea, like this:

A user makes input to JTextArea and clicks a button, that text is then appended to JTextPane and JTextPane is repainted. JTextPane is within JScrollBar which is within JPanel here's the code for those:


And here's the code for JTextArea which I use for input (button aswell)


This is how it looks:



Now that you know how it looks & works here's the problem:
After I fill up my JTextPane (outputPane) and when the scrollBar shows up it starts, after that whenever I type a character (any character)
in my inputArea (Jtextarea), my outputPane automaticly resizes so I can see all the text and by doing that makes my
upper panel smaller, on second character input it goes back to normal tho...

I get the scrollBar to show like this:


Then I input a character in my TestArea and this happens:


After I input another character this happens:


And after I click send (button):


I never had any issues using Swing OR JTextArea, it is however my first time working with JTextPane so I might be unaware of some mechanics.
Would appriciate any help in resolving this issue.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd experiment with GridBagLayout instead of BorderLayout. Scroll panels can be tricky when they need to be resized, and I've always found that GridBagLayout prevents the kind of things from happening that you're seeing.
 
Ante Adamovic
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I managed to solve the issue by using JTextField instead of JTextArea for input, but still have no idea why it was behaving so weirdly...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic