Hola chicos, soy super novato en java, entonces quería si podría mostrar una pagina web especifica en una ventana.
por ejemplo, al momento de abrir la aplicación, se abra una ventana que muestre la web.
por favor no me reten.
mmm veamos Almacenemos el Contenido del Sitio en una String, usemos un JEditorPane, un scroll y creemos un Jframe
Primero almacenamos la info de la url en un String:
String pagina = "http://www.google.com.mx";
Creemos un Jeditor y metemos en el el String de la url:
JEditorPane pane = new JEditorPane(pagina);
Creamos un ScrollPane para poder Visualizar la pagina entera y le metemos el JeditorPane:
JScrollPane scroll = new JScrollPane(pane);
Creamos un Jframe y ponemos un titulo:
JFrame frame = new JFrame("Pagina");
bien y este es el Resultado Final
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
/**
*
* @author Slider324
*/
public class Prueba {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
String pagina = "http://www.google.com.mx";
JEditorPane pane = new JEditorPane(pagina);
JScrollPane scroll = new JScrollPane(pane);
//Creamos Un Frame
JFrame frame = new JFrame("Pagina");
//Agregamos a Frame el scroll ya que contiene la info
frame.getContentPane().add(scroll);
//Hacemos Visible, definimos Cerrar y tamaño
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 600);
frame.setVisible(true);
}
}
No se si te refieres a abrirla dentro de tu propia interfaz (cosa que ya te han contestado), yo te explicaré como abrirla con el navegador predetermindo:
String url = new String();
url = "www.google.es";
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " +"http://"+url);
Saludos