开发者

Creating another window for just displaying text + swing

I currently have a window frame with panels inside and am using it to run my program. Now I am in a need to display text along with running of the code side by side.

The problem with displaying it in the same win开发者_StackOverflowdow is that it minimizes the total screen area which I am using for input handling.

Thus I decided to create a dialog box and dump all the text inside.

This proved to be a bad decision as sometimes the output is really large and dialog boxes do not contain the scroll bar.

Can anyone tell me what's the best way to proceed?

I just want suggestions to what should I try and do not need any code part for it as I would like to do that on my own :)


  • Create a new JWindow (or JFrame, one tutorial here: http://download.oracle.com/javase/tutorial/uiswing/components/frame.html)
  • Inside of it, create a new JTextArea and dump all your text there
  • to get the scrolling, create a new JScrollPane around your JTextArea. Tutorial: http://download.oracle.com/javase/tutorial/uiswing/components/scrollpane.html


You should follow tradition and use either:

  • One JFrame that will host your application and open any number of JDialogs your for your scrolling text etc.

or

  • One JFrame with any number of JInternalPanes.

JFrame is a top-level container and every application should have only one. You do not loose any functionality this way, and you stick with the standards, which will definitely make somebody's life easier in the future. Maybe your's.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜