Błąd przy zmianie stylu aplikacji okienkowej

Odpowiedz Nowy wątek
2015-01-22 12:55
0

Hej!

Słuchajcie... Tworzę sobie podstawowe aplikacje okienkowe wedle tutorial'u znaleźnego na YT i mam pewien problem ze zmianą stylu aplikacji. Wprawdzie styl się zmienia, ale tylko za pierwszym wyborem po czym na konsoli rzyga stack overflow ----> http://4programmers.net/Pastebin/3772.

Tworzę aplikację w GUI builderze netbeansa

Bardzo bym prosił o pomoc. action dla zmiany stylu pod mMetal, mNimbus, mWindows. Oto kod:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package menutestowe;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Box;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author jarek
 */
public class NewJFrame extends javax.swing.JFrame {
    String wybranyTekst;
    PanelHasla panelHasla = null;

    public NewJFrame() {
        initComponents();
        setResizable(false);
        setLocation(500, 200);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        mKopiuj = new javax.swing.JMenuItem();
        mWklej = new javax.swing.JMenuItem();
        mDolacz = new javax.swing.JMenuItem();
        jScrollPane1 = new javax.swing.JScrollPane();
        notatnik = new javax.swing.JTextArea();
        bSzukaj = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        tSzukany = new javax.swing.JTextArea();
        colorCombo = new javax.swing.JComboBox();
        mKolor = new javax.swing.JButton();
        pHaslo = new javax.swing.JPasswordField();
        bZaloguj = new javax.swing.JButton();
        jSlider1 = new javax.swing.JSlider();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuPlik = new javax.swing.JMenu();
        mOtworz = new javax.swing.JMenuItem();
        mZapisz = new javax.swing.JMenuItem();
        mWyjscie = new javax.swing.JMenuItem();
        menuOpcje = new javax.swing.JMenu();
        mNarz1 = new javax.swing.JMenuItem();
        mNarz2 = new javax.swing.JMenuItem();
        chOpcja1 = new javax.swing.JCheckBoxMenuItem();
        menuStyl = new javax.swing.JMenu();
        mMetal = new javax.swing.JMenuItem();
        mNimbus = new javax.swing.JMenuItem();
        mWindows = new javax.swing.JMenuItem();
        menuAbout = new javax.swing.JMenu();
        mAbout = new javax.swing.JMenuItem();

        jPopupMenu1.setComponentPopupMenu(jPopupMenu1);
        jPopupMenu1.setNextFocusableComponent(jScrollPane1);
        jPopupMenu1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jPopupMenu1MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jPopupMenu1MouseReleased(evt);
            }
        });
        notatnik.add(jPopupMenu1);
        notatnik.setComponentPopupMenu(jPopupMenu1);

        mKopiuj.setText("Kopiuj");
        mKopiuj.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mKopiujActionPerformed(evt);
            }
        });
        jPopupMenu1.add(mKopiuj);

        mWklej.setText("Wklej");
        mWklej.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mWklejActionPerformed(evt);
            }
        });
        jPopupMenu1.add(mWklej);

        mDolacz.setText("Dołącz");
        mDolacz.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mDolaczActionPerformed(evt);
            }
        });
        jPopupMenu1.add(mDolacz);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                formKeyTyped(evt);
            }
        });

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setEnabled(false);

        notatnik.setColumns(20);
        notatnik.setRows(5);
        jScrollPane1.setViewportView(notatnik);

        bSzukaj.setText("Szukaj");
        bSzukaj.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bSzukajActionPerformed(evt);
            }
        });

        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        tSzukany.setColumns(20);
        tSzukany.setRows(5);
        jScrollPane2.setViewportView(tSzukany);

        colorCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Czarny", "Czerwony", "Zielony" }));
        colorCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                colorComboActionPerformed(evt);
            }
        });

        mKolor.setText("Zmień Kolor");
        mKolor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mKolorActionPerformed(evt);
            }
        });

        pHaslo.setText("jPasswordField1");
        pHaslo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pHasloActionPerformed(evt);
            }
        });

        bZaloguj.setText("Zaloguj się!");
        bZaloguj.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bZalogujActionPerformed(evt);
            }
        });

        jSlider1.setMajorTickSpacing(20);
        jSlider1.setMinorTickSpacing(5);
        jSlider1.setPaintLabels(true);
        jSlider1.setPaintTicks(true);
        jSlider1.setValue(0);
        jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSlider1StateChanged(evt);
            }
        });

        jLabel1.setText("stopnie celsiusa");

        menuPlik.setText("Plik");

        mOtworz.setText("Otwórz");
        mOtworz.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mOtworzActionPerformed(evt);
            }
        });
        menuPlik.add(mOtworz);

        mZapisz.setText("Zapisz");
        mZapisz.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mZapiszActionPerformed(evt);
            }
        });
        menuPlik.add(mZapisz);
        menuPlik.addSeparator();

        mWyjscie.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
        mWyjscie.setText("Wyjdź");
        mWyjscie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mWyjscieActionPerformed(evt);
            }
        });
        menuPlik.add(mWyjscie);

        jMenuBar1.add(menuPlik);

        menuOpcje.setText("Opcje");

        mNarz1.setText("Narzędzie 1");
        menuOpcje.add(mNarz1);

        mNarz2.setText("Narzędzie 2");
        menuOpcje.add(mNarz2);

        chOpcja1.setSelected(true);
        chOpcja1.setText("Opcja1");
        chOpcja1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chOpcja1ActionPerformed(evt);
            }
        });
        menuOpcje.add(chOpcja1);

        jMenuBar1.add(menuOpcje);
        //jMenuBar1.add(Box.createHorizontalGlue());

        menuStyl.setText("Styl");

        mMetal.setText("Metal");
        mMetal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mMetalActionPerformed(evt);
            }
        });
        menuStyl.add(mMetal);

        mNimbus.setText("Nimbus");
        mNimbus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mNimbusActionPerformed(evt);
            }
        });
        menuStyl.add(mNimbus);

        mWindows.setText("Windows");
        mWindows.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mWindowsActionPerformed(evt);
            }
        });
        menuStyl.add(mWindows);

        jMenuBar1.add(menuStyl);

        menuAbout.setText("O Programie");

        mAbout.setText("O Programie");
        mAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mAboutActionPerformed(evt);
            }
        });
        menuAbout.add(mAbout);

        jMenuBar1.add(menuAbout);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(149, 149, 149)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jSlider1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(bSzukaj)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(mKolor))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE))
                .addGap(53, 53, 53)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(colorCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(76, 76, 76)
                        .addComponent(pHaslo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(78, 78, 78)
                            .addComponent(bZaloguj))))
                .addContainerGap(107, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(108, 108, 108)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(colorCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(39, 39, 39)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(bSzukaj, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                            .addComponent(mKolor)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(93, 93, 93)
                        .addComponent(pHaslo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(146, 146, 146)
                        .addComponent(bZaloguj)))
                .addGap(47, 47, 47)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(36, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void mAboutActionPerformed(java.awt.event.ActionEvent evt) {                                       
        JOptionPane.showMessageDialog(null, "Program testowy \n Wersja 1.0");

    }                                      

    private void mOtworzActionPerformed(java.awt.event.ActionEvent evt) {                                        
        JFileChooser fc = new JFileChooser();

        if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
        {
            File plik = fc.getSelectedFile();

            try 
            {

                //JOptionPane.showMessageDialog(null, "Zapisany plik to: " + plik);
               Scanner skaner = new Scanner(plik);
               while (skaner.hasNextLine())
               {
                   notatnik.append(skaner.nextLine() + "\n");
               } 

            } catch (FileNotFoundException ex) {
                Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);

            }
        }

    }                                       

    private void mZapiszActionPerformed(java.awt.event.ActionEvent evt) {                                        
        JFileChooser fc = new JFileChooser();

        if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION)
        {
            File plik = fc.getSelectedFile();

            try 
            {
                PrintWriter pw = new PrintWriter(plik);
                Scanner skaner = new Scanner(notatnik.getText());

                while (skaner.hasNextLine())
                {
                    pw.println(skaner.nextLine() + "\n");
                }
                pw.close();
            }
            catch (FileNotFoundException ex)
            {

            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);

            }
        }

    }                                       

    private void mWyjscieActionPerformed(java.awt.event.ActionEvent evt) {                                         
        dispose();
    }                                        

    private void chOpcja1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       if (chOpcja1.isSelected())
       {
           mNarz1.setEnabled(true);
       }
       else
       {
           mNarz1.setEnabled(false);
       }
    }                                        

    private void bSzukajActionPerformed(java.awt.event.ActionEvent evt) {                                        
        String tekst = notatnik.getText();
        String szukane = tSzukany.getText();
        String wystapienia = "";
        int i = 0;
        int index;
        int startIndex = 0;

        while((index = tekst.indexOf(szukane, startIndex)) != -1 )
        {
            startIndex = index + szukane.length();
            i++;
            wystapienia = wystapienia + " " + index;
        }

        JOptionPane.showMessageDialog(null, szukane + " wystąpiło " + i + " razy " + wystapienia);

    }                                       

    private void mKopiujActionPerformed(java.awt.event.ActionEvent evt) {                                        
       wybranyTekst = notatnik.getSelectedText();

    }                                       

    private void jPopupMenu1MousePressed(java.awt.event.MouseEvent evt) {                                         
        if (evt.isPopupTrigger())
        {
            jPopupMenu1.show(evt.getComponent(), evt.getX(), evt.getY());
        }
    }                                        

    private void jPopupMenu1MouseReleased(java.awt.event.MouseEvent evt) {                                          
        if (evt.isPopupTrigger())
        {
            jPopupMenu1.show(evt.getComponent(), evt.getX(), evt.getY());
        }
    }                                         

    private void formKeyTyped(java.awt.event.KeyEvent evt) {                              
        // TODO add your handling code here:
    }                             

    private void mWklejActionPerformed(java.awt.event.ActionEvent evt) {                                       

        notatnik.insert(wybranyTekst, notatnik.getCaretPosition());
    }                                      

    private void mDolaczActionPerformed(java.awt.event.ActionEvent evt) {                                        
        notatnik.append("\n" + wybranyTekst);
    }                                       

    private void colorComboActionPerformed(java.awt.event.ActionEvent evt) {                                           
        String color = (String) colorCombo.getSelectedItem();

        if (color.equals("Czarny"))
        {
            notatnik.setForeground(Color.BLACK);
        }
        else if (color.equals("Zielony"))
        {
            notatnik.setForeground(Color.GREEN);
        }
        else if (color.equals("Czerwony"))
        {
            notatnik.setForeground(Color.RED);
        }
    }                                          

    private void mKolorActionPerformed(java.awt.event.ActionEvent evt) {                                       
        Color wybranyKolor = JColorChooser.showDialog(null, "Wybierz kolor", Color.black);
        notatnik.setForeground(wybranyKolor);

    }                                      

    private void pHasloActionPerformed(java.awt.event.ActionEvent evt) {                                       
        JOptionPane.showMessageDialog(null, new String(pHaslo.getPassword()));
    }                                      

    private void bZalogujActionPerformed(java.awt.event.ActionEvent evt) {                                         
        if(panelHasla == null)
        {
            panelHasla = new PanelHasla(this);
        }
            panelHasla.setVisible(true);
            panelHasla.setFocus();

            if (panelHasla.isOK())
            {
                notatnik.append(panelHasla.getUser() + "\n");
                notatnik.append(panelHasla.getPassword() + "\n");
            }
            else
                notatnik.append("nie zalogowałeś się!");

    }                                        

    private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {                                      
        int stopnie = 0;
        stopnie = jSlider1.getValue();
        jLabel1.setText("Stopnie wynoszą " + stopnie);

    }                                     

    private void mMetalActionPerformed(java.awt.event.ActionEvent evt) {                                       

        try {
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

//            SwingUtilities.updateComponentTreeUI(this);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
        SwingUtilities.updateComponentTreeUI(this);
    }                                      

    private void mNimbusActionPerformed(java.awt.event.ActionEvent evt) {                                        
        try {
            UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
        SwingUtilities.updateComponentTreeUI(this);
    }                                       

    private void mWindowsActionPerformed(java.awt.event.ActionEvent evt) {                                         
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
        SwingUtilities.updateComponentTreeUI(this);
    }                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton bSzukaj;
    private javax.swing.JButton bZaloguj;
    private javax.swing.JCheckBoxMenuItem chOpcja1;
    private javax.swing.JComboBox colorCombo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSlider jSlider1;
    private javax.swing.JMenuItem mAbout;
    private javax.swing.JMenuItem mDolacz;
    private javax.swing.JButton mKolor;
    private javax.swing.JMenuItem mKopiuj;
    private javax.swing.JMenuItem mMetal;
    private javax.swing.JMenuItem mNarz1;
    private javax.swing.JMenuItem mNarz2;
    private javax.swing.JMenuItem mNimbus;
    private javax.swing.JMenuItem mOtworz;
    private javax.swing.JMenuItem mWindows;
    private javax.swing.JMenuItem mWklej;
    private javax.swing.JMenuItem mWyjscie;
    private javax.swing.JMenuItem mZapisz;
    private javax.swing.JMenu menuAbout;
    private javax.swing.JMenu menuOpcje;
    private javax.swing.JMenu menuPlik;
    private javax.swing.JMenu menuStyl;
    private javax.swing.JTextArea notatnik;
    private javax.swing.JPasswordField pHaslo;
    private javax.swing.JTextArea tSzukany;
    // End of variables declaration                   
}

Pozostało 580 znaków

2015-01-23 09:20
2

Bierzesz udział w konkursie na najdłuższy kod jednej klasy?


To smutne, że głupcy są tak pewni siebie, a ludzie mądrzy - tak pełni wątpliwości. Bertrand Russell

Pozostało 580 znaków

2015-01-23 13:21
0

Cóż netbeans GUI builder niestety tak działa nie znalazłem opcji zmiany generowanego kodu.

Pozostało 580 znaków

2015-01-23 15:24
0

Nie chce mi się przeglądać tego kodu ale znając życie to masz funckje która wywołuje sama siebie w nieskończoność, bo to błąd przepełnionego stosu. Zapnij się debugerem i zobacz która linijka ci dokładnie wywala ten błąd.

Ja bym obstawiał to
updateComponentTreeUI ale szczerze to nie wiem :)

Rada ode mnie

nie używaj generatorów GUI ;-)

Pozostało 580 znaków

2015-01-24 11:06
0

Winne jest na pewno

updateComponentTreeUI(this);

tylko nie wiem dlaczego. Mam parę programów, w których w ten właśnie sposób zmieniam wygląd i nie ma nieskończonej rekurencji. Różnica jest taka, że w moich programach akcja jest podpięta pod JButton.Spróbuj też podpiąć akcję pod JButton.
Rada ode mnie, nie używaj generatorów GUI. ;-)


To smutne, że głupcy są tak pewni siebie, a ludzie mądrzy - tak pełni wątpliwości. Bertrand Russell
edytowany 3x, ostatnio: bogdans, 2015-01-24 11:07

Pozostało 580 znaków

2015-01-24 11:47
0

Tak też zrobię... Dzięki wielkie

Pozostało 580 znaków

2015-01-24 18:05
0

A co to jest?

notatnik.add(jPopupMenu1);
notatnik.setComponentPopupMenu(jPopupMenu1);

menu podpięte do textarea? Wyrzuć te dwie linijki i będzie działać...

Pozostało 580 znaków

Odpowiedz
Liczba odpowiedzi na stronę

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0