Article View: borland.public.jbuilder.java.swing
Article #11178JEditorPane woes. Help please.
From: Steve Cannon
Date: Mon, 05 Jul 1999 00:00
Date: Mon, 05 Jul 1999 00:00
110 lines
3206 bytes
3206 bytes
I can't seem to get the code below to display the html file in the
JEditorPane. The TipsWindow class is being instantiated from a button click
and the JButton is inside an app that is inherited from a JFrame.
Can anyone spot any problems?
Thanks.
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.net.URL;
import java.io.IOException;
////////////////////////////////////////////////////////////////////////////
////
/**
*
*/
public class TipsWindow extends JPopupMenu
{
private JEditorPane jEditorPane = new JEditorPane();
private JScrollPane scrollPane = new JScrollPane( jEditorPane );
////////////////////////////////////////////////////////////////////////////
/
/**
*
*/
public TipsWindow()
{
try
{
init();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
////////////////////////////////////////////////////////////////////////////
/
/**
*
*/
private void init() throws Exception
{
scrollPane.setPreferredSize(new Dimension(140, 140));
scrollPane.setMinimumSize(new Dimension(140, 140));
file://scrollPane.setViewportView( jEditorPane );
jEditorPane.setBackground(new java.awt.Color(255, 255, 135));
jEditorPane.setBorder(BorderFactory.createLineBorder(Color.black));
jEditorPane.setContentType("text/html");
file://jEditorPane.setContentType("text/plain");
jEditorPane.setText( "<u>JEditorPane Test</u>" );
jEditorPane.setPreferredSize(new Dimension(140, 140));
jEditorPane.setMinimumSize(new Dimension(140, 140));
jEditorPane.setEditable(false);
jEditorPane.addHyperlinkListener( new HyperlinkListener()
{
public void hyperlinkUpdate( HyperlinkEvent e )
{
try
{
jEditorPane.setPage( e.getURL() );
}
catch( IOException ioe )
{
ioe.printStackTrace();
}
}
});
add( scrollPane );
file://add( new JLabel( "***** Test label *****" ) );
file://setLocation( 200, 300 );
pack();
file://setVisible(true);
}
////////////////////////////////////////////////////////////////////////////
/
/**
*
*/
public void setPage( String sPage ) throws IOException
{
jEditorPane.setPage( sPage );
}
////////////////////////////////////////////////////////////////////////////
/
/**
*
*/
public void setPage( URL url ) throws IOException
{
jEditorPane.setPage( url );
}
}
Technical Details
Message-ID:
<7lqo0h$agd6@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,be10a334df544f85,start X-Google-Attributes: gid111d45,public From: "Steve Cannon" <scannon@austin.rr.com> Subject: JEditorPane woes. Help please. Date: 1999/07/05 Message-ID: <7lqo0h$agd6@forums.borland.com> X-Deja-AN: 497422056 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.swing