# Look&Feel-Wechsel bringt mein GUI durcheinander



## zubi (24. Jan 2004)

Hallo,

ich habe mit NetBeans ein kleines GUI für ein Adressbuch gestaltet inklusive einem Menü mit einer OptionGroup, mit welcher man das Look&Feel verändern kann. Zur Auswahl stehen Windows, Metall und Motif, wobei die ersten beiden keine grossen Veränderungen am GUI auslösen, Motif jedoch verzerrt die Sache ganz schön.

Das Seltsame dabei: wenn ich das Progi unter MacOSX laufen lasse, funktioniert der Wechsel einwandfrei  :shock: !

Hat jemand eine Idee an was das liegen könnte?

Herzlichen Dank & Gruss
zubi


----------



## bummerland (24. Jan 2004)

zeigst mal den code?


----------



## Guest (24. Jan 2004)

jo mach ich. der ist relativ lang, da er mit dem GUI-Editor erzeugt wurde.


```
private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        buttonGroup1 = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jPanel1 = new javax.swing.JPanel();
        strasseField = new javax.swing.JTextField();
        telField = new javax.swing.JTextField();
        nameField = new javax.swing.JTextField();
        ortField = new javax.swing.JTextField();
        mailField = new javax.swing.JTextField();
        plzField = new javax.swing.JTextField();
        vornameField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        addButton = new javax.swing.JButton();
        changeButton = new javax.swing.JButton();
        deleteButton = new javax.swing.JButton();
        clearButton = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        searchField = new javax.swing.JTextField();
        searchCombo = new javax.swing.JComboBox();
        searchButton = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        textPane = new javax.swing.JTextPane();
        printAllButton = new javax.swing.JButton();
        printSelButton = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        newMenu = new javax.swing.JMenuItem();
        delMenu = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        openMenu = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JSeparator();
        saveMenu = new javax.swing.JMenuItem();
        saveAsMenu = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JSeparator();
        quitMenu = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        radioWindows = new javax.swing.JRadioButtonMenuItem();
        radioMetallic = new javax.swing.JRadioButtonMenuItem();
        radioMotif = new javax.swing.JRadioButtonMenuItem();

        getContentPane().setLayout(new java.awt.GridBagLayout());

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        jList1.setFont(new java.awt.Font("Lucida Console", 1, 11));
        jList1.setPreferredSize(new java.awt.Dimension(160, 0));
        jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList1ValueChanged(evt);
            }
        });

        jScrollPane1.setViewportView(jList1);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridheight = 8;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(jScrollPane1, gridBagConstraints);

        jPanel1.setLayout(new java.awt.GridBagLayout());

        jPanel1.setBorder(new javax.swing.border.TitledBorder(null, "Erfassen", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Console", 0, 12)));
        strasseField.setFont(new java.awt.Font("Dialog", 0, 10));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(1, 2, 1, 1);
        jPanel1.add(strasseField, gridBagConstraints);

        telField.setFont(new java.awt.Font("Dialog", 0, 10));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(1, 2, 1, 1);
        jPanel1.add(telField, gridBagConstraints);

        nameField.setFont(new java.awt.Font("Dialog", 0, 10));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 120;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 0.5;
        gridBagConstraints.insets = new java.awt.Insets(1, 2, 1, 1);
        jPanel1.add(nameField, gridBagConstraints);

        ortField.setFont(new java.awt.Font("Dialog", 0, 10));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 100;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(1, 2, 1, 1);
        jPanel1.add(ortField, gridBagConstraints);

        mailField.setFont(new java.awt.Font("Dialog", 0, 10));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(1, 2, 1, 1);
        jPanel1.add(mailField, gridBagConstraints);

        plzField.setFont(new java.awt.Font("Dialog", 0, 10));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.ipadx = 60;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 2, 1, 1);
        jPanel1.add(plzField, gridBagConstraints);

        vornameField.setFont(new java.awt.Font("Dialog", 0, 10));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 100;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 0.5;
        gridBagConstraints.insets = new java.awt.Insets(1, 2, 1, 1);
        jPanel1.add(vornameField, gridBagConstraints);

        jLabel2.setFont(new java.awt.Font("Dialog", 0, 11));
        jLabel2.setText("Vorname");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 3, 1, 2);
        jPanel1.add(jLabel2, gridBagConstraints);

        jLabel3.setFont(new java.awt.Font("Dialog", 0, 11));
        jLabel3.setText("Strasse / Nr.");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 2);
        jPanel1.add(jLabel3, gridBagConstraints);

        jLabel4.setFont(new java.awt.Font("Dialog", 0, 11));
        jLabel4.setText("PLZ");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 2);
        jPanel1.add(jLabel4, gridBagConstraints);

        jLabel5.setFont(new java.awt.Font("Dialog", 0, 11));
        jLabel5.setText("Ort");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 3, 1, 2);
        jPanel1.add(jLabel5, gridBagConstraints);

        jLabel6.setFont(new java.awt.Font("Dialog", 0, 11));
        jLabel6.setText("Tel.");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 2);
        jPanel1.add(jLabel6, gridBagConstraints);

        jLabel1.setFont(new java.awt.Font("Dialog", 0, 11));
        jLabel1.setText("Name");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 2);
        jPanel1.add(jLabel1, gridBagConstraints);

        jLabel7.setFont(new java.awt.Font("Dialog", 0, 11));
        jLabel7.setText("eMail");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 2);
        jPanel1.add(jLabel7, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridheight = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(3, 1, 3, 5);
        getContentPane().add(jPanel1, gridBagConstraints);

        jPanel2.setLayout(new java.awt.GridBagLayout());

        addButton.setFont(new java.awt.Font("Lucida Console", 1, 10));
        addButton.setMnemonic('a');
        addButton.setText("add");
        addButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(1, 3, 1, 3);
        jPanel2.add(addButton, gridBagConstraints);

        changeButton.setFont(new java.awt.Font("Lucida Console", 1, 10));
        changeButton.setMnemonic('c');
        changeButton.setText("change");
        changeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                changeButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(1, 3, 1, 3);
        jPanel2.add(changeButton, gridBagConstraints);

        deleteButton.setFont(new java.awt.Font("Lucida Console", 1, 10));
        deleteButton.setMnemonic('d');
        deleteButton.setText("delete");
        deleteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(1, 3, 1, 3);
        jPanel2.add(deleteButton, gridBagConstraints);

        clearButton.setFont(new java.awt.Font("Lucida Console", 1, 10));
        clearButton.setMnemonic('l');
        clearButton.setText("clear");
        clearButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(1, 3, 1, 3);
        jPanel2.add(clearButton, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.insets = new java.awt.Insets(3, 1, 3, 5);
        getContentPane().add(jPanel2, gridBagConstraints);

        jPanel3.setLayout(new java.awt.GridBagLayout());

        jPanel3.setBorder(new javax.swing.border.TitledBorder(null, "Suchen", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Console", 0, 12)));
        jLabel8.setFont(new java.awt.Font("Dialog", 0, 11));
        jLabel8.setText("Begriff");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        jPanel3.add(jLabel8, gridBagConstraints);

        searchField.setFont(new java.awt.Font("Dialog", 0, 10));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 120;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 2);
        jPanel3.add(searchField, gridBagConstraints);

        searchCombo.setFont(new java.awt.Font("Dialog", 0, 10));
        searchCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Name", "Vorname", "Strasse", "PLZ", "Ort", "Telefon", "eMail" }));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 2);
        jPanel3.add(searchCombo, gridBagConstraints);

        searchButton.setFont(new java.awt.Font("Lucida Console", 1, 10));
        searchButton.setMnemonic('s');
        searchButton.setText("search");
        searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        jPanel3.add(searchButton, gridBagConstraints);

        jLabel9.setFont(new java.awt.Font("Dialog", 0, 11));
        jLabel9.setText("Eigenschaft");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel3.add(jLabel9, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(3, 1, 3, 5);
        getContentPane().add(jPanel3, gridBagConstraints);

        textPane.setEditable(false);
        textPane.setFont(new java.awt.Font("Lucida Console", 0, 10));
        textPane.setPreferredSize(new java.awt.Dimension(160, 17));
        textPane.setAutoscrolls(false);
        jScrollPane2.setViewportView(textPane);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.gridheight = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipady = 46;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(jScrollPane2, gridBagConstraints);

        printAllButton.setFont(new java.awt.Font("Lucida Console", 1, 10));
        printAllButton.setMnemonic('p');
        printAllButton.setText("print all");
        printAllButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                printAllButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 1, 1, 5);
        getContentPane().add(printAllButton, gridBagConstraints);

        printSelButton.setFont(new java.awt.Font("Lucida Console", 1, 10));
        printSelButton.setMnemonic('r');
        printSelButton.setText("print selection");
        printSelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                printSelButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 1, 1, 5);
        getContentPane().add(printSelButton, gridBagConstraints);

        jMenu1.setMnemonic('f');
        jMenu1.setText("File");
        jMenu1.setFont(new java.awt.Font("Lucida Console", 0, 10));
        newMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        newMenu.setFont(new java.awt.Font("Lucida Console", 0, 10));
        newMenu.setMnemonic('n');
        newMenu.setText("new AdressBook");
        newMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newMenuActionPerformed(evt);
            }
        });

        jMenu1.add(newMenu);

        delMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK));
        delMenu.setFont(new java.awt.Font("Lucida Console", 0, 10));
        delMenu.setMnemonic('d');
        delMenu.setText("delete AdressBook");
        delMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                delMenuActionPerformed(evt);
            }
        });

        jMenu1.add(delMenu);

        jMenu1.add(jSeparator1);

        openMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        openMenu.setFont(new java.awt.Font("Lucida Console", 0, 10));
        openMenu.setMnemonic('o');
        openMenu.setText("open");
        openMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openMenuActionPerformed(evt);
            }
        });

        jMenu1.add(openMenu);

        jMenu1.add(jSeparator2);

        saveMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        saveMenu.setFont(new java.awt.Font("Lucida Console", 0, 10));
        saveMenu.setMnemonic('s');
        saveMenu.setText("save");
        saveMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveMenuActionPerformed(evt);
            }
        });

        jMenu1.add(saveMenu);

        saveAsMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        saveAsMenu.setFont(new java.awt.Font("Lucida Console", 0, 10));
        saveAsMenu.setMnemonic('a');
        saveAsMenu.setText("save As");
        saveAsMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAsMenuActionPerformed(evt);
            }
        });

        jMenu1.add(saveAsMenu);

        jMenu1.add(jSeparator3);

        quitMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        quitMenu.setFont(new java.awt.Font("Lucida Console", 0, 10));
        quitMenu.setMnemonic('q');
        quitMenu.setText("quit");
        quitMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quitMenuActionPerformed(evt);
            }
        });

        jMenu1.add(quitMenu);

        jMenuBar1.add(jMenu1);

        jMenu2.setMnemonic('l');
        jMenu2.setText("Layout");
        jMenu2.setFont(new java.awt.Font("Lucida Console", 0, 10));
        radioWindows.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        radioWindows.setFont(new java.awt.Font("Lucida Console", 0, 10));
        radioWindows.setMnemonic('w');
        radioWindows.setText("Windows");
        buttonGroup1.add(radioWindows);
        radioWindows.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioWindowsActionPerformed(evt);
            }
        });

        jMenu2.add(radioWindows);

        radioMetallic.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        radioMetallic.setFont(new java.awt.Font("Lucida Console", 0, 10));
        radioMetallic.setMnemonic('e');
        radioMetallic.setText("Metallic");
        buttonGroup1.add(radioMetallic);
        radioMetallic.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioMetallicActionPerformed(evt);
            }
        });

        jMenu2.add(radioMetallic);

        radioMotif.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        radioMotif.setFont(new java.awt.Font("Lucida Console", 0, 10));
        radioMotif.setMnemonic('o');
        radioMotif.setText("Motif");
        buttonGroup1.add(radioMotif);
        radioMotif.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioMotifActionPerformed(evt);
            }
        });

        jMenu2.add(radioMotif);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        pack();
    }
```

ich kann sonst auch das file dranhängen.

gruss


----------



## bummerland (27. Jan 2004)

dann zeig mal den code für deine funktion radioMotifActionPerformed etc. :roll:


----------



## Stefan1200 (27. Jan 2004)

zubi hat gesagt.:
			
		

> Zur Auswahl stehen Windows, Metall und Motif, wobei die ersten beiden keine grossen Veränderungen am GUI auslösen, Motif jedoch verzerrt die Sache ganz schön.



Das Motif mehr platz braucht, ist mir auch bekannt. In diesem Fall hilft nur, die GUI so vergrößern, das alles gut ausschaut.

PS: Es gibt auch noch das Aqua LookAndFeel von Mac OS X.
Aqua steht natürlich nur unter MacOS X zur Verfügung, genauso wie Windows nur unter Windows zur Verfügung steht.
Das LookAndFeel heisst: apple.laf.AquaLookAndFeel


----------



## zubi (27. Jan 2004)

Die RadioButtonGroup besteht aus 3 Buttons, welche 0, 1 oder 2 an folgende Methode zum Layout-Wechsel übergibt:

```
public void setLayout(int layout) {
        try {
            switch(layout) {
                case 0: UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 
                        radioWindows.setSelected(true); break;
                case 1: UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                        radioMotif.setSelected(true); break;
                case 2: UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); 
                        radioMetallic.setSelected(true); break;
            }
            SwingUtilities.updateComponentTreeUI(this);
        }
        catch(ClassNotFoundException e) {
            JOptionPane.showMessageDialog(this, e.toString());
        }
        catch(InstantiationException e) {
            JOptionPane.showMessageDialog(this, e.toString());
        }
        catch(IllegalAccessException e) {
            JOptionPane.showMessageDialog(this, e.toString());
        }
        catch(UnsupportedLookAndFeelException e) {
            JOptionPane.showMessageDialog(this, e.toString());
        }
    }
```

Wenn ich noch "pack();" hinzufüge, dann werden die Buttons und Fields gut dargestellt, jedoch wird dann die jList "zerdrückt". Damit ihr euch ein Bild davon machen könnt, hier ein Screen:






Wenn ich die Breite des Frames verkleinere (wenn das Programm ausgeführt wird), dann "springt"  ab einem gewissen Punkt die Breite der Liste und wird nicht in einem fliessenden Übergang schmaler.

gruss,
zubi


----------

