Seticon

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #31
    Originally posted by soty
    hi i covered the init () curly bracket and the class curly bracket. so which of the curly bracket where u asking me about?

    thanks you
    Nothing; I was misled by the stinky indentation of your code. Did you print out
    whether or not the ImageIcon could find the file?

    kind regards,

    Jos

    Comment

    • soty
      New Member
      • Mar 2008
      • 25

      #32
      Originally posted by JosAH
      Nothing; I was misled by the stinky indentation of your code. Did you print out
      whether or not the ImageIcon could find the file?

      kind regards,

      Jos
      oh ok

      uhmmm
      i dont know how to do dat.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #33
        Originally posted by soty
        oh ok

        uhmmm
        i dont know how to do dat.
        So start reading the API documentation for the ImageIcon class. There must be
        a way to figure out whether or not the icon was really loaded. One of the methods
        should be able to give you the answer.

        kind regards,

        Jos

        Comment

        • soty
          New Member
          • Mar 2008
          • 25

          #34
          Originally posted by JosAH
          So start reading the API documentation for the ImageIcon class. There must be
          a way to figure out whether or not the icon was really loaded. One of the methods
          should be able to give you the answer.

          kind regards,

          Jos

          ok once i figure it out i'll get back at u.

          thank you

          Comment

          • Navdip
            New Member
            • Mar 2008
            • 22

            #35
            Originally posted by soty
            PLEASE I NEED HELP ON THIS CODE.


            I'M TRYING TO WRITE A CODE ON VENDING MACHINE. BUT FIRST OF ALL I NEED TO PUT PICTURES ON THE BUTTONS THAT I'M USING.

            THE ThING IS I'M HAVING ERRORS WHEN USING THE SETICON. this is my code below....... (i jus want to put pictures on button before i proceed with the code.)





            import java.awt.*;
            import java.applet.*;
            import java.awt.event. ActionListener;
            import javax.swing.Ima geIcon;
            import javax.swing.JTe xtPane;


            public class vendmachine extends Applet
            {
            Color Armygreen = new Color(120, 100, 50);

            Panel panel1 = new Panel();
            Label header = new Label("WELCOME TO UJU'S VENDING MACHINE");


            Panel panel2 = new Panel();
            Button chip = new Button("Chips") ;
            Button cookie = new Button("Coookie ");
            Button walnut = new Button("Walnut" );
            Button mintGum = new Button("MintGum ");
            Button lifesaver = new Button("lifeSav er");
            Button popcorn = new Button("Popcorn ");
            Button nacho = new Button("Nacho") ;
            Button mandm = new Button("M&M");
            Button mixednut = new Button("mixed Nut");




            Panel panel3 = new Panel();
            JTextPane mytextArea = new JTextPane();



            Panel panel4 = new Panel();


            Panel panel5 = new Panel();



            public void init()
            {
            setSize(400, 420);
            setLayout(new BorderLayout()) ;


            add(panel1);
            add(panel1, BorderLayout.NO RTH);
            panel1.add(head er);
            panel1.setPrefe rredSize(new Dimension(400,5 0));
            panel1.setBackg round(Color.GRA Y);



            add(panel2);
            add(panel2, BorderLayout.WE ST);
            panel2.setPrefe rredSize(new Dimension(270 , 50));
            panel2.add(chip );
            panel2.add(cook ie);
            panel2.add(waln ut);
            panel2.add(mint Gum);
            panel2.add(life saver);
            panel2.add(popc orn);
            panel2.add(nach o);
            panel2.add(mand m);
            panel2.add(mixe dnut);
            panel2.setBackg round(Color.BLU E);



            /* add(panel3);
            add(panel3,Bord erLayout.CENTER );
            // panel3.add(myte xtArea);
            panel3.setPrefe rredSize(new Dimension(400,1 00));
            // mytextArea.setB ackground(Color .PINK);
            panel3.setBackg round(Color.CYA N);*/



            add(panel4);
            add(panel4,Bord erLayout.SOUTH) ;
            panel4.setPrefe rredSize(new Dimension(400,1 00));
            panel4.setBackg round(Color.RED );



            add(panel5);
            add(panel5,Bord erLayout.CENTER );
            panel5.setPrefe rredSize(new Dimension(400,1 00));
            panel5.setBackg round(Color.GRE EN);




            }



            public void paint(Graphics g)
            {
            //Image chips;
            //Image mintGum, nachos, cookies, lifeSaver, MandM,walnut, popcorn,mixedNu t;


            chip.SetIcon(ne w ImageIcon("chip s1.gif"));
            mintGum.SetIcon (new ImageIcon("mint Gum.gif"));
            nacho.SetIcon(n ew ImageIcon("nach os.gif"));
            cookie.SetIcon( new ImageIcon("cook ies.gif"));
            lifesaver.SetIc on(new ImageIcon("life saver.gif"));
            mandm.SetIcon(n ew ImageIcon("m_m. gif"));
            walnut.SetIcon( new ImageIcon("waln ut.gif"));
            popcorn.SetIcon (new ImageIcon("popc orn.gif"));
            mixednut.SetIco n(new ImageIcon("mixf ruit.gif"));



            // g.drawImage(chi ps, 20, 20, this);
            }


            }




            HI...you should set the images to button before adding the button objects into panel...and images must be placed in same folder in which your application is going to develop...other you must give full path of "* .gif " file to set imageIcon...you can use JButton instead of simple button object if u are aware about JApplet it'll more helpfull for u to create a windows application..ho pe best for success

            Comment

            Working...