Look and Feel - mein 1. Versuch

Status
Nicht offen für weitere Antworten.

obiwan

Aktives Mitglied
Hallo,
ich versuche ein L&F ("Substance") einzubinden. Habe in Eclipse bereits über "Window-Preferences-Java-Classpath Variables" die "substance.jar" geadded.
Wenn ich das Programm laufen lasse kommt der Fehler "Substance not found" - also ein ClassNotFoundException.
Wie mache ich "org.jvnet.substance.SubstanceLookAndFeel" dem Programm bekannt?
Was muss ich wie adden, damit das L&F funktioniert?


Code:
package zwei;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class Walkthrough extends JFrame {
	  public Walkthrough() {
	    super("Sample app");
	    this.setLayout(new FlowLayout());
	    this.add(new JButton("button"));
	    this.add(new JCheckBox("check"));
	    this.add(new JLabel("label"));
	    
	    this.pack();
	    this.setSize(this.getPreferredSize());
	    this.setLocationRelativeTo(null);
	    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	  }
	  
	  public static void main(String[] args) {
		  try {
		      UIManager
		          .setLookAndFeel("org.jvnet.substance.SubstanceLookAndFeel");
		    } catch (UnsupportedLookAndFeelException ulafe) {
		      System.out.println("Substance failed to set");
		    } catch (ClassNotFoundException cnfe) {
		      System.out.println("Substance not found");
		    } catch (InstantiationException ie) {
		      System.out.println("Substance failed to instantiate");
		    } catch (IllegalAccessException iae) {
		      System.out.println("Access denied");
		    }

		    Walkthrough w = new Walkthrough();
		    w.setVisible(true);
		  } 
}
 
Versuch mal das package zu importieren:
Code:
import org.jvnet.substance.SubstanceLookAndFeel;
Und dann die UIManager#setLookAndFeel so aufrufen:
Code:
UIManager.setLookAndFeel(new SubstanceLookAndFeel());
 
import org.jvnet.substance.SubstanceLookAndFeel;

kennt er nicht, "The import org.jvnet cannot be resolved."

klappt leider nicht.
 
dann stimmt was mit deinem classpath nicht

zeig mal wie der genau aussieht
 
Das sind nur Variablen, die man benutzen könnte. Der Class-Path ist Projektabhängig, entsprechend muss das Zeugs über "Project > Properties" oder rechtsklick gesetzt werden. In dem Projektdialog unter "Java Build Path > Libraries" kann man dann Libraries eintragen, die dann dem Projekt bekannt sind.
 
Ich will das L&F auch. Jetzt die dümmste Frage wo kann ich das runterladen?? Finde es nicht.

Edit: Hat sich erledigt.
 
Status
Nicht offen für weitere Antworten.

Zurück
Oben