Olá !!! Eu já consegui abrir um link em java no navegador , porém eu queria que o link abrisse dentro de uma JPainel ou dentro do JFrame . Alguém sabe ???
webView.zip (928,Bytes)
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.border.BevelBorder;
import java.awt.Color;
import java.awt.Desktop;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.awt.event.ActionEvent;
public class WebView {
private JFrame frame;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
WebView window = new WebView();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public WebView() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 526, 422);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JPanel panel = new JPanel();
panel.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.BLUE, Color.YELLOW, Color.BLACK, Color.RED));
panel.setBounds(0, 0, 518, 345);
frame.getContentPane().add(panel);
JButton btnNewButton = new JButton("Abrir web");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
File link = new File("C:\\Users\\Adriano\\Desktop\\Gem Remoto\\Hinários\\hinário em mi.pdf");
Desktop.getDesktop().open(link);
} catch (Exception e2) {
// TODO: handle exception
}
}
});
btnNewButton.setBounds(175, 361, 125, 23);
frame.getContentPane().add(btnNewButton);
}
}