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.

LookAndFeel interesse

Empfohlene Antworten

Veröffentlicht

Hey Leute,

ich möchte gerne etwas über LookAndFeel's lernen und habe mir daher das L&F "Metal" aus der src.zip geholt und möchte daran lernen wie man diese ändern kann. Leider habe ich das Problem, dass ich nicht weiss, wie ich das geänderte L&F verwende und teste, was sich geändert hat.

Ich habe dem L&F "Metal" einen neuen Namen gegeben und natürlich in den Dateien auch "package" geändert.

Nun habe ich die Struktur "package de.mindquery.wood_ui.wood;"(sie liegen auch auf meinem Desktop in den Ordner "de.mindquery etc").

Ich erzeuge also in einem neuen Projekt ein JFrame, welches über

    private void switchLookAndFeel(Container f) {

        try {

            UIManager.setLookAndFeel("de.mindquery.wood_ui.wood");

        } catch (UnsupportedLookAndFeelException | IllegalAccessException | InstantiationException | ClassNotFoundException ex) {

            ex.printStackTrace(System.out);

        }

        SwingUtilities.updateComponentTreeUI(f);

    }
sein L&F wechseln soll. Ich habe keine Ahnung wie ich "MEIN" L&F implementieren muss, damit nicht folgenden Fehler erscheint:


java.lang.ClassNotFoundException: de.mindquery.wood_ui.wood

	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

	at java.security.AccessController.doPrivileged(Native Method)

	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

	at java.lang.ClassLoader.loadClass(ClassLoader.java:423)

	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

	at java.lang.Class.forName0(Native Method)

	at java.lang.Class.forName(Class.java:266)

	at javax.swing.SwingUtilities.loadSystemClass(SwingUtilities.java:1874)

	at javax.swing.UIManager.setLookAndFeel(UIManager.java:579)

	at musicbox_layout.NewJFrame.switchLookAndFeel(NewJFrame.java:80)

	at musicbox_layout.NewJFrame.jButton1ActionPerformed(NewJFrame.java:87)

	at musicbox_layout.NewJFrame.access$000(NewJFrame.java:17)

	at musicbox_layout.NewJFrame$1.actionPerformed(NewJFrame.java:44)

	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)

	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)

	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)

	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)

	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)

	at java.awt.Component.processMouseEvent(Component.java:6505)

	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)

	at java.awt.Component.processEvent(Component.java:6270)

	at java.awt.Container.processEvent(Container.java:2229)

	at java.awt.Component.dispatchEventImpl(Component.java:4861)

	at java.awt.Container.dispatchEventImpl(Container.java:2287)

	at java.awt.Component.dispatchEvent(Component.java:4687)

	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)

	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)

	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)

	at java.awt.Container.dispatchEventImpl(Container.java:2273)

	at java.awt.Window.dispatchEventImpl(Window.java:2719)

	at java.awt.Component.dispatchEvent(Component.java:4687)

	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)

	at java.awt.EventQueue.access$200(EventQueue.java:103)

	at java.awt.EventQueue$3.run(EventQueue.java:688)

	at java.awt.EventQueue$3.run(EventQueue.java:686)

	at java.security.AccessController.doPrivileged(Native Method)

	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)

	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)

	at java.awt.EventQueue$4.run(EventQueue.java:702)

	at java.awt.EventQueue$4.run(EventQueue.java:700)

	at java.security.AccessController.doPrivileged(Native Method)

	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)

	at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)

	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)

	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)

	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)

	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)

	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Ich habe bereits versucht mein L&F in einem neuen Projekt zu packen, dies dann zu kompilieren und die erzeugte wood.jar als lib einzubinden... geht leider auch nicht.

ich nehme an, es ist nicht weiter schwer, aber ich komme einfach nicht dahinter.

ich hoffe ihr könnt mir helfen.

Mit besten Grüßen

Sring

Na im Stacktrace steht doch der Fehler schon drin. Es wird deine Klasse de.mindquery.wood_ui.wood nicht gefunden. Also musst du dir mal deinen classpath anschauen ob da eine passende Klasse zu finden ist. Ich vermute mal das du einfach vergessen hast deine Klasse überhaupt anzugeben. Denn das was du dem UIManager übergibst schaut für mich nach einem Package aus und nicht nach eine Klasse.

Wo willst du deine Klasse denn hin übergeben? Wenn du eine Frage hast solltest du sie so genau wie möglich stellen und auch den Problem so genau wie möglich beschreiben. Bisher habe ich bei dir sehr viel raten müssen was du eigentlich meinst.

Ich vermute aber mal das du wissen willst wie du dem UIManager deine Klasse übergibst.


//Alternative 1: wird erst zur Laufzeit ausgewertet

UIManager.setLookAndFeel("mein.super.tolles.package.MeineKlasse");


//Alternative 2: wird bereits zur compilezeit ausgewertet

UIManager.setLookAndFeel(MeineKlasse.class.getCanonicalName());

Alternative 2 hat den Nachteil das du eine compile Abhängigkeit zu deinem LookAndFeel erzeugst. Welche unter umständen nicht gewünscht ist. Sollte aber für deine Spielereien jetzt erstmal egal sein.

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.