Results 1 to 2 of 2
  1. #1

    Member Since
    Aug 15, 2011
    Early 2011 13 inch MacBook Pro i5 with 8gb of Ram
    Pictures on Simple Java GUI won't work.
    Ok so here's my code:

    import java.awt.FlowLayout;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JFrame;
    import javax.swing.JButton;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;

    public class Gui extends JFrame{

    private JButton reg;
    private JButton custom;

    public Gui(){
    super("The title");
    setLayout(new FlowLayout());

    reg = new JButton("reg Button");

    Icon b = new ImageIcon(getClass().getResource("b.png"));
    Icon x = new ImageIcon(getClass().getResource("x.png"));
    custom = new JButton("Custom", b);

    HandlerClass handler = new HandlerClass();

    private class HandlerClass implements ActionListener{
    public void actionPerformed(ActionEvent event) {
    JOptionPane.showMessageDialog(null, String.format("%s", event.getActionCommand()));



    Main Class:

    import javax.swing.JFrame;
    class apples{
    public static void main(String[] args){

    Gui go = new Gui();


    When I run it, the .png's don't show.

  2. #2

    Member Since
    Aug 15, 2011
    Early 2011 13 inch MacBook Pro i5 with 8gb of Ram
    We'll after using a picture off the internet instead of one i made in photoshop, it worked.

    Topic Closed

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. simple setup that just won't work
    By kitfer in forum Internet, Networking, and Wireless
    Replies: 1
    Last Post: 07-05-2015, 01:19 PM
  2. best GUI option for my simple needs?
    By cowboytaketwo in forum OS X - Development and Darwin
    Replies: 3
    Last Post: 12-10-2011, 09:03 PM
  3. A simple example for calling an existing java code from c using jni?
    By missshirin in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 10-14-2010, 05:00 PM
  4. Replies: 10
    Last Post: 05-25-2009, 09:57 PM
  5. AN ultra simple Java app develpoment studio?
    By indykid in forum Web Design and Hosting
    Replies: 0
    Last Post: 07-04-2005, 04:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts