Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

JEditorPane

Empfohlene Antworten

Veröffentlicht

Ich habe ein kleines Problem mit der Einarbeitung in Swing, genauer, mit der Klasse JEditorPane: Ich möchte dass nachfolgendes Programm die Seite von Yahoo öffnet:

public class test {

static void main(String[] args) {

HTMLEditorKit kit = new HTMLEditorKit();

HTMLDocument d = new HTMLDocument();

try

{

URL url = new URL("http://de.yahoo.com/");

JEditorPane editor = new JEditorPane();

editor.setContentType("text/html");

editor.setEditorKit(kit);

editor.setDocument(d);

editor.setPage(url);

editor.setVisible(true);

}

catch(IOException e)

{

System.out.println("error");

}

}

}

Es wird aber nichts ausgegeben. Kann mir jemand sagen warum, und was ich ändern muss.

die main methode ist dabei natürlich public... fehler beim copy/paste :">

Du musst dein JEditorPane in ein Fenster einbauen, sonst geht es nicht^^

Ansonsten hilft Google oft weiter ;)

Ich hab zwar noch nie damit gearbeitet, hab aber auf die schnelle mal folgendes gemacht:

import java.awt.*;

import javax.swing.*;

import java.io.*;


public class test extends JFrame{

	test(String titel){

		super(titel);


		try{

		String url = "http://www.google.de/";

  		JEditorPane htmlPane = new JEditorPane(url);

  		htmlPane.setEditable(false);

  		add(new JScrollPane(htmlPane));

  		}

  		catch (IOException e){ System.out.println(e);}


  		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

	}

public static void main(String[] args) {

	test win = new test("JEditorPane Test");


	Dimension windowSize = Toolkit.getDefaultToolkit().getScreenSize();

	int breite = (windowSize.width);

	int hoehe = (windowSize.height);


	win.setSize(breite,hoehe);

	win.setLocation(0,0);

	win.setVisible(true);

	}

}

Zeigt die Website an, aber nich so wirklich, wie man es haben will. Aber ich denke, das sollte für den Anfang reichen^^

Gruß

Raphael

Vielen Dank! Ich werds ausprobieren!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.