1

I need your help! I am switching to netbeans and have been having some major problems. After about 6 hours I finally figured out how to get the image to show in netbeans. Is there a way to write the code where it will work in JGrasp and netbeans?

The working code for netbeans is

menuPic = new javax.swing.JButton();
menuPic.setIcon(new javax.swing.ImageIcon(getClass().getResource("image/w2.png")));

and the working code for JGrasp is

menuPic = new JButton();
ImageIcon bottompic = new ImageIcon("image/w2.png");
JButton menuPic = new JButton(bottompic);

I hate JGrasp but thats what my teacher uses to grade, so I want to be able to write it in netbeans and copy and paste the code to JGrasp and it be able to work. Any help would be greatly appreciated!!

solved this but now i have another problem ok that worked but now my JOptionPane picture isn't loading in netbeans The code i used in JGrasp is

final ImageIcon icon1 = new ImageIcon("image/money.gif");
JOptionPane.showMessageDialog(null, " blah blah", "Text", JOptionPane.INFORMATION_MESSAGE,   icon1);

and if i wanted to show an image in JOptionPane.showInputDialog would it be the same as putting on in JOptionPane.showMessageDialog ? Thanks

Barett
  • 5,826
  • 6
  • 51
  • 55
Josh Mo
  • 137
  • 1
  • 3
  • 6

1 Answers1

3

The "NetBeans" code will work in JGrasp as long as your image files are located in the right location -- in an image subdirectory off of the directory that holds the class files. By the way, it's not NetBeans-specific code; it's nothing but Java code, pure and simple.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • thanks. if i woulda known that in the beginning i probably would have figured it out a lot sooner. I got it, thanks!! – Josh Mo Jul 01 '12 at 04:56