13 Replies Latest reply: Aug 19, 2007 8:10 PM by 807600 RSS

    How  images in array?

    807600
      Without using Jar files, could someone please tell me how I can take a normal gif image, and place it in an array and compile it with "in" the .java file.

      So when the .java file is compiled, the gif image is compiled too and the when the .class is run it will NOT look for the image since it is within the .class in an array.


      Also, please could you tell me how I can make .java file NOT .class but .exe

      thank you
        • 1. Re: How  images in array?
          807600
          why not use a jar file?
          • 2. Re: How  images in array?
            807600
            Neither Jar files or Class files are the point.

            The question is how to imped a gif image within a .java file.
            Allowing the image and its content to be compiled with the .java is compiled.

            So when the .class is run, the .class will NOT look for the gif file. It will NOT seek a URL or a path. The gif image will be withint the .class file.

            thank you
            • 3. Re: How  images in array?
              807600
              Another good place for me to use my "no homework" code ... demonstrates your point:
              import javax.swing.*;
              import java.awt.event.ActionListener;
              import java.awt.event.ActionEvent;
              
              public class Homework extends JFrame {
              
                   private JLabel imageLabel;
                   private byte[] image = { 71, 73, 70, 56, 55, 97, 48, 0, 48, 0, -58, 0, 0, 0, 0, 0, 111, 62, 0,
                                   37, 20, 0, -118, 77, 0, -87, -87, -87, 119, 67, 1, 81, 45, 0, -95, -95,
                                   -95, -97, -97, -97, -99, -99, -99, -103, -103, -103, 51, 28, 0, -109,
                                   -109, -109, 41, 23, 0, -117, -117, -117, 78, 63, 46, -125, -125, -125,
                                   121, 121, 121, 65, 36, 0, 113, 113, 113, 109, 109, 109, 107, 107, 107,
                                   127, 124, 120, 109, 61, 0, 99, 99, 99, 97, 97, 97, -123, 127, 119, 87,
                                   87, 87, 101, 88, 71, 22, 12, 0, 81, 81, 81, 77, 77, 77, 81, 48, 5, 123,
                                   69, 0, 69, 69, 69, -10, -10, -10, 67, 67, 67, -14, -14, -14, -18, -18,
                                   -18, 59, 59, 59, -20, -20, -20, 9, 5, 0, -22, -22, -22, -26, -26, -26,
                                   36, 20, 0, 51, 51, 51, -28, -28, -28, -38, -38, -38, 80, 45, 0, 6, 3,
                                   0, 117, 65, 0, 107, 60, 0, -46, -46, -46, -50, -50, -50, 27, 27, 27,
                                   -52, -52, -52, -56, -56, -56, -58, -58, -58, 93, 56, 9, 13, 13, 13, -68,
                                   -68, -68, 94, 53, 0, -125, 73, 0, -74, -74, -74, -80, -80, -80, -82, -82,
                                   -82, -84, -84, -84, 17, 9, 0, -90, -90, -90, 7, 4, 0, 44, 24, 0, 68, 55,
                                   40, -102, -102, -102, -108, -108, -108, -110, -110, -110, 91, 73, 49,
                                   -116, -116, -116, -118, -118, -118, -120, -120, -120, -122, -122, -122,
                                   58, 32, 0, 85, 47, 0, -128, -128, -128, 124, 124, 124, 102, 57, 0, 116,
                                   116, 116, 55, 30, 0, 89, 63, 30, 69, 41, 7, 92, 57, 13, 99, 55, 0, 96,
                                   96, 96, 15, 8, 0, 94, 94, 94, -125, -127, 127, 116, 65, 0, 32, 18, 0,
                                   86, 86, 86, 42, 33, 23, -1, -1, -1, 86, 48, 0, 105, 93, 78, -11, -11,
                                   -11, 62, 62, 62, 54, 54, 54, -27, -27, -27, -35, -35, -35, 53, 29, 0,
                                   40, 40, 40, -39, -39, -39, 43, 24, 0, -41, -41, -41, -43, -43, -43, 30,
                                   30, 30, -49, -49, -49, 87, 49, 0, -55, -55, -55, 40, 22, 0, -65, -65, -65,
                                   -69, -69, -69, -71, -71, -71, -77, -77, -77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                   0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 48, 0, 48, 0, 0, 7, -2, -128, 99,
                                   -126, -125, -124, -123, -122, -122, 116, 0, 0, 65, -121, -115, -114, -113,
                                   -113, -119, -117, -112, -108, -114, 10, 79, 66, -121, 68, 79, 16, 17, 17,
                                   112, -114, 120, 79, 76, -107, -121, 108, 0, 30, -121, 36, 0, 104, -108,
                                   21, 0, 59, -91, -122, -89, -87, -122, -85, -83, -112, -81, -79, -78, 99,
                                   68, 59, 59, 53, 37, 35, -86, -84, -82, -80, -68, 99, 7, -118, 111, -114,
                                   -73, -58, -69, -78, -54, 0, -52, -115, 74, 21, 85, 73, 73, 106, -114, 4,
                                   21, 20, -39, 55, -91, -46, -44, -114, -110, -116, -113, 37, -118, 79, -30,
                                   -53, -112, -26, -112, -23, 0, -21, -107, 102, 46, 46, 39, 54, 24, -121, 27,
                                   54, 34, -10, -61, -24, -44, 33, -93, 69, 12, 23, -91, 120, -13, 100, 17, 52,
                                   -28, -92, -117, 20, 74, 116, 14, 36, -24, -46, 37, -49, 64, 84, -56, 10,
                                   -23, -54, 40, 104, 33, -57, 49, 27, 121, 1, 97, -61, -26, -50, 27, 23, -121,
                                   50, -112, 36, 121, -57, 81, -56, 104, -19, 26, -83, 82, 52, -87, -47, -53, 82,
                                   118, 60, 120, 64, 16, 4, 7, 33, 21, 65, -126, 60, 48, 66, -44, -120, -122, 32,
                                   45, 13, 33, -15, 16, 38, 104, -101, -117, -75, 4, -15, 80, 68, 101, -128, -43,
                                   1, 70, 0, -80, 113, -124, 16, 42, -95, -87, 0, -86, 94, -51, -70, -75, 81, 87,
                                   94, 52, -24, -68, 16, -76, 5, -51, -87, -80, -2, 87, -79, 106, 61, -28, 0, -51,
                                   25, 58, 116, -46, 124, 20, -124, -122, 38, -36, -79, 115, 13, -35, -52, -88,
                                   -126, 7, -113, 35, 44, 18, -77, -120, 66, -91, 49, 21, 48, 0, -30, 24, 94, 65,
                                   72, 9, -119, 15, 123, -57, 4, 81, 116, 33, 46, 11, -65, -96, 15, 100, 62, -76,
                                   25, 64, -25, -85, -97, 65, -45, 20, 61, -70, 80, -23, -45, 86, 3, 56, 118, 76,
                                   70, 17, -21, -42, -125, 94, -57, -35, 109, -11, -117, -19, -52, 114, -24, 108,
                                   27, -109, -74, -119, 34, 50, 23, 100, -16, -66, -22, 27, -64, 109, -114, 54, 0,
                                   116, -23, -88, -102, -59, -14, -34, -65, -9, 70, -97, 62, -26, -83, 95, -21,
                                   -41, -101, 63, -105, -11, 67, -89, -114, 30, 87, 116, 102, -23, -63, -66, -67,
                                   -127, -94, -16, -119, 10, 80, -44, -62, -125, 62, 94, 73, 20, -123, 24, 48, 71,
                                   -47, 23, -34, 84, -88, 38, 32, 0, 54, 80, -126, -62, 27, 8, -66, 49, -123, 126,
                                   -4, -7, -57, -37, 12, 29, 68, -40, -63, 16, -118, 112, 33, -95, -124, 98, 32, 104,
                                   -126, 35, 79, 8, -72, 95, 127, 0, -4, 119, -99, 85, 23, 40, -46, 3, 111, 33, 40,
                                   -110, 4, -121, 30, 54, 24, -30, -120, 36, -102, -120, -94, -118, -121, 80, -76,
                                   -60, 28, 56, -26, 56, -121, 21, 11, 64, 6, -128, 27, 11, 4, 41, -28, -112, 11, -44,
                                   33, -29, 110, 41, -78, -68, 66, 17, 69, 22, -115, -95, -120, 4, -53, 113, 49, -32,
                                   -108, 71, -58, -107, 36, 104, -13, 60, 25, 37, 0, 49, 112, -31, -27, -105, 96, -122,
                                   -23, -91, 22, 51, 2, -112, 2, -104, 22, -40, -93, 37, 111, 82, 46, 0, -29, -101,
                                   87, 37, 9, 67, 92, 18, -8, 5, 37, -101, 0, -72, 9, -25, -101, 114, -46, -87, 98,
                                   18, 101, 64, 33, -24, -96, 80, -60, -112, -25, -98, 124, 42, 50, -25, 85, 117, 2,
                                   32, 72, -121, 3, -22, -119, -24, 117, 125, 50, -86, 72, 9, 37, 120, 81, -60, -90,
                                   -100, 114, -70, -122, 15, -96, -122, 42, -22, -88, -92, -122, 90, -64, 47, 32, -120,
                                   -118, -59, 47, 107, 46, 7, 34, -107, -80, 18, 40, -56, 43, 52, 101, 9, -64, -99, -82,
                                   -58, 26, 107, -127, 32, -7, 53, -49, 19, 79, 112, 32, -63, -80, -60, 18, -37, -128,
                                   34, 19, 0, -85, -20, -78, -52, 54, -5, 4, 3, -126, -120, -94, 108, 14, -124, 64, 74,
                                   37, 57, -72, 25, 98, -19, -108, -40, 102, 43, 72, 32, 0, 59 };
                   private JButton button;
              
                   public Homework() {
              
                        imageLabel = new JLabel(new ImageIcon(image));
                        imageLabel.setText("You fucking piece of shit!");
                        imageLabel.setVisible(false);
              
                        button = new JButton("Do Homework");
              
                        this.getContentPane().setLayout(new java.awt.FlowLayout());
                        this.getContentPane().add(imageLabel);
                        this.getContentPane().add(button);
                        this.pack();
                        this.setSize(400, 100);
                        this.setLocationRelativeTo(null);
                        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
                        this.setTitle("Homework Do-er");
              
                        button.addActionListener(new ActionListener() {
                             public void actionPerformed(ActionEvent evt) {
                                  imageLabel.setVisible(true);
                                  setTitle("You're a fucking idiot!");
                                  button.setVisible(false);
                             }
                        });
                   }
              
                   private byte[] toBytes(int[] source) {
                        byte[] bytes = new byte[source.length];
                        for( int i = 0; i < source.length; i++ ) {
                             bytes[i] = (byte)source;
                        }

                        return bytes;
                   }

                   public static void main(String[] argv) {
                        new Homework().setVisible(true);
                   }
              }
              • 4. Re: How  images in array?
                807600
                Oh, and don't take that personally. The program was written for some asshat who asked to have someone do their homework for them. This just shows how "embed" an image into a "class."
                • 5. Re: How  images in array?
                  807600
                  thank you.
                  That is what I was looking for.
                  I knew the idea, but it had been a long time.

                  Thank you
                  • 6. Re: How  images in array?
                    807600
                    Navy, that code is absolutely beautiful. I almost cried. If I may be forward enough add small changes for obfuscation purposes:

                    add these
                        private byte[] yfpos = 
                        {
                                0x59, 0x6f, 0x75, 0x20, 0x66, 0x75, 0x63, 0x6b, 0x69, 0x6e, 0x67,
                                0x20, 0x70, 0x69, 0x65, 0x63, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x73,
                                0x68, 0x69, 0x74, 0x21
                        };
                        private byte[] yafi =
                        {
                                0x59, 0x6f, 0x75, 0x27, 0x72, 0x65, 0x20, 0x61, 0x20, 0x66, 0x75,
                                0x63, 0x6b, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x69, 0x6f, 0x74,
                                0x21
                        };
                    change this
                         imageLabel.setText("You fucking piece of shit!");
                    to this
                            imageLabel.setText(new String(yfpos));
                    and this
                              setTitle("You're a fucking idiot!");
                    to this
                                    setTitle(new String(yafi));
                    • 7. Re: How  images in array?
                      807600
                      Navy, that code is absolutely beautiful. I almost
                      cried. If I may be forward enough add small changes
                      for obfuscation purposes:

                      add these
                      private byte[] yfpos = 
                      {
                      0x59, 0x6f, 0x75, 0x20, 0x66, 0x75, 0x63,
                      0x6b, 0x69, 0x6e, 0x67,
                      0x20, 0x70, 0x69, 0x65, 0x63, 0x65, 0x20,
                      0x6f, 0x66, 0x20, 0x73,
                      0x68, 0x69, 0x74, 0x21
                      private byte[] yafi =
                      {
                      0x59, 0x6f, 0x75, 0x27, 0x72, 0x65, 0x20,
                      0x61, 0x20, 0x66, 0x75,
                      0x63, 0x6b, 0x69, 0x6e, 0x67, 0x20, 0x69,
                      0x64, 0x69, 0x6f, 0x74,
                      0x21
                      ode]
                      change this 
                           imageLabel.setText("You fucking piece of shit!");
                      to this
                      imageLabel.setText(new String(yfpos));
                      
                      and this
                                setTitle("You're a fucking idiot!");

                      to this
                      setTitle(new String(yafi));
                      I accept your substitutions and hereby extend my whole-hearted gratitude for your assistance in the bettering of this software.

                      @everyone: Any further improvements are warmly welcomed!!

                      Thanks, Pete!!
                      • 8. Re: How  images in array?
                        807600
                        Incorporating Pete's improvements:
                        import javax.swing.*;
                        import java.awt.event.ActionListener;
                        import java.awt.event.ActionEvent;
                        
                        public class Homework extends JFrame {
                        
                             private JLabel imageLabel;
                             private byte[] image = { 71, 73, 70, 56, 55, 97, 48, 0, 48, 0, -58, 0, 0, 0, 0, 0, 111, 62, 0,
                                             37, 20, 0, -118, 77, 0, -87, -87, -87, 119, 67, 1, 81, 45, 0, -95, -95,
                                             -95, -97, -97, -97, -99, -99, -99, -103, -103, -103, 51, 28, 0, -109,
                                             -109, -109, 41, 23, 0, -117, -117, -117, 78, 63, 46, -125, -125, -125,
                                             121, 121, 121, 65, 36, 0, 113, 113, 113, 109, 109, 109, 107, 107, 107,
                                             127, 124, 120, 109, 61, 0, 99, 99, 99, 97, 97, 97, -123, 127, 119, 87,
                                             87, 87, 101, 88, 71, 22, 12, 0, 81, 81, 81, 77, 77, 77, 81, 48, 5, 123,
                                             69, 0, 69, 69, 69, -10, -10, -10, 67, 67, 67, -14, -14, -14, -18, -18,
                                             -18, 59, 59, 59, -20, -20, -20, 9, 5, 0, -22, -22, -22, -26, -26, -26,
                                             36, 20, 0, 51, 51, 51, -28, -28, -28, -38, -38, -38, 80, 45, 0, 6, 3,
                                             0, 117, 65, 0, 107, 60, 0, -46, -46, -46, -50, -50, -50, 27, 27, 27,
                                             -52, -52, -52, -56, -56, -56, -58, -58, -58, 93, 56, 9, 13, 13, 13, -68,
                                             -68, -68, 94, 53, 0, -125, 73, 0, -74, -74, -74, -80, -80, -80, -82, -82,
                                             -82, -84, -84, -84, 17, 9, 0, -90, -90, -90, 7, 4, 0, 44, 24, 0, 68, 55,
                                             40, -102, -102, -102, -108, -108, -108, -110, -110, -110, 91, 73, 49,
                                             -116, -116, -116, -118, -118, -118, -120, -120, -120, -122, -122, -122,
                                             58, 32, 0, 85, 47, 0, -128, -128, -128, 124, 124, 124, 102, 57, 0, 116,
                                             116, 116, 55, 30, 0, 89, 63, 30, 69, 41, 7, 92, 57, 13, 99, 55, 0, 96,
                                             96, 96, 15, 8, 0, 94, 94, 94, -125, -127, 127, 116, 65, 0, 32, 18, 0,
                                             86, 86, 86, 42, 33, 23, -1, -1, -1, 86, 48, 0, 105, 93, 78, -11, -11,
                                             -11, 62, 62, 62, 54, 54, 54, -27, -27, -27, -35, -35, -35, 53, 29, 0,
                                             40, 40, 40, -39, -39, -39, 43, 24, 0, -41, -41, -41, -43, -43, -43, 30,
                                             30, 30, -49, -49, -49, 87, 49, 0, -55, -55, -55, 40, 22, 0, -65, -65, -65,
                                             -69, -69, -69, -71, -71, -71, -77, -77, -77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                             0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 48, 0, 48, 0, 0, 7, -2, -128, 99,
                                             -126, -125, -124, -123, -122, -122, 116, 0, 0, 65, -121, -115, -114, -113,
                                             -113, -119, -117, -112, -108, -114, 10, 79, 66, -121, 68, 79, 16, 17, 17,
                                             112, -114, 120, 79, 76, -107, -121, 108, 0, 30, -121, 36, 0, 104, -108,
                                             21, 0, 59, -91, -122, -89, -87, -122, -85, -83, -112, -81, -79, -78, 99,
                                             68, 59, 59, 53, 37, 35, -86, -84, -82, -80, -68, 99, 7, -118, 111, -114,
                                             -73, -58, -69, -78, -54, 0, -52, -115, 74, 21, 85, 73, 73, 106, -114, 4,
                                             21, 20, -39, 55, -91, -46, -44, -114, -110, -116, -113, 37, -118, 79, -30,
                                             -53, -112, -26, -112, -23, 0, -21, -107, 102, 46, 46, 39, 54, 24, -121, 27,
                                             54, 34, -10, -61, -24, -44, 33, -93, 69, 12, 23, -91, 120, -13, 100, 17, 52,
                                             -28, -92, -117, 20, 74, 116, 14, 36, -24, -46, 37, -49, 64, 84, -56, 10,
                                             -23, -54, 40, 104, 33, -57, 49, 27, 121, 1, 97, -61, -26, -50, 27, 23, -121,
                                             50, -112, 36, 121, -57, 81, -56, 104, -19, 26, -83, 82, 52, -87, -47, -53, 82,
                                             118, 60, 120, 64, 16, 4, 7, 33, 21, 65, -126, 60, 48, 66, -44, -120, -122, 32,
                                             45, 13, 33, -15, 16, 38, 104, -101, -117, -75, 4, -15, 80, 68, 101, -128, -43,
                                             1, 70, 0, -80, 113, -124, 16, 42, -95, -87, 0, -86, 94, -51, -70, -75, 81, 87,
                                             94, 52, -24, -68, 16, -76, 5, -51, -87, -80, -2, 87, -79, 106, 61, -28, 0, -51,
                                             25, 58, 116, -46, 124, 20, -124, -122, 38, -36, -79, 115, 13, -35, -52, -88,
                                             -126, 7, -113, 35, 44, 18, -77, -120, 66, -91, 49, 21, 48, 0, -30, 24, 94, 65,
                                             72, 9, -119, 15, 123, -57, 4, 81, 116, 33, 46, 11, -65, -96, 15, 100, 62, -76,
                                             25, 64, -25, -85, -97, 65, -45, 20, 61, -70, 80, -23, -45, 86, 3, 56, 118, 76,
                                             70, 17, -21, -42, -125, 94, -57, -35, 109, -11, -117, -19, -52, 114, -24, 108,
                                             27, -109, -74, -119, 34, 50, 23, 100, -16, -66, -22, 27, -64, 109, -114, 54, 0,
                                             116, -23, -88, -102, -59, -14, -34, -65, -9, 70, -97, 62, -26, -83, 95, -21,
                                             -41, -101, 63, -105, -11, 67, -89, -114, 30, 87, 116, 102, -23, -63, -66, -67,
                                             -127, -94, -16, -119, 10, 80, -44, -62, -125, 62, 94, 73, 20, -123, 24, 48, 71,
                                             -47, 23, -34, 84, -88, 38, 32, 0, 54, 80, -126, -62, 27, 8, -66, 49, -123, 126,
                                             -4, -7, -57, -37, 12, 29, 68, -40, -63, 16, -118, 112, 33, -95, -124, 98, 32, 104,
                                             -126, 35, 79, 8, -72, 95, 127, 0, -4, 119, -99, 85, 23, 40, -46, 3, 111, 33, 40,
                                             -110, 4, -121, 30, 54, 24, -30, -120, 36, -102, -120, -94, -118, -121, 80, -76,
                                             -60, 28, 56, -26, 56, -121, 21, 11, 64, 6, -128, 27, 11, 4, 41, -28, -112, 11, -44,
                                             33, -29, 110, 41, -78, -68, 66, 17, 69, 22, -115, -95, -120, 4, -53, 113, 49, -32,
                                             -108, 71, -58, -107, 36, 104, -13, 60, 25, 37, 0, 49, 112, -31, -27, -105, 96, -122,
                                             -23, -91, 22, 51, 2, -112, 2, -104, 22, -40, -93, 37, 111, 82, 46, 0, -29, -101,
                                             87, 37, 9, 67, 92, 18, -8, 5, 37, -101, 0, -72, 9, -25, -101, 114, -46, -87, 98,
                                             18, 101, 64, 33, -24, -96, 80, -60, -112, -25, -98, 124, 42, 50, -25, 85, 117, 2,
                                             32, 72, -121, 3, -22, -119, -24, 117, 125, 50, -86, 72, 9, 37, 120, 81, -60, -90,
                                             -100, 114, -70, -122, 15, -96, -122, 42, -22, -88, -92, -122, 90, -64, 47, 32, -120,
                                             -118, -59, 47, 107, 46, 7, 34, -107, -80, 18, 40, -56, 43, 52, 101, 9, -64, -99, -82,
                                             -58, 26, 107, -127, 32, -7, 53, -49, 19, 79, 112, 32, -63, -80, -60, 18, -37, -128,
                                             34, 19, 0, -85, -20, -78, -52, 54, -5, 4, 3, -126, -120, -94, 108, 14, -124, 64, 74,
                                             37, 57, -72, 25, 98, -19, -108, -40, 102, 43, 72, 32, 0, 59 };
                        
                             private byte[] yfpos = {
                                    0x59, 0x6f, 0x75, 0x20, 0x66, 0x75, 0x63, 0x6b, 0x69, 0x6e, 0x67,
                                    0x20, 0x70, 0x69, 0x65, 0x63, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x73,
                                    0x68, 0x69, 0x74, 0x21
                                 };
                        
                             private byte[] yafi = {
                                    0x59, 0x6f, 0x75, 0x27, 0x72, 0x65, 0x20, 0x61, 0x20, 0x66, 0x75,
                                    0x63, 0x6b, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x69, 0x6f, 0x74,
                                    0x21
                                 };
                        
                             private JButton button;
                        
                             public Homework() {
                        
                                  imageLabel = new JLabel(new ImageIcon(image));
                                  imageLabel.setText(new String(yfpos));
                                  imageLabel.setVisible(false);
                        
                                  button = new JButton("Do Homework");
                        
                                  this.getContentPane().setLayout(new java.awt.FlowLayout());
                                  this.getContentPane().add(imageLabel);
                                  this.getContentPane().add(button);
                                  this.pack();
                                  this.setSize(400, 100);
                                  this.setLocationRelativeTo(null);
                                  this.setDefaultCloseOperation(EXIT_ON_CLOSE);
                                  this.setTitle("Homework Do-er");
                        
                                  button.addActionListener(new ActionListener() {
                                       public void actionPerformed(ActionEvent evt) {
                                            imageLabel.setVisible(true);
                                            setTitle(new String(yafi));
                                            button.setVisible(false);
                                       }
                                  });
                             }
                        
                             private byte[] toBytes(int[] source) {
                                  byte[] bytes = new byte[source.length];
                                  for( int i = 0; i < source.length; i++ ) {
                                       bytes[i] = (byte)source;
                                  }

                                  return bytes;
                             }

                             public static void main(String[] argv) {
                                  new Homework().setVisible(true);
                             }
                        }
                        • 9. Re: How  images in array?
                          DarrylBurke
                          Hey Navy

                          Why not get rid of the last giveaway text -- "Do Homework" and "Homework Do-er" -- the same way !?!

                          Might actually get submitted to some unsuspecting prof.

                          :D
                          • 10. Re: How  images in array?
                            807600
                            Hey Navy

                            Why not get rid of the last giveaway text -- "Do
                            Homework" and "Homework Do-er" -- the same way !?!

                            Might actually get submitted to some unsuspecting
                            prof.

                            :D
                            Hmmm ... good suggestion. Give me a few minutes...
                            • 11. Re: How  images in array?
                              807600
                              Latest iteration:
                              import javax.swing.*;
                              import java.awt.event.ActionListener;
                              import java.awt.event.ActionEvent;
                              
                              public class Homework extends JFrame {
                              
                                   private JLabel imageLabel;
                                   private byte[] image = { 71, 73, 70, 56, 55, 97, 48, 0, 48, 0, -58, 0, 0, 0, 0, 0, 111, 62, 0,
                                                   37, 20, 0, -118, 77, 0, -87, -87, -87, 119, 67, 1, 81, 45, 0, -95, -95,
                                                   -95, -97, -97, -97, -99, -99, -99, -103, -103, -103, 51, 28, 0, -109,
                                                   -109, -109, 41, 23, 0, -117, -117, -117, 78, 63, 46, -125, -125, -125,
                                                   121, 121, 121, 65, 36, 0, 113, 113, 113, 109, 109, 109, 107, 107, 107,
                                                   127, 124, 120, 109, 61, 0, 99, 99, 99, 97, 97, 97, -123, 127, 119, 87,
                                                   87, 87, 101, 88, 71, 22, 12, 0, 81, 81, 81, 77, 77, 77, 81, 48, 5, 123,
                                                   69, 0, 69, 69, 69, -10, -10, -10, 67, 67, 67, -14, -14, -14, -18, -18,
                                                   -18, 59, 59, 59, -20, -20, -20, 9, 5, 0, -22, -22, -22, -26, -26, -26,
                                                   36, 20, 0, 51, 51, 51, -28, -28, -28, -38, -38, -38, 80, 45, 0, 6, 3,
                                                   0, 117, 65, 0, 107, 60, 0, -46, -46, -46, -50, -50, -50, 27, 27, 27,
                                                   -52, -52, -52, -56, -56, -56, -58, -58, -58, 93, 56, 9, 13, 13, 13, -68,
                                                   -68, -68, 94, 53, 0, -125, 73, 0, -74, -74, -74, -80, -80, -80, -82, -82,
                                                   -82, -84, -84, -84, 17, 9, 0, -90, -90, -90, 7, 4, 0, 44, 24, 0, 68, 55,
                                                   40, -102, -102, -102, -108, -108, -108, -110, -110, -110, 91, 73, 49,
                                                   -116, -116, -116, -118, -118, -118, -120, -120, -120, -122, -122, -122,
                                                   58, 32, 0, 85, 47, 0, -128, -128, -128, 124, 124, 124, 102, 57, 0, 116,
                                                   116, 116, 55, 30, 0, 89, 63, 30, 69, 41, 7, 92, 57, 13, 99, 55, 0, 96,
                                                   96, 96, 15, 8, 0, 94, 94, 94, -125, -127, 127, 116, 65, 0, 32, 18, 0,
                                                   86, 86, 86, 42, 33, 23, -1, -1, -1, 86, 48, 0, 105, 93, 78, -11, -11,
                                                   -11, 62, 62, 62, 54, 54, 54, -27, -27, -27, -35, -35, -35, 53, 29, 0,
                                                   40, 40, 40, -39, -39, -39, 43, 24, 0, -41, -41, -41, -43, -43, -43, 30,
                                                   30, 30, -49, -49, -49, 87, 49, 0, -55, -55, -55, 40, 22, 0, -65, -65, -65,
                                                   -69, -69, -69, -71, -71, -71, -77, -77, -77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                   0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 48, 0, 48, 0, 0, 7, -2, -128, 99,
                                                   -126, -125, -124, -123, -122, -122, 116, 0, 0, 65, -121, -115, -114, -113,
                                                   -113, -119, -117, -112, -108, -114, 10, 79, 66, -121, 68, 79, 16, 17, 17,
                                                   112, -114, 120, 79, 76, -107, -121, 108, 0, 30, -121, 36, 0, 104, -108,
                                                   21, 0, 59, -91, -122, -89, -87, -122, -85, -83, -112, -81, -79, -78, 99,
                                                   68, 59, 59, 53, 37, 35, -86, -84, -82, -80, -68, 99, 7, -118, 111, -114,
                                                   -73, -58, -69, -78, -54, 0, -52, -115, 74, 21, 85, 73, 73, 106, -114, 4,
                                                   21, 20, -39, 55, -91, -46, -44, -114, -110, -116, -113, 37, -118, 79, -30,
                                                   -53, -112, -26, -112, -23, 0, -21, -107, 102, 46, 46, 39, 54, 24, -121, 27,
                                                   54, 34, -10, -61, -24, -44, 33, -93, 69, 12, 23, -91, 120, -13, 100, 17, 52,
                                                   -28, -92, -117, 20, 74, 116, 14, 36, -24, -46, 37, -49, 64, 84, -56, 10,
                                                   -23, -54, 40, 104, 33, -57, 49, 27, 121, 1, 97, -61, -26, -50, 27, 23, -121,
                                                   50, -112, 36, 121, -57, 81, -56, 104, -19, 26, -83, 82, 52, -87, -47, -53, 82,
                                                   118, 60, 120, 64, 16, 4, 7, 33, 21, 65, -126, 60, 48, 66, -44, -120, -122, 32,
                                                   45, 13, 33, -15, 16, 38, 104, -101, -117, -75, 4, -15, 80, 68, 101, -128, -43,
                                                   1, 70, 0, -80, 113, -124, 16, 42, -95, -87, 0, -86, 94, -51, -70, -75, 81, 87,
                                                   94, 52, -24, -68, 16, -76, 5, -51, -87, -80, -2, 87, -79, 106, 61, -28, 0, -51,
                                                   25, 58, 116, -46, 124, 20, -124, -122, 38, -36, -79, 115, 13, -35, -52, -88,
                                                   -126, 7, -113, 35, 44, 18, -77, -120, 66, -91, 49, 21, 48, 0, -30, 24, 94, 65,
                                                   72, 9, -119, 15, 123, -57, 4, 81, 116, 33, 46, 11, -65, -96, 15, 100, 62, -76,
                                                   25, 64, -25, -85, -97, 65, -45, 20, 61, -70, 80, -23, -45, 86, 3, 56, 118, 76,
                                                   70, 17, -21, -42, -125, 94, -57, -35, 109, -11, -117, -19, -52, 114, -24, 108,
                                                   27, -109, -74, -119, 34, 50, 23, 100, -16, -66, -22, 27, -64, 109, -114, 54, 0,
                                                   116, -23, -88, -102, -59, -14, -34, -65, -9, 70, -97, 62, -26, -83, 95, -21,
                                                   -41, -101, 63, -105, -11, 67, -89, -114, 30, 87, 116, 102, -23, -63, -66, -67,
                                                   -127, -94, -16, -119, 10, 80, -44, -62, -125, 62, 94, 73, 20, -123, 24, 48, 71,
                                                   -47, 23, -34, 84, -88, 38, 32, 0, 54, 80, -126, -62, 27, 8, -66, 49, -123, 126,
                                                   -4, -7, -57, -37, 12, 29, 68, -40, -63, 16, -118, 112, 33, -95, -124, 98, 32, 104,
                                                   -126, 35, 79, 8, -72, 95, 127, 0, -4, 119, -99, 85, 23, 40, -46, 3, 111, 33, 40,
                                                   -110, 4, -121, 30, 54, 24, -30, -120, 36, -102, -120, -94, -118, -121, 80, -76,
                                                   -60, 28, 56, -26, 56, -121, 21, 11, 64, 6, -128, 27, 11, 4, 41, -28, -112, 11, -44,
                                                   33, -29, 110, 41, -78, -68, 66, 17, 69, 22, -115, -95, -120, 4, -53, 113, 49, -32,
                                                   -108, 71, -58, -107, 36, 104, -13, 60, 25, 37, 0, 49, 112, -31, -27, -105, 96, -122,
                                                   -23, -91, 22, 51, 2, -112, 2, -104, 22, -40, -93, 37, 111, 82, 46, 0, -29, -101,
                                                   87, 37, 9, 67, 92, 18, -8, 5, 37, -101, 0, -72, 9, -25, -101, 114, -46, -87, 98,
                                                   18, 101, 64, 33, -24, -96, 80, -60, -112, -25, -98, 124, 42, 50, -25, 85, 117, 2,
                                                   32, 72, -121, 3, -22, -119, -24, 117, 125, 50, -86, 72, 9, 37, 120, 81, -60, -90,
                                                   -100, 114, -70, -122, 15, -96, -122, 42, -22, -88, -92, -122, 90, -64, 47, 32, -120,
                                                   -118, -59, 47, 107, 46, 7, 34, -107, -80, 18, 40, -56, 43, 52, 101, 9, -64, -99, -82,
                                                   -58, 26, 107, -127, 32, -7, 53, -49, 19, 79, 112, 32, -63, -80, -60, 18, -37, -128,
                                                   34, 19, 0, -85, -20, -78, -52, 54, -5, 4, 3, -126, -120, -94, 108, 14, -124, 64, 74,
                                                   37, 57, -72, 25, 98, -19, -108, -40, 102, 43, 72, 32, 0, 59 };
                              
                                   private byte[] yfpos = {
                                          0x59, 0x6f, 0x75, 0x20, 0x66, 0x75, 0x63, 0x6b, 0x69, 0x6e, 0x67,
                                          0x20, 0x70, 0x69, 0x65, 0x63, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x73,
                                          0x68, 0x69, 0x74, 0x21
                                       };
                              
                                   private byte[] yafi = {
                                          0x59, 0x6f, 0x75, 0x27, 0x72, 0x65, 0x20, 0x61, 0x20, 0x66, 0x75,
                                          0x63, 0x6b, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x69, 0x6f, 0x74,
                                          0x21
                                       };
                              
                                   private byte[] title = { 72, 111, 109, 101, 119, 111, 114, 107, 32, 68, 111, 45, 69, 114 };
                                   private byte[] btnText = { 68, 111, 32, 72, 111, 109, 101, 119, 111, 114, 107 };
                              
                                   private JButton button;
                              
                                   public Homework() {
                              
                                        imageLabel = new JLabel(new ImageIcon(image));
                                        imageLabel.setText(new String(yfpos));
                                        imageLabel.setVisible(false);
                              
                                        button = new JButton(new String(btnText));
                              
                                        this.getContentPane().setLayout(new java.awt.FlowLayout());
                                        this.getContentPane().add(imageLabel);
                                        this.getContentPane().add(button);
                                        this.pack();
                                        this.setSize(400, 100);
                                        this.setLocationRelativeTo(null);
                                        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
                                        this.setTitle(new String(title));
                              
                                        button.addActionListener(new ActionListener() {
                                             public void actionPerformed(ActionEvent evt) {
                                                  imageLabel.setVisible(true);
                                                  setTitle(new String(yafi));
                                                  button.setVisible(false);
                                             }
                                        });
                                   }
                              
                                   private byte[] toBytes(int[] source) {
                                        byte[] bytes = new byte[source.length];
                                        for( int i = 0; i < source.length; i++ ) {
                                             bytes[i] = (byte)source;
                                        }

                                        return bytes;
                                   }

                                   public static void main(String[] argv) {
                                        new Homework().setVisible(true);
                                   }
                              }
                              • 12. Re: How  images in array?
                                DarrylBurke
                                Navy

                                More obfuscation, if yuo're feeling like working hard :-))

                                Put the byte array contents into long[] arrays and parse out the bytes at runtime :-)

                                And obfuscated varnames... like the noobs put up for all to decipher? I suggest x, xx, xxx, xxxx, .....

                                :D
                                • 13. Re: How  images in array?
                                  807600
                                  Navy

                                  More obfuscation, if yuo're feeling like working hard
                                  :-))

                                  Put the byte array contents into long[] arrays and
                                  parse out the bytes at runtime :-)

                                  And obfuscated varnames... like the noobs put up for
                                  all to decipher? I suggest x, xx, xxx, xxxx, .....

                                  :D
                                  Not up for it, but help yourself.