I'm working on a game that has a chatbox in it, but despite looking into it, (I might not be searching for the right thing), I can't figure out the best way to create a custom 'scroll pane' for a 'textbox' draw on the graphics. This horrible paint representation kind of shows what I'm trying to accomplish:
If I can give anymore information on this, please ask. This is the best way I could figure out how to explain it.
Edit: OK, so to give more info on this, the JPanel the game uses to display the game. It's done via overriding PaintComponent in the JPanel. I'm not sure if it's possible to add a new component to draw this with. If it is, then that might work. I just need to be able to position it in a specific spot. If adding a new component to this would work, then that would work and I feel like an idiot.
Option 1) Use a JTextArea held in a JScrollPane. Option 2) Use a JList held in a JScrollPane. The JTextArea is a little simpler, but the JList works better and is more responsive if it needs to hold a lot of data. The tutorials can be found here:
Note that this question could have been very quickly answered by you after a quick scan of the Swing Tutorials, and so for future reference, I've included a link to them.
Edit
Please consider these options for possibly a better solution:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.