jLabel MouseEvent, Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException


Baskaran
7/5/2016 5:43 am
HOME ยป Web Development

I want to make button with hover using jLabel. When I come over button errors appears. I'm using netbeans. Most of the codes generated automatically.

public class anaEkrn extends javax.swing.JFrame {

public anaEkrn() {
    initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code"> 
                        
private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();

   
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jLabel1.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/market2/images/tumu.png")));
// NOI18N
    jLabel1.setText("jLabel1");
    jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseEntered(java.awt.event.MouseEvent evt) {
            jLabel1MouseEntered(evt);
        }
        public void mousePressed(java.awt.event.MouseEvent evt) {
            jLabel1MousePressed(evt);
        }
    });

    javax.swing.GroupLayout jPanel1Layout = new
javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
       
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 79,
javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(197, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
       
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 97,
javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
    );

    javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
       
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
            .addContainerGap(298, Short.MAX_VALUE)
            .addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(23, 23, 23))
    );
    layout.setVerticalGroup(
       
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(19, 19, 19)
            .addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(328, Short.MAX_VALUE))
    );

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

private void jLabel1MouseEntered(java.awt.event.MouseEvent evt) {     
                               
    ImageIcon icon= new
ImageIcon(getClass().getResource("/images/tumu.png"));
    jLabel1.setIcon(icon);
}                                    

private void jLabel1MousePressed(java.awt.event.MouseEvent evt) {     
                               
    ImageIcon II = new
ImageIcon(getClass().getResource("/images/tumu_hover.png"));
    jLabel1.setIcon(II);
}                                    

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(anaEkrn.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
    } catch (InstantiationException ex) {
       
java.util.logging.Logger.getLogger(anaEkrn.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
    } catch (IllegalAccessException ex) {
       
java.util.logging.Logger.getLogger(anaEkrn.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
       
java.util.logging.Logger.getLogger(anaEkrn.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 anaEkrn().setVisible(true);
        }
    });
}

// Variables declaration - do not modify                     
public javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
// End of variables declaration                   

There are so many errors under this error title.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

What should I do?


Related to : jLabel MouseEvent, Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
jLabel MouseEvent, Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
7/5/2016 5:43 am by Baskaran in Web Development

I want to make button with hover using jLabel. When I come over button errors appears. I'm using netbeans. Most of the codes generated automatically.

public class anaEkrn extends javax.swing.JFrame {

public anaEkrn() {
    initComponents();
}
@SuppressWarnings("unchecked")
// <
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException help!!!
by soonk in Web Development

I have spent over a WEEK trying to figure out why my code isn't working. It's a long code, I will post it all but I will break down the code as I explain.
First off, I have called double[] arrays and then initialized them later on in the program on certain steps. What problem is that even th


Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException !
by Roman in Web Development

I made a poker game and when I run it I get these errors...

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at PokerGame.Hand.getPairs(Hand.java:82) at PokerGame.Hand.whichHand(Hand.java:28) at PokerGame.DeckOfCards$1.acti
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException !!
by Pakistan in Web Development

run:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.sun.java.swing.plaf.nimbus.NimbusStyle.init(NimbusStyle.java:418)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.validate(NimbusStyle.java:359)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.getVal


Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException !!!
by GreenChile in Web Development

I am creating a GUI program with java and when I run it, I get this stack of errors.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at ButtonPanel$AllocateListener.actionPerformed(ButtonPanel.java:52) at javax.swing.AbstractButton.fireActionP
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException !! $ !!
by LookBehindYou in Web Development

I am getting the following exception when I am running my Swing Application. But the program continues and does not terminate abruptly unlike general Exceptions

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTreeUI.paintRow(BasicTr


Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
by MisterLilBig in Web Development

I'm having an issue, when I run my application and click over the JMenuBar I get the following exception, I'm not sure why because no line at the exception point to my code, those lines are all from JavaLibraries.
The exception points over the Event Handler/Dispatche... so I gues maybe I'm n


eclipse : Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
by Insomniator in Web Development

(I am new to java so please don't make your answer TOOOOOOO CONFUSING!!!! :P.)
I just have created a game using eclipse and I really wanted to make a fun game! I looked off of some tutorials that helped me create this. The thing is I can't move in the game. I would really appreciate help! TAGS: eclipse Exception thread ldquo EventQueue rdquo

Java: Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
by cashshadow in Web Development

public class MainFrame extends JFrame {
public DefaultTableModel historyModel;
public DefaultTableModel dataModel;
public JTable historyTable;
public JTable dataTable;
public JTableHeader header;
private void createUI() {
browsersT
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Java GUI Error
by Gipsy.D in Web Development

I am trying to design a calculator in java. My code isn't finished but I have designed a GUI, which works except for when i try to actually calculate the result. When i press "=" on my calculator i receive the above error. Here is my code:GUI:import javax.swing.*;import java.awt.event.ActionListener
HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .