Zum Inhalt springen

frage zu object.setOpaque(boolean b)


Empfohlene Beiträge

Geschrieben

Also java.lang.Object.setOpaque(boolean B) bewirkt eigentlich nur eins: eine Compiler-Error - die gibt es nämlich nicht ;) .

Die Klasse java.awt.Component hat eine Methode isOpaque() die in der API folgendermaßen beschrieben ist:

isOpaque

public boolean isOpaque()Returns true if this component is completely opaque, returns false by default.

An opaque component paints every pixel within its rectangular region. A non-opaque component paints only some of its pixels, allowing the pixels underneath it to "show through". A component that does not fully paint its pixels therefore provides a degree of transparency. Only lightweight components can be transparent.

Subclasses that guarantee to always completely paint their contents should override this method and return true. All of the "heavyweight" AWT components are opaque.

Returns:

true if this component is completely opaque

Since:

1.2

Viele Subclasses von java.awt.Component bieten die Methode setOpaque(boolean), um diese Eigenschaft zu Manipulieren. Eine Subclass wäre zum Beispiel die javax.swing.JComponent deren Api Beschreibung so aussieht

setOpaque

public void setOpaque(boolean isOpaque)If true the component paints every pixel within its bounds. Otherwise, the component may not paint some or all of its pixels, allowing the underlying pixels to show through.

The default value of this property is false for JComponent. However, the default value for this property on most standard JComponent subclasses (such as JButton and JTree) is look-and-feel dependent.

Parameters:

isOpaque - true if this component should be opaque

Die gesamte Api-Dokumentation ALLER SUN-Java Klassen und deren Methoden findest du unter http://java.sun.com/j2se/1.4.1/docs/api/

Gruß

Mirko

Geschrieben

ok. Kurz gesagt: der Hintergrund schimmert durch, oder eben nicht.

Ausprobieren kannst du es zum Beispiel, in dem du mal zwei JLabels auf ein Panel setzt. Dem Panel gibst du irgendeine andere Hintergrundfarbe. Das eine Label setzt du setOpaque(true) und beim anderen setOpaque(false).

Gruß

Mirko

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...