• Post Reply Bookmark Topic Watch Topic
  • New Topic

Create a scrollable HTML Pane

 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to create a scrollable pane that will display an HTML document and I do not understand how to approach this. From my research it seems like I need to use a rather convoluted process:

Create JTextPane
Create HTMLDocument
Create JScrollPane
Use JTextPane in an HTMLDocument/EditorKit
Insert HTML string into EditorKit
Add JTextPane to JScrollPane
Add JScrollPane to JOPtionPane.showMessageDialog

Is it really that convoluted or is there a simpler way to do this? If this is the correct way, which one of these components controls the size of the JOptionPane? TIA.
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the Swing tutorial on Using Text Components for a working example.

You have been given links to the tutorial in past questions.

The tutorial can also be used as a reference for future questions. Keep a link to the tutorial handy for Swing basics.
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for being dense but I have yet to find a single one of those tutorials that helped me with what I need to accomplish. That is where I go first and if it were that easy to apply them I would not be asking here. Perhaps part of the problem is that I don't really know what I'm looking for. The learning curve is extremely steep and I still pretty close to the bottom. I know helping noobs can sometimes be a PITA but please don't automatically assume I have not looked that the tutorials. Rather assume I have and was unable to understand how to apply them to my situation.
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tutorials that helped me with what I need to accomplish.


Rarely will you find a tutorial that does 100% of what you need to do. The point of the tutorial is to get you started with the basics.

The tutorial has working code.

I have no idea what you find complex about working code.

How do you expect us to guess what you find confusing about working code.

I have never seen any suggestions on the forum doing what you are suggesting so I have no idea where you came up with that approach. It certainly did not come from the tutorial. So all I can assume is that you have not read the tutorial, which is why I pointed you to the tutorial.

If you had read the tutorial then you would have posted a question asking how the code from the tutorial works.

 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are making this question more complex than I intended. If you re-read the original post the answer should be quite simple. Either I have the right approach or I don't. If I do then I can proceed on my own. If I don't then I can do further research but I don't want to waste my time going down the wrong road.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dennis Putnam wrote:I need to create a scrollable pane that will display an HTML document and I do not understand how to approach this. From my research it seems like I need to use a rather convoluted process:

Is it really that convoluted or is there a simpler way to do this? If this is the correct way, which one of these components controls the size of the JOptionPane? TIA.


Pick a proper component for your requirement. Details available in the link Rob posted. For simple HTML rendering I suggest JEditorPane
Create JEditorPane instance
Wrap it inside JScrollPane instance
Create JPanel. Set layout to BorderLayout
Add JScrollPane to panel
Set the panel as the JOptionPane 'message'
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what I was looking for. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!