Gostaria de saber se alguem sabe me dizer porque o Button não aparece no código abaixo.
[code]import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.*;
public class ReadServerFile extends JFrame
{
private JEditorPane contentsArea;
private JButton btn;
public ReadServerFile()
{
super( "Web Browser" );
btn = new JButton("Abrir Arquivo");
setVisible( true );
btn.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
getThePage( event.getActionCommand() );
}
}
);
contentsArea = new JEditorPane();
contentsArea.setEditable( false );
contentsArea.addHyperlinkListener(
new HyperlinkListener()
{
public void hyperlinkUpdate( HyperlinkEvent event )
{
if ( event.getEventType() ==
HyperlinkEvent.EventType.ACTIVATED )
getThePage( event.getURL().toString() );
}
}
);
add( new JScrollPane( contentsArea ), BorderLayout.CENTER );
setSize( 300, 400 );
setVisible( true );
}
private void getThePage( String location )
{
try
{
contentsArea.setPage( location );
}
catch ( IOException ioException )
{
JOptionPane.showMessageDialog( this,
"Caminho/URL não encontrado", "Caminho/URL nulo", JOptionPane.ERROR_MESSAGE );
}
}
}[/code]
Obrigado.