Results 1 to 1 of 1
- 12-04-2010, 05:20 AM #1Member
- Join Date
- Oct 2010
- Rep Power
Displaying an image through an array
So, I have an image that the user has selected and altered in some way, which is then read into a 2D array (which all works fine). I essentially need to be able to use JLabel to display this image by reading the array it is provided.
Now, some explanation of my code is needed. "image" is the array in question, and I've written all the other methods to modify this array as needed, and the information will be stored. I know this works. "displayGrayscaleImage" is a method that takes the array, which was originally just a color image read into an array, and turns it into a grayscale. This also works, but I think this may be the problem. Since the image is already gray, it doesn't need to enter this method again, but I don't know how to create a method that will display the image by reading the array into my JLabel called "imageLabel".
This is in the method that creates all needed buttons, JPanels, and the JLabel in question.
JPanel JPANEL_C = new JPanel(); JPANEL_C.setBackground(Color.blue); JLabel imageLabel = new JLabel(new [B]ImageIcon(displayGrayscaleImage(image))[/B]); JPANEL_C.add(imageLabel); contentPane.add(JPANEL_C,BorderLayout.CENTER);
- By BariMutation in forum New To JavaReplies: 6Last Post: 11-12-2010, 02:23 AM
- By Samari413 in forum New To JavaReplies: 10Last Post: 11-06-2010, 09:56 PM
- By SWEngineer in forum AWT / SwingReplies: 11Last Post: 01-28-2010, 06:48 AM
- By SreenivasGurramkonda in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 12-08-2008, 07:01 AM
- By splinter64uk in forum AWT / SwingReplies: 1Last Post: 12-05-2007, 09:12 AM