Oppure

Loading
07/04/11 21:16
spode
l'errore è:
 Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at filetrenner.GUI.showGruppo2(GUI.java:153)
        at filetrenner.fileTrenner.setOutput(fileTrenner.java:52)
        at filetrenner.fileTrenner.openStreamInput(fileTrenner.java:42)
        at filetrenner.fileTrenner.setSorgente(fileTrenner.java:28)
        at filetrenner.GUI.actionPerformed(GUI.java:66)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253)
        at java.awt.Component.processMouseEvent(Component.java:6203)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:5968)
        at java.awt.Container.processEvent(Container.java:2105)
        at java.awt.Component.dispatchEventImpl(Component.java:4564)
        at java.awt.Container.dispatchEventImpl(Container.java:2163)
        at java.awt.Component.dispatchEvent(Component.java:4390)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4125)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
        at java.awt.Container.dispatchEventImpl(Container.java:2149)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4390)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:649)
        at java.awt.EventQueue.access
l'errore è:
 Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at filetrenner.GUI.showGruppo2(GUI.java:153)
        at filetrenner.fileTrenner.setOutput(fileTrenner.java:52)
        at filetrenner.fileTrenner.openStreamInput(fileTrenner.java:42)
        at filetrenner.fileTrenner.setSorgente(fileTrenner.java:28)
        at filetrenner.GUI.actionPerformed(GUI.java:66)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253)
        at java.awt.Component.processMouseEvent(Component.java:6203)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:5968)
        at java.awt.Container.processEvent(Container.java:2105)
        at java.awt.Component.dispatchEventImpl(Component.java:4564)
        at java.awt.Container.dispatchEventImpl(Container.java:2163)
        at java.awt.Component.dispatchEvent(Component.java:4390)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4125)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
        at java.awt.Container.dispatchEventImpl(Container.java:2149)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4390)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:649)
        at java.awt.EventQueue.access{parsed_message}0(EventQueue.java:96)
        at java.awt.EventQueue.run(EventQueue.java:608)
        at java.awt.EventQueue.run(EventQueue.java:606)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext.doIntersectionPrivilege(AccessControlContext.java:105)
        at java.security.AccessControlContext.doIntersectionPrivilege(AccessControlContext.java:116)
        at java.awt.EventQueue.run(EventQueue.java:622)
        at java.awt.EventQueue.run(EventQueue.java:620)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext.doIntersectionPrivilege(AccessControlContext.java:105)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:619)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
COSTRUITO CON SUCCESSO (tempo totale: 12 secondi)


e i codici:

FILE: FILETRENNER.JAVA

package filetrenner;

import javax.swing.JFileChooser;
import java.io.PrintStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
import java.util.Random;

public class fileTrenner
{

    private Scanner in = null;
    private int maxCaratteri = 0;

    public void setSorgente(String maxCaratteri)
    {
        this.maxCaratteri = Integer.parseInt(maxCaratteri);
        String desktop = System.getProperty("user.home");//NOTA
        JFileChooser chooser = new JFileChooser(desktop.concat("\Desktop"));
        chooser.setMultiSelectionEnabled(false);
                if(chooser.showOpenDialog( null) == JFileChooser.APPROVE_OPTION)
                {
                    sorgente = chooser.getSelectedFile();
                }

        this.openStreamInput();
    }

    private void openStreamInput()
    {
        try
        {
            in = new Scanner(new FileReader(sorgente));
        }
        catch(FileNotFoundException e)
        {
            scrivi("Impossibile accedere al file sorgente... " + e);
            this.setSorgente(null);
        }
        this.setOutput();
    }

    public void setOutput()
    {
        String destinazione = sorgente.getAbsolutePath().toString().replace(".txt", " - diviso per ").concat(Integer.toString(maxCaratteri)).concat(".txt");
        File output = new File(destinazione);

        GUI interfaccia = new GUI();
        interfaccia.showGruppo2(sorgente.getName(), output.getAbsolutePath());
        this.openStreamOutput(output);
    }

    PrintStream out = null;
    public void openStreamOutput(File output)
    {
        try
        {
            out = new PrintStream(output);
        }
        catch(FileNotFoundException  f)
        {
            scrivi("Impossibile aprire il file di destinazione... " + f);
        }
    }

    public void trennen()
    {
        int somma = 0;
        while(in.hasNext())
        {
            String next = in.next();
            if(somma + next.length() + 1 == maxCaratteri)
            {
                somma = 0;
                out.println(next);
            }
            else if(somma + next.length() + 1 < maxCaratteri)
            {
                somma = somma + 1 + next.length();
                out.print(next.concat(" "));
            }
            else
            {
                somma = next.length();
                out.println();
                out.print(next.concat(" "));
            }
        }
        GUI interfaccia = new GUI();
        interfaccia.showGruppo3();
    }

    public static File sorgente = null;
    public static void main(String[] args)
    {
        fileTrenner divisore = new fileTrenner();
        //divisore.openBenvenuto();

        GUI interfaccia = new GUI();
        interfaccia.creaFrame();
        interfaccia.gruppo1();
        interfaccia.gruppo2();
        interfaccia.gruppo3();
    }

    private void openBenvenuto()
    {
        Random generatore = new Random();
        int casuale = generatore.nextInt();
        
    }

    private static void scrivi(String testo)
    {
        System.out.println(testo);
    }
}


FILE: GUI.JAVA

package filetrenner;
import javax.swing.*;
import java.awt.Color;
import java.awt.TextField;
import java.awt.Label;
import java.awt.event.*;

public class GUI
{
    fileTrenner divisore = new fileTrenner();

    public JFrame frame = null;
    public void creaFrame()
    {
        frame = new JFrame ("File Trenner für Zippo");
        frame.setAlwaysOnTop(true);
        frame.setSize(500, 500);
        frame.setLocation(700, 10);
        frame.setVisible(true);
        frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(null);

        ImageIcon icon = new ImageIcon("/home/spode/Scrivania/sfondo.png");
        JLabel sfondo = new JLabel(icon);
        sfondo.setSize(frame.getSize());
        sfondo.setLocation(frame.getLocation());
        frame.add(sfondo);
    }
////////////////////////////////////////////////////////////////////////////////////////////
    TextField testo1 = new TextField();
    public void gruppo1()
    {
                JButton pulsante1 = null;

        Label label1 = new Label("Caratteri per riga: ");
        label1.setSize(125, 15);
        label1.setLocation(10, 10);
        label1.setForeground(Color.black);
        frame.add(label1);

        testo1.setSize(75, 15);
        testo1.setLocation(160, 10);
        testo1.setColumns(3);
        testo1.setEditable(true);
        testo1.getCursor();
        testo1.setForeground(Color.orange);
        frame.add(testo1);

        pulsante1 = new JButton("0k");
        pulsante1.setForeground(Color.green);
        pulsante1.setVisible(true);
        pulsante1.setSize(60, 15);
        pulsante1.setLocation(10, 40);
        frame.add(pulsante1);
        pulsante1.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                try
                {
                if(Integer.parseInt(testo1.getText()) > 0)
                {
                    System.out.println(testo1.getText());
                    divisore.setSorgente(testo1.getText());
                }
                }
                catch(NumberFormatException ex)
                {
                    testo1.setText("");
                }
            }
        }
                );
    }
///////////////////////////////////////////////////////////////////////////////////////////////
    Label label2 = null;
    Label label3 = null;
    Label label4 = null;
    Label label5 = null;
    JButton pulsante2 = null;
    JButton pulsante3 = null;
    public void gruppo2()
    {
        label2 = new Label("File Sorgente: ");
        label2.setForeground(Color.black);
        label2.setLocation(10, 100);
        label2.setSize(90, 15);
        label2.setVisible(false);
        frame.add(label2);

        label3 = new Label();
        label3.setForeground(Color.orange);
        label3.setSize(90, 15);
        label3.setLocation(100, 100);
        label3.setVisible(false);
        frame.add(label3);

        label4 = new Label("File Output: ");
        label4.setForeground(Color.black);
        label4.setVisible(false);
        label4.setLocation(label2.getX(), label2.getY() + 30);
        label4.setSize(label2.getSize());
        frame.add(label4);

        label5 = new Label();
        label5.setForeground(Color.orange);
        label5.setVisible(false);
        label5.setLocation(label3.getX(), label3.getY() + 30);
        label5.setSize(100, label2.getHeight());
        frame.add(label5);

        pulsante2 = new JButton("0k!");
        pulsante2.setForeground(Color.green);
        pulsante2.setSize(60, 15);
        pulsante2.setLocation(label4.getX(), label4.getY() + 30);
        pulsante2.setVisible(false);
        frame.add(pulsante2);
        pulsante2.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                divisore.trennen();
            }
        });

        pulsante3 = new JButton("Reset");
        pulsante3.setForeground(Color.red);
        pulsante3.setSize(75, 15);
        pulsante3.setLocation(75, pulsante2.getY());
        pulsante3.setVisible(false);
        frame.add(pulsante3);
        pulsante3.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                testo1.setText("");
                label2.setVisible(false);
                label3.setVisible(false);
                label4.setVisible(false);
                label5.setVisible(false);
                pulsante2.setVisible(false);
                pulsante3.setVisible(false);
            }
        });
        System.out.println("gruppo2");
    }

    public void showGruppo2(String nome, String nomeOut)
    {
        this.label2.setVisible(true);//RIGA 153!
        this.label3.setText(nome);
        this.label4.setVisible(true);
        this.label5.setText(nomeOut);
        this.label5.setVisible(true);
    }
/////////////////////////////////////////////////////////////////////////////////////////
    Label label6 = null;
    JComboBox comboBox = new JComboBox();
    JButton pulsante4 = null;
    Label label7 = null;
    public void gruppo3()
    {
        label6 = new Label("Riprovi? ");
        label6.setForeground(Color.black);
        label6.setVisible(false);
        label6.setLocation(pulsante2.getX(), pulsante2.getY() + 80);
        label6.setSize(55, 15);
        frame.add(label6);

        comboBox.addItem("Si");
        comboBox.setLocation(70, label6.getY());
        comboBox.setSelectedIndex(0);
        comboBox.setVisible(false);
        comboBox.setSize(40, 20);

        comboBox.addItem("No");
        frame.add(comboBox);
        comboBox.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                System.exit(0);
            }
        });

        pulsante4 = new JButton();
        pulsante4.setLocation(120, 200);
        pulsante4.setSize(pulsante2.getSize());
        pulsante4.setForeground(Color.black);
        pulsante4.setVisible(false);
        frame.add(pulsante4);
        pulsante4.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                label7.setVisible(false);
                label2.setVisible(false);
                label4.setVisible(false);
                label3.setVisible(false);
                label5.setVisible(false);
                label6.setVisible(false);
                pulsante2.setVisible(false);
                pulsante3.setVisible(false);
                pulsante4.setVisible(false);
                comboBox.setVisible(false);
            }
        });

        label7 = new Label("Formattazione avvenuta con successo!");
        label7.setForeground(Color.black);
        label7.setLocation(120, 330);
        label7.setVisible(false);
        label7.setSize(245, 15);
        frame.add(label7);
        System.out.println("gruppo 3");
    }

    public void showGruppo3()
    {
        this.label6.setVisible(true);
        this.label7.setVisible(true);
        this.comboBox.setVisible(true);
        this.pulsante4.setVisible(true);
    }
}
0(EventQueue.java:96) at java.awt.EventQueue.run(EventQueue.java:608) at java.awt.EventQueue.run(EventQueue.java:606) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext.doIntersectionPrivilege(AccessControlContext.java:105) at java.security.AccessControlContext.doIntersectionPrivilege(AccessControlContext.java:116) at java.awt.EventQueue.run(EventQueue.java:622) at java.awt.EventQueue.run(EventQueue.java:620) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext.doIntersectionPrivilege(AccessControlContext.java:105) at java.awt.EventQueue.dispatchEvent(EventQueue.java:619) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177) at java.awt.EventDispatchThread.run(EventDispatchThread.java:138) COSTRUITO CON SUCCESSO (tempo totale: 12 secondi)


e i codici:

FILE: FILETRENNER.JAVA

package filetrenner;

import javax.swing.JFileChooser;
import java.io.PrintStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
import java.util.Random;

public class fileTrenner
{

    private Scanner in = null;
    private int maxCaratteri = 0;

    public void setSorgente(String maxCaratteri)
    {
        this.maxCaratteri = Integer.parseInt(maxCaratteri);
        String desktop = System.getProperty("user.home");//NOTA
        JFileChooser chooser = new JFileChooser(desktop.concat("\Desktop"));
        chooser.setMultiSelectionEnabled(false);
                if(chooser.showOpenDialog( null) == JFileChooser.APPROVE_OPTION)
                {
                    sorgente = chooser.getSelectedFile();
                }

        this.openStreamInput();
    }

    private void openStreamInput()
    {
        try
        {
            in = new Scanner(new FileReader(sorgente));
        }
        catch(FileNotFoundException e)
        {
            scrivi("Impossibile accedere al file sorgente... " + e);
            this.setSorgente(null);
        }
        this.setOutput();
    }

    public void setOutput()
    {
        String destinazione = sorgente.getAbsolutePath().toString().replace(".txt", " - diviso per ").concat(Integer.toString(maxCaratteri)).concat(".txt");
        File output = new File(destinazione);

        GUI interfaccia = new GUI();
        interfaccia.showGruppo2(sorgente.getName(), output.getAbsolutePath());
        this.openStreamOutput(output);
    }

    PrintStream out = null;
    public void openStreamOutput(File output)
    {
        try
        {
            out = new PrintStream(output);
        }
        catch(FileNotFoundException  f)
        {
            scrivi("Impossibile aprire il file di destinazione... " + f);
        }
    }

    public void trennen()
    {
        int somma = 0;
        while(in.hasNext())
        {
            String next = in.next();
            if(somma + next.length() + 1 == maxCaratteri)
            {
                somma = 0;
                out.println(next);
            }
            else if(somma + next.length() + 1 < maxCaratteri)
            {
                somma = somma + 1 + next.length();
                out.print(next.concat(" "));
            }
            else
            {
                somma = next.length();
                out.println();
                out.print(next.concat(" "));
            }
        }
        GUI interfaccia = new GUI();
        interfaccia.showGruppo3();
    }

    public static File sorgente = null;
    public static void main(String[] args)
    {
        fileTrenner divisore = new fileTrenner();
        //divisore.openBenvenuto();

        GUI interfaccia = new GUI();
        interfaccia.creaFrame();
        interfaccia.gruppo1();
        interfaccia.gruppo2();
        interfaccia.gruppo3();
    }

    private void openBenvenuto()
    {
        Random generatore = new Random();
        int casuale = generatore.nextInt();
        
    }

    private static void scrivi(String testo)
    {
        System.out.println(testo);
    }
}


FILE: GUI.JAVA

package filetrenner;
import javax.swing.*;
import java.awt.Color;
import java.awt.TextField;
import java.awt.Label;
import java.awt.event.*;

public class GUI
{
    fileTrenner divisore = new fileTrenner();

    public JFrame frame = null;
    public void creaFrame()
    {
        frame = new JFrame ("File Trenner für Zippo");
        frame.setAlwaysOnTop(true);
        frame.setSize(500, 500);
        frame.setLocation(700, 10);
        frame.setVisible(true);
        frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(null);

        ImageIcon icon = new ImageIcon("/home/spode/Scrivania/sfondo.png");
        JLabel sfondo = new JLabel(icon);
        sfondo.setSize(frame.getSize());
        sfondo.setLocation(frame.getLocation());
        frame.add(sfondo);
    }
////////////////////////////////////////////////////////////////////////////////////////////
    TextField testo1 = new TextField();
    public void gruppo1()
    {
                JButton pulsante1 = null;

        Label label1 = new Label("Caratteri per riga: ");
        label1.setSize(125, 15);
        label1.setLocation(10, 10);
        label1.setForeground(Color.black);
        frame.add(label1);

        testo1.setSize(75, 15);
        testo1.setLocation(160, 10);
        testo1.setColumns(3);
        testo1.setEditable(true);
        testo1.getCursor();
        testo1.setForeground(Color.orange);
        frame.add(testo1);

        pulsante1 = new JButton("0k");
        pulsante1.setForeground(Color.green);
        pulsante1.setVisible(true);
        pulsante1.setSize(60, 15);
        pulsante1.setLocation(10, 40);
        frame.add(pulsante1);
        pulsante1.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                try
                {
                if(Integer.parseInt(testo1.getText()) > 0)
                {
                    System.out.println(testo1.getText());
                    divisore.setSorgente(testo1.getText());
                }
                }
                catch(NumberFormatException ex)
                {
                    testo1.setText("");
                }
            }
        }
                );
    }
///////////////////////////////////////////////////////////////////////////////////////////////
    Label label2 = null;
    Label label3 = null;
    Label label4 = null;
    Label label5 = null;
    JButton pulsante2 = null;
    JButton pulsante3 = null;
    public void gruppo2()
    {
        label2 = new Label("File Sorgente: ");
        label2.setForeground(Color.black);
        label2.setLocation(10, 100);
        label2.setSize(90, 15);
        label2.setVisible(false);
        frame.add(label2);

        label3 = new Label();
        label3.setForeground(Color.orange);
        label3.setSize(90, 15);
        label3.setLocation(100, 100);
        label3.setVisible(false);
        frame.add(label3);

        label4 = new Label("File Output: ");
        label4.setForeground(Color.black);
        label4.setVisible(false);
        label4.setLocation(label2.getX(), label2.getY() + 30);
        label4.setSize(label2.getSize());
        frame.add(label4);

        label5 = new Label();
        label5.setForeground(Color.orange);
        label5.setVisible(false);
        label5.setLocation(label3.getX(), label3.getY() + 30);
        label5.setSize(100, label2.getHeight());
        frame.add(label5);

        pulsante2 = new JButton("0k!");
        pulsante2.setForeground(Color.green);
        pulsante2.setSize(60, 15);
        pulsante2.setLocation(label4.getX(), label4.getY() + 30);
        pulsante2.setVisible(false);
        frame.add(pulsante2);
        pulsante2.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                divisore.trennen();
            }
        });

        pulsante3 = new JButton("Reset");
        pulsante3.setForeground(Color.red);
        pulsante3.setSize(75, 15);
        pulsante3.setLocation(75, pulsante2.getY());
        pulsante3.setVisible(false);
        frame.add(pulsante3);
        pulsante3.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                testo1.setText("");
                label2.setVisible(false);
                label3.setVisible(false);
                label4.setVisible(false);
                label5.setVisible(false);
                pulsante2.setVisible(false);
                pulsante3.setVisible(false);
            }
        });
        System.out.println("gruppo2");
    }

    public void showGruppo2(String nome, String nomeOut)
    {
        this.label2.setVisible(true);//RIGA 153!
        this.label3.setText(nome);
        this.label4.setVisible(true);
        this.label5.setText(nomeOut);
        this.label5.setVisible(true);
    }
/////////////////////////////////////////////////////////////////////////////////////////
    Label label6 = null;
    JComboBox comboBox = new JComboBox();
    JButton pulsante4 = null;
    Label label7 = null;
    public void gruppo3()
    {
        label6 = new Label("Riprovi? ");
        label6.setForeground(Color.black);
        label6.setVisible(false);
        label6.setLocation(pulsante2.getX(), pulsante2.getY() + 80);
        label6.setSize(55, 15);
        frame.add(label6);

        comboBox.addItem("Si");
        comboBox.setLocation(70, label6.getY());
        comboBox.setSelectedIndex(0);
        comboBox.setVisible(false);
        comboBox.setSize(40, 20);

        comboBox.addItem("No");
        frame.add(comboBox);
        comboBox.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                System.exit(0);
            }
        });

        pulsante4 = new JButton();
        pulsante4.setLocation(120, 200);
        pulsante4.setSize(pulsante2.getSize());
        pulsante4.setForeground(Color.black);
        pulsante4.setVisible(false);
        frame.add(pulsante4);
        pulsante4.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                label7.setVisible(false);
                label2.setVisible(false);
                label4.setVisible(false);
                label3.setVisible(false);
                label5.setVisible(false);
                label6.setVisible(false);
                pulsante2.setVisible(false);
                pulsante3.setVisible(false);
                pulsante4.setVisible(false);
                comboBox.setVisible(false);
            }
        });

        label7 = new Label("Formattazione avvenuta con successo!");
        label7.setForeground(Color.black);
        label7.setLocation(120, 330);
        label7.setVisible(false);
        label7.setSize(245, 15);
        frame.add(label7);
        System.out.println("gruppo 3");
    }

    public void showGruppo3()
    {
        this.label6.setVisible(true);
        this.label7.setVisible(true);
        this.comboBox.setVisible(true);
        this.pulsante4.setVisible(true);
    }
}
Ultima modifica effettuata da spode 07/04/11 21:18
aaa
10/04/11 8:06
tasx
Ciao!!

Il problema è che l'oggetto GUI quando fai questa cosa qui:
GUI interfaccia = new GUI();
        interfaccia.showGruppo2(sorgente.getName(), output.getAbsolutePath());


viene resettato quindi la variabile "label2" viene impostata a "null", quindi quando viene chiamato il ".setVisible(true)" ti parte una eccezione.

Per risolvere dovresti chiamare il metodo "gruppo2" prima di di uitlizzare il metodo "showGruppo2(...)" o altrimenti la inizializzi da qualche altra parte, o altrimenti ancora non stai a ricreare ogni volta sempre la stessa classe, la creai una volta e poi la riutilizzi nel codice.

Ciaociao!!
aaa
10/04/11 11:25
spode
penso che sceglierò l'ultima. grazie! =)
aaa