[nbj2ee] Re: Set jLable text from another class

  • From: John Yeary < >
  • To:
  • Subject: [nbj2ee] Re: Set jLable text from another class
  • Date: Tue, 16 Oct 2012 15:41:09 -0400

This is the wrong forum for GUI based questions, please use the  " target="_blank"> mailing list.


John Yeary
NetBeans Dream Team
President Greenville Java Users Group
Java Users Groups Community Leader
Java Enterprise Community Leader



"Far better it is to dare mighty things, to win glorious triumphs, even though checkered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the gray twilight that knows not victory nor defeat."
-- Theodore Roosevelt

On Mon, Oct 15, 2012 at 8:24 PM, Kwauhn < " target="_blank"> > wrote:
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:

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 :)



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 {
            String output = new Scanner(new File("C:\\Program Files\\Fethr\\Worlds\\Mill\\chunks.dat")).useDelimiter("\\Z").next();
        }catch(java.util.NoSuchElementException e1){
            Notice.jLabel2.setText("The chunks.dat file provided is corrupt, Fethr can not read the world.");

[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 25 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20150226.965aeb8). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
Please Confirm