[nbj2ee] Set jLable text from another class

  • From: "Kwauhn" < >
  • To:
  • Subject: [nbj2ee] Set jLable text from another class
  • Date: Mon, 15 Oct 2012 20:24:27 -0400

so I'm trying to create an error message for a program, and the dialog window 
is displayed when the error java.util.NoSuchElementException is caught. Just 
before that though, I try to change the text in the jLabel from the Notice 
class to "The chunks.dat file provided is corrupt, Fethr can not read the 
world.". When I have this code here is the only time I get this error:


Code:
Exception in thread "main" java.lang.NullPointerException
        at src.ChunksReader.main(ChunksReader.java:13)
Java Result: 1



The problem is, I have gone into the jLabel's declaration and changed the 
identifiers the "public static", and NetBeans says the code is fine when 
viewing the source. If anyone knows why I get this error, and how to fix it, 
that would be really helpful :)

source:


Code:

package src;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class ChunksReader {
    public static void main(String[] args) throws FileNotFoundException {
        try{
            String output = new Scanner(new File("C:\\Program 
Files\\Fethr\\Worlds\\Mill\\chunks.dat")).useDelimiter("\\Z").next();
            System.out.println(output);
        }catch(java.util.NoSuchElementException e1){
            Notice.jLabel2.setText("The chunks.dat file provided is corrupt, 
Fethr can not read the world.");
            Notice.main(args);
        }
    }
}









[nbj2ee] Set jLable text from another class

Kwauhn 10/16/2012

[nbj2ee] Re: Set jLable text from another class

John Yeary 10/16/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close