Syntehetica - LAF

Spin

Top Contributor
Java:
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

/**
 * The main class of the application.
 */
public class CockApp extends SingleFrameApplication {

    /**
     * At startup create and show the main frame of the application.
     */
    @Override protected void startup() {
        try {
            show(new CockView(this));
        } catch (SQLException ex) {
            Logger.getLogger(CockApp.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(CockApp.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override protected void configureWindow(java.awt.Window root) {
    }

    /**
     * A convenient static getter for the application instance.
     * @return the instance of CockApp
     */
    public static CockApp getApplication() {
        return Application.getInstance(CockApp.class);
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {
        launch(CockApp.class, args);
    }
}



Hallo leute ich habe diesen Code gefunden um meiner Anwendung ein anderes Design zu geben .
Gibt es noch eine Kürzere varainte als diese?

Und zum anderen möchte ich mein View nicht von FrameView ableiten sondern von JFrame.
Hat jemand dazu einen Code?

Ich will einfach nur dem Swing Layout ein anderes Design verpassen, danke grüße
 
Zuletzt bearbeitet:

Spin

Top Contributor
Ja , das Look & Feel ist ganz nett , aber sieht doch auch nicht schick aus.
Damit habe ich schon oft was gemacht , wollte diesmal jDestkop verwenden , aber dann darf ich wohl nicht mehr JFrame benutzen , weil das swing angehört :/

Dann sind die methoden , setsize , setLocation , setDefaultClose..

alle nicht mehr vorhanden .
Vielleicht weiß ja einer wie ich jDestkop am besten benutze .
 

Spin

Top Contributor
Java:
 public CView() {
        super("Cocktail-Application");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(600, 550);
        this.setLocation((int) d.getWidth() / 2 - 350, (int) d.getHeight() / 2 - 350);
        this.initComponents();
        this.settings();

        try {
            UIManager.setLookAndFeel(new SyntheticaStandardLookAndFeel());
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.setVisible(true);


    }


Mh , das Layout will sich aber nich ändern. Was muss ich denn jetzt machen?
 

U2nt

Bekanntes Mitglied
Also

Java:
import javax.swing.*;
import javax.swing.plaf.synth.SynthLookAndFeel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Klasse extends JFrame {
	
	private JButton button;
	
	public Klasse() {
		        super("Cocktail-Application");
		        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		        setSize(600, 550);
		        setLocationRelativeTo(null);
		        try {
		            UIManager.setLookAndFeel(new SynthLookAndFeel());
		        } catch (Exception e) {
		            e.printStackTrace();
		        }		
		        
		        button = new JButton("the button");
		        button.addActionListener(
		        		new ActionListener() {

							@Override
							public void actionPerformed(ActionEvent arg0) {
								JOptionPane.showMessageDialog(null, "you clicked the button");
								
							}
		        			
		        		}
		        );
		        add(button);        
		        
	}
	
	
	public static void main(String[] args) {
		Klasse k = new Klasse();
		k.setVisible(true);
	}
	
}

So ändert er bei mir das LAF doch habe den Code eben gerade von dir genomme und leicht modifiziert... Naja aufjedenfall ergab das bei mir ein kleines Einrückterror! Wenn er hier das LAF bei dir nicht ändert weiss ich auch nicht weiter - bei mir gehts.
 

Spin

Top Contributor
Mhh , ne habe es jetzt so gemacht :

Java:
 try {
            UIManager.setLookAndFeel(new SyntheticaStandardLookAndFeel());
        } catch (Exception e) {
            e.printStackTrace();
        }
        for (int i = 0; i < this.getComponentCount(); i++) {
        SwingUtilities.updateComponentTreeUI(this.getComponent(i));

        this.setVisible(true);


Damit erreiche ich alle Komponenten , whärend der Laufzeit.
Interessant wäre , wie ich das vor dem Kompilieren einstellen könnte.
danke grüße
 

U2nt

Bekanntes Mitglied
Naja daran sieht man wieder das ich mich mit LAF nicht gut auskenne :)
Also funktionierts nun und is erledigt?
 

Spin

Top Contributor
jepp ;)

Alles schick , naja paar sachen sind noch zu klären , warum gewisse Textfelder einen Hintergrund haben und manche nicht. Aber das Pferd bekomme ich geschaukelt ;)

grüße
 

Oben