| | |
two Java GUI problems - please help
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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??
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??
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:
-Nick Nisi
I think that you just want to use this:
JFramename.setResizable(false);-Nick Nisi
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
00100000011100100110010101100001011001000010000001110100011010000110100101110011
00100000011110010110111101110101001000000110111001100101011001010110010000100000
0110100001100101011011000111000000101110
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
00100000011100100110010101100001011001000010000001110100011010000110100101110011
00100000011110010110111101110101001000000110111001100101011001010110010000100000
0110100001100101011011000111000000101110
![]() |
Similar Threads
- Java / GUI Developer Needed (UK) (Software Development Job Offers)
- [J]TextArea problems in SuSE 10.1 (Java)
- java gui libraries (Java)
Other Threads in the Java Forum
- Previous Thread: i need help with arrays
- Next Thread: methods
Views: 5772 | Replies: 15
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application apps arguments array arrays automation binary bluetooth businessintelligence card chat class classes client code collision component crashcourse database detection draw eclipse error event exception file fractal free game gis givemetehcodez graphics gui helpwithhomework html ide image input integer integration j2me java javadoc javafx javaprojects jmf jni jpanel julia jvm linux list loop machine map method methods migrate mobile netbeans newbie nls number object oracle os physics print problem program programming project radio recursion remote scanner screen security server set size sms socket sort sql string swing test textfield threads time transfer tree trolltech utility windows






