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.

Image auf ein JPanel knallen

Empfohlene Antworten

Veröffentlicht

Hallo Zusammen,

kann mir jemand sagen wie ich ein Image

auf ein JPanel knallen kann?

weiß leider nicht mehr weiter.

danke schon im vorraus.

gruß

forrester

danke habs schon selber gefunden.

mercn.

ehre

forrester

Hallo...

und, wie gehts?

Würd mich auch interessieren :-)

Grüße

  • 3 Wochen später...

Hi

Hier habt Ihr den fertigen Quellcode für ein JPanel welches ein Image darstellt. Einfach im Construktor den Pfad des Images angeben und das neue Objekt anzeigen lassen.


import javax.swing.*;

import java.awt.*;

import java.util.*;


/**

 * Mit Hilfe diesen Panels ist es möglich, ein Image anzuzeigen

 * Creation date: (14.07.2001 11:14:47)

 * @author: Thomas Schiffler

 */


public class ImagePanel extends javax.swing.JPanel {

	private String pfadOfImage = null;

	private Image image = null;

/**

 * ImagePanel Construktor. Es wird der Pfad des Images, welches angezeigt werden soll

 * benötigt

 */

public ImagePanel(String imagePfad) {

	super();


	pfadOfImage = imagePfad;


	image = Toolkit.getDefaultToolkit().createImage(pfadOfImage);

}

public int getImageHeight() {

	return image.getHeight(this);

}

public int getImageWidth() {

	return image.getWidth(this);

}

/**

 * Zeichnet das Image

 */


public void paintComponent(Graphics g) {

	super.paintComponent(g);

	g.drawImage(

		image, 

		new Double(g.getClipBounds().getCenterX() - (image.getWidth(this) / 2))

			.intValue(), 

		new Double(g.getClipBounds().getCenterY() - (image.getHeight(this) / 2))

			.intValue(), 

		this); 

}

}

Gruß Erbeere

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.