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.

drawString() und html???

Empfohlene Antworten

Veröffentlicht

kann ich mit drawString() html-code ausgeben?


public void paint(Graphics g)

{

     String html = "<html><b>ueberschrift</b><br>bla bla blahtml>";

     g.drawString(html,100,100);

}


kann ich das mit einer anderen classe?

gruss und danke,

Da brauchst JEditorPane oder JTextPane. Bei deiner Lösung wird der HTML-Text mitausgegeben.

kurz, bündig, richtig!

vielen Dank, hat mir geholfen.

noch Nachtrag:

wie kann ich editor (JTextField Komponente) jetzt zeichnen?

Quelltext myTest.java


import java.awt.BorderLayout;

import java.awt.Component;

import java.awt.Container;

import java.awt.Graphics;


import javax.swing.JEditorPane;

import javax.swing.JFrame;

import javax.swing.JPanel;


import src.FileAction;



public class myTest extends JPanel

{

	public void paint(Graphics g)

	{

		paintHead(g, 50,50);

	}


	private void paintHead(Graphics g, int x, int y)

	{


	    // String s mit HTML

		String s = "<html><b>Test</b></html>";


	    //Instanzieren eines JEditorPane

	    //Übergabe des HTML-Codes aus s

		JEditorPane editor = new JEditorPane();

		editor.setSize(200,200);

		editor.setContentType("text/html");

		editor.setText(s);

	    //---------------------------------

	    //wie kann ich editor jetzt Zeichnen???

	    //---------------------------------

	}

	public static void main(String[] args)

	{

		JFrame frame = new JFrame();

		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);


		Container contentPane = frame.getContentPane();


		Component printIt = new myTest();

		contentPane.add(printIt, BorderLayout.CENTER);

		frame.setSize(200,200);

		frame.show();

	}

}

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.