two Java GUI problems - please help

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2004
Posts: 55
Reputation: apcxpc is an unknown quantity at this point 
Solved Threads: 0
apcxpc's Avatar
apcxpc apcxpc is offline Offline
Junior Poster in Training

two Java GUI problems - please help

 
0
  #1
May 2nd, 2005
Hi all

I've programmed a relay chat system in Java. Just having two GUI-related problems with the chat client itself.

Problem #1 : I can't get the chat windows to scroll as new text appears in them. The scroll bar does appear when it needs to, but it remains at the top of the box (but grows smaller as more text is appended) ...so the newly appended text is hidden unless you scroll the scrollbar further down yourself.
This is what I'm doing:
I have a JTextArea for the text, then I have a JScrollPane to which I've added the JTextArea.
Then I've added the JScrollPane to (the contentPane of) the JFrame.
I have the vertical-scroll-bar policy of the JScrollPane set to ALWAYS.
I've also set the viewport of the JScrollPane to my JTextArea.

How do I get the scrollbar scrolling to keep up with text being added to the chat window?



Problem #2
I'm using JFrames for the chat client windows. I want to prevent the chat client user from re-sizing the windows. How do I do this??
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 192
Reputation: stupidenator is an unknown quantity at this point 
Solved Threads: 4
stupidenator's Avatar
stupidenator stupidenator is offline Offline
Junior Poster

Re: two Java GUI problems - please help

 
0
  #2
May 2nd, 2005
I'm not sure about your first problem, I've been wondering that myself. But I do know how to solve your resizing problem...

I think that you just want to use this:

JFramename.setResizable(false);

-Nick Nisi
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: two Java GUI problems - please help

 
0
  #3
May 2nd, 2005
use javax.swing.JScrollPane and then just add your text area to this
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 55
Reputation: apcxpc is an unknown quantity at this point 
Solved Threads: 0
apcxpc's Avatar
apcxpc apcxpc is offline Offline
Junior Poster in Training

Re: two Java GUI problems - please help

 
0
  #4
May 3rd, 2005
stupidenator: Thanks for that! I searched the JFrame API for the word 'resize' and nothing came up, so I was at a loss. :cheesy:

paradox814: I did that, as I've mentioned up there. It just didn't work.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: two Java GUI problems - please help

 
0
  #5
May 3rd, 2005
remember that JFrame is derived from Frame which derives from Component (or something like that), many core methods are inherited from a parent class.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 55
Reputation: apcxpc is an unknown quantity at this point 
Solved Threads: 0
apcxpc's Avatar
apcxpc apcxpc is offline Offline
Junior Poster in Training

Re: two Java GUI problems - please help

 
0
  #6
May 3rd, 2005
yep. Thanks jtwenting. Remember you helped test my chat system? ... :cheesy:

Any idea on the scrollable chat windows? A chat client with non-scrollable windows is... pretty much a disaster.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 25
Reputation: Black Knight is an unknown quantity at this point 
Solved Threads: 0
Black Knight's Avatar
Black Knight Black Knight is offline Offline
Light Poster

Re: two Java GUI problems - please help

 
0
  #7
May 3rd, 2005
I had exaclty the same problem when i made a chat system for uni using a JEditorPane in a scroll window, its one of those problems which is really annoying. Im not sure if I actually fixed it but i know you can do it as some of the other students ones worked (but a lot didnt). Have you tried anchoring it to the bottom of the scroll pane or something similar, might have something to do with setEditable aswell. if the text area is editable it might not scrol properly, it may work correctly if it isnt editable, just a few ideas.
01001001011001100010000001111001011011110111010100100000011000110110000101101110
00100000011100100110010101100001011001000010000001110100011010000110100101110011
00100000011110010110111101110101001000000110111001100101011001010110010000100000
0110100001100101011011000111000000101110
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 27
Reputation: DeepZ is an unknown quantity at this point 
Solved Threads: 0
DeepZ's Avatar
DeepZ DeepZ is offline Offline
Light Poster

Re: two Java GUI problems - please help

 
0
  #8
May 3rd, 2005
From the top of my head, you should set the caret position after you update the text :
jta.append("Some text!");
jta.setCaretPosition(jta.getText().length()); Have fun.
:?: Sometimes i wonder if i'm on the right planet :!:
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 25
Reputation: Black Knight is an unknown quantity at this point 
Solved Threads: 0
Black Knight's Avatar
Black Knight Black Knight is offline Offline
Light Poster

Re: two Java GUI problems - please help

 
0
  #9
May 3rd, 2005
I remember trying that in the app i wrote, i dont think it will work, as the caret position can be on the text area but not necessarily in the view. If it does work it would be interesting to know fo rthe future.
01001001011001100010000001111001011011110111010100100000011000110110000101101110
00100000011100100110010101100001011001000010000001110100011010000110100101110011
00100000011110010110111101110101001000000110111001100101011001010110010000100000
0110100001100101011011000111000000101110
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: two Java GUI problems - please help

 
0
  #10
May 3rd, 2005
JScrollPane is your friend
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 5772 | Replies: 15
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC