Results 1 to 5 of 5
- 02-04-2012, 02:38 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 48
- Rep Power
- 0
Uncaught error fetching image eror
I am facing this error which says uncaught error fetching image. But i do not know where is the image that is null.
I need help..
Java Code:package HealthOK.ui; import javax.swing.JPanel; import java.awt.Color; import java.awt.Dimension; import javax.swing.JLabel; import java.awt.Rectangle; import javax.swing.ImageIcon; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.SwingConstants; import javax.swing.JButton; import java.awt.Point; import javax.swing.Timer; import HealthOK.ui.TimerModel; import HealthOK.entity.GameQuestion; import OOPJ.database.DBController; import java.sql.ResultSet; import java.util.ArrayList; public class GamesQuestionPanel extends JPanel{ private static final long serialVersionUID = 1L; private JLabel jLabelQuestion = null; private JLabel jLabelScore = null; private JLabel jLabelHeart1 = null; private JLabel jLabelHeart2 = null; private JLabel jLabelHeart3 = null; private JButton jButtonAnswer1; private JButton jButtonAnswer2; private JButton jButtonAnswer3; private JLabel jLabelDescription1; private JLabel jLabelDescription2; private JLabel jLabelDescription3; private JButton jButtonAdd = null; private JFrame myFrame = null; private JLabel jLabelTimer = null; private Timer t; private TimerModel tm; private int qn_num = 0; private JLabel jLabelScore1 = null; private JLabel jLabelQn; private JButton jButtonEdit = null; private String answer; private int count=0; int Score = 0; public void Randomise() { ArrayList<Integer> random = new ArrayList<Integer>(); try{ DBController db = new DBController(); //passing data source name db.setUp("CFDatabase"); String g_question =" "; String dbQuery = "SELECT * FROM GameQuestion WHERE g_question ='" + g_question + "'"; //for retrieve SQL use readRequest method ResultSet rs = db.readRequest(dbQuery); if (rs.next()){ int g_questionNo =rs.getInt("g_questionNo"); random.add(g_questionNo); System.out.println(random.get(g_questionNo)); } }catch (Exception e) { e.printStackTrace(); } ;} /** * This is the default constructor */ public GamesQuestionPanel() { super(); initialize(); } public GamesQuestionPanel(JFrame f) { this(); myFrame = f; } public GamesQuestionPanel(JFrame f, String s ){ this(); myFrame = f; jLabelTimer.setText(s); } /** * This method initialises this * * @return void */ private void initialize() { jLabelQn = new JLabel(); jLabelQn.setBounds(new Rectangle(13, 96, 55, 50)); jLabelQn.setFont(new Font("Dialog", Font.BOLD, 18)); jLabelQn.setHorizontalAlignment(SwingConstants.CENTER); jLabelQn.setHorizontalTextPosition(SwingConstants.CENTER); jLabelQn.setText(""); jLabelScore1 = new JLabel(); jLabelScore1.setText(""); jLabelScore1.setSize(new Dimension(83, 29)); jLabelScore1.setLocation(new Point(119, 438)); jLabelTimer = new JLabel(); jLabelTimer.setBounds(new Rectangle(17, 23, 199, 53)); jLabelTimer.setText("00:01:00"); jLabelTimer.setHorizontalTextPosition(SwingConstants.CENTER); jLabelTimer.setIcon(new ImageIcon(getClass().getResource("/HealthOK/ui/images/timerbg.png"))); jLabelTimer.setFont(new Font("Dialog", Font.BOLD, 18)); jLabelTimer.setHorizontalAlignment(SwingConstants.CENTER); t = new Timer(1000, new java.awt.event.ActionListener(){ public void actionPerformed(java.awt.event.ActionEvent e) { tm.timeTick(); jLabelTimer.setText(tm.getTime()); if(tm.isTimeUp()){ t.stop(); JOptionPane.showMessageDialog(null, "HighScore: " + Score, "GameOver", JOptionPane.INFORMATION_MESSAGE); int finalScore = Score ; String display = Integer.toString(finalScore); jLabelScore.setText(display); tm.setTime("00:10:00"); JPanel panel = new ProgrammesEventsPanelEnq(myFrame); myFrame.getContentPane().removeAll(); myFrame.getContentPane().add(panel); myFrame.getContentPane().validate(); myFrame.getContentPane().repaint(); } } }); tm = new TimerModel(); tm.setTime("00:01:00"); t.start(); jLabelDescription3 = new JLabel(); jLabelDescription3.setFont(new Font("Dialog", Font.BOLD, 20)); jLabelDescription3.setLocation(new Point(483, 385)); jLabelDescription3.setSize(new Dimension(218, 33)); jLabelDescription3.setHorizontalAlignment(SwingConstants.CENTER); jLabelDescription3.setHorizontalTextPosition(SwingConstants.CENTER); jLabelDescription3.setForeground(Color.black); jLabelDescription2 = new JLabel(); jLabelDescription2.setFont(new Font("Dialog", Font.BOLD, 20)); jLabelDescription2.setLocation(new Point(244, 386)); jLabelDescription2.setSize(new Dimension(226, 33)); jLabelDescription2.setHorizontalAlignment(SwingConstants.CENTER); jLabelDescription2.setHorizontalTextPosition(SwingConstants.CENTER); jLabelDescription2.setForeground(Color.black); jLabelDescription1 = new JLabel(); jLabelDescription1.setFont(new Font("Dialog", Font.BOLD, 20)); jLabelDescription1.setBackground(new Color(238, 238, 238)); jLabelDescription1.setLocation(new Point(9, 386)); jLabelDescription1.setSize(new Dimension(225, 33)); jLabelDescription1.setHorizontalAlignment(SwingConstants.CENTER); jLabelDescription1.setHorizontalTextPosition(SwingConstants.CENTER); jLabelDescription1.setForeground(Color.black); jLabelHeart3 = new JLabel(); jLabelHeart3.setBounds(new Rectangle(611, 61, 45, 39)); jLabelHeart3.setIcon(new ImageIcon(getClass().getResource("/HealthOK/ui/images/heartshape.png"))); jLabelHeart3.setText(""); jLabelHeart2 = new JLabel(); jLabelHeart2.setBounds(new Rectangle(546, 61, 43, 40)); jLabelHeart2.setIcon(new ImageIcon(getClass().getResource("/HealthOK/ui/images/heartshape.png"))); jLabelHeart2.setText(""); jLabelHeart1 = new JLabel(); jLabelHeart1.setBounds(new Rectangle(482, 60, 44, 41)); jLabelHeart1.setIcon(new ImageIcon(getClass().getResource("/HealthOK/ui/images/heartshape.png"))); jLabelHeart1.setText(""); jLabelScore = new JLabel(); jLabelScore.setBounds(new Rectangle(25, 438, 83, 29)); jLabelScore.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); jLabelScore.setForeground(Color.black); jLabelScore.setText(" Score:"); jLabelQuestion = new JLabel(); jLabelQuestion.setBounds(new Rectangle(71, 95, 618, 52)); jLabelQuestion.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); jLabelQuestion.setForeground(Color.black); this.setSize(712, 500); this.setLayout(null); this.setBackground(Color.white); this.add(jLabelQuestion, null); this.add(jLabelScore, null); this.add(jLabelHeart1, null); this.add(jLabelHeart2, null); this.add(jLabelHeart3, null); this.add(getJButtonAnswer1(), null); this.add(getJButtonAnswer2(), null); this.add(getJButtonAnswer3(), null); this.add(jLabelDescription1, null); this.add(jLabelDescription2, null); this.add(jLabelDescription3, null); this.add(getJButtonAdd(), null); this.add(jLabelTimer, null); this.add(jLabelScore1, null); this.add(jLabelQn, null); this.add(getJButtonEdit(), null); qn_num = 1; GameQuestion g1 = new GameQuestion(qn_num); g1.retrieveGameQuestion(); jLabelQn.setText("Q1."); jLabelQuestion.setText(g1.getG_question()); jLabelDescription1.setText(g1.getG_imageDescription1()); jLabelDescription2.setText(g1.getG_imageDescription2()); jLabelDescription3.setText(g1.getG_imageDescription3()); jButtonAnswer1.setIcon(new ImageIcon(g1.getG_image1())); jButtonAnswer2.setIcon(new ImageIcon(g1.getG_image2())); jButtonAnswer3.setIcon(new ImageIcon(g1.getG_image3())); } /** * This method initialises jButtonAnswer1 * * @return javax.swing.JButton */ private JButton getJButtonAnswer1() { if (jButtonAnswer1 == null) { jButtonAnswer1 = new JButton(); jButtonAnswer1.setBackground(Color.white); jButtonAnswer1.setSize(new Dimension(228, 214)); jButtonAnswer1.setLocation(new Point(5, 164)); jButtonAnswer1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { answer = "1"; DisplayQuestion(); } }); } return jButtonAnswer1; } /** * This method initialises jButtonAnswer2 * * @return javax.swing.JButton */ private JButton getJButtonAnswer2() { if (jButtonAnswer2 == null) { jButtonAnswer2 = new JButton(); jButtonAnswer2.setBackground(Color.white); jButtonAnswer2.setSize(new Dimension(228, 214)); jButtonAnswer2.setLocation(new Point(240, 164)); jButtonAnswer2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { answer = "2"; DisplayQuestion(); } }); } return jButtonAnswer2; } /** * This method initialises jButtonAnswer3 * * @return javax.swing.JButton */ private JButton getJButtonAnswer3() { if (jButtonAnswer3 == null) { jButtonAnswer3 = new JButton(); jButtonAnswer3.setBackground(Color.white); jButtonAnswer3.setSize(new Dimension(228, 214)); jButtonAnswer3.setLocation(new Point(474, 163)); jButtonAnswer3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { answer = "3"; DisplayQuestion(); } }); } return jButtonAnswer3; } /** * This method initializes jButtonEdit * * @return javax.swing.JButton */ private JButton getJButtonAdd() { if (jButtonAdd == null) { jButtonAdd = new JButton(); jButtonAdd.setBounds(new Rectangle(591, 9, 90, 39)); jButtonAdd.setFont(new Font("Dialog", Font.BOLD, 16)); jButtonAdd.setText("Add"); jButtonAdd.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { t.stop(); JPanel panel = new GamesCreatePanel(myFrame); myFrame.getContentPane().removeAll(); myFrame.getContentPane().add(panel); myFrame.getContentPane().validate(); myFrame.getContentPane().repaint(); Object admin = null; if(getName() == admin) { jButtonAdd.setVisible(true); } else { jButtonAdd.setVisible(false); } } }); } return jButtonAdd; } /** * This method initializes jButtonEdit * * @return javax.swing.JButton */ private JButton getJButtonEdit() { if (jButtonEdit == null) { jButtonEdit = new JButton(); jButtonEdit.setPreferredSize(new Dimension(65, 31)); jButtonEdit.setSize(new Dimension(90, 39)); jButtonEdit.setText("Edit"); jButtonEdit.setFont(new Font("Dialog", Font.BOLD, 16)); jButtonEdit.setLocation(new Point(492, 9)); jButtonEdit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { t.stop(); JPanel panel = new GamesEditPanel(myFrame); myFrame.getContentPane().removeAll(); myFrame.getContentPane().add(panel); myFrame.getContentPane().validate(); myFrame.getContentPane().repaint(); } }); } return jButtonEdit; } public void DisplayQuestion(){ GameQuestion g1 = new GameQuestion(); g1.retrieveGameQuestion(); if(jButtonAnswer1.isSelected() && (g1.getG_correctAnswer() == 1)&& (jButtonAnswer2.isSelected()) && (g1.getG_correctAnswer() == 2) && (jButtonAnswer3.isSelected()) && (g1.getG_correctAnswer()==3)) jLabelQn.setText("Q" + "."); jLabelQuestion.setText(g1.getG_question()); jLabelDescription1.setText(g1.getG_imageDescription1()); jLabelDescription2.setText(g1.getG_imageDescription2()); jLabelDescription3.setText(g1.getG_imageDescription3()); jButtonAnswer1.setIcon(new ImageIcon(g1.getG_image1())); jButtonAnswer2.setIcon(new ImageIcon(g1.getG_image2())); jButtonAnswer3.setIcon(new ImageIcon(g1.getG_image3())); } }
here is the error message:
connection is jdbc:odbc:CFDatabase
DB Query: SELECT * FROM GameQuestion WHERE g_questionNo =1
Connection is closed
connection is jdbc:odbc:CFDatabase
DB Query: SELECT * FROM GameQuestion WHERE g_questionNo =0
Connection is closed
Uncaught error fetching image:
java.lang.NullPointerException
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.awt.image.FileImageSource.getDecoder(Unknown Source)
at sun.awt.image.InputStreamImageSource.doFetch(Unkno wn Source)
at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
at sun.awt.image.ImageFetcher.run(Unknown Source)
- 02-04-2012, 03:38 PM #2
Re: Uncaught error fetching image eror
Is that all of the error message? It doesn't have any lines that refer to where in your program the exception occurred.
- 02-04-2012, 06:40 PM #3
Member
- Join Date
- Jan 2012
- Posts
- 48
- Rep Power
- 0
Re: Uncaught error fetching image eror
Its okay, I'ver solved it! ThankYou for your time and help! :D
- 02-10-2012, 07:34 PM #4
Member
- Join Date
- Feb 2012
- Posts
- 1
- Rep Power
- 0
Re: Uncaught error fetching image eror
Post your solution for the benefit of others with the same issue!
- 02-10-2012, 09:06 PM #5
Similar Threads
-
Uncaught error. What's this? (big headache!)
By mathidioticz in forum New To JavaReplies: 8Last Post: 02-04-2012, 06:41 PM -
Uncaught error fetching image
By Manfizy in forum New To JavaReplies: 9Last Post: 12-03-2011, 04:16 PM -
Uncaught error fetching image
By dyelax in forum New To JavaReplies: 8Last Post: 03-21-2011, 12:06 AM -
catching uncaught exceptions using Spring / WebApp
By taille50 in forum Web FrameworksReplies: 1Last Post: 10-18-2009, 01:14 AM -
Do uncaught errors appear in the PrintStream?
By arnab321 in forum New To JavaReplies: 1Last Post: 02-26-2009, 08:56 AM


LinkBack URL
About LinkBacks


Bookmarks