Question

In: Computer Science

Need to read a PPM image using a 3D array and display it in a swing Jpanel.

Need to read a PPM image using a 3D array and display it in a swing Jpanel. 

Solutions

Expert Solution

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.ImageIcon;

public class HangmanPanel extends JPanel {
    private JLabel imageLabel;
    private ImageIcon[] images;
    private JButton nextImage;
    private int imageNumber;


    public HangmanPanel() {

        nextImage = new JButton("Next Image");
        nextImage.setEnabled(true);
        nextImage.setToolTipText("Press for next image.");
        nextImage.addActionListener(new ButtonListener());

        images = new ImageIcon[8];
        // Populating the array
        {
            images[0] = new ImageIcon("hangman0.png");
            images[1] = new ImageIcon("hangman1.png");
            images[2] = new ImageIcon("hangman2.png");
            images[3] = new ImageIcon("hangman3.png");
            images[4] = new ImageIcon("hangman4.png");
            images[5] = new ImageIcon("hangman5.png");
            images[6] = new ImageIcon("hangman6.png");
            images[7] = new ImageIcon("hangman7.png");
        }

        setBackground(Color.white);

        add(nextImage);
        int count = 0;
        while (images.length > count)
        imageLabel = new JLabel (images[imageNumber]);
        count++;
        imageNumber++;
        add (imageLabel);
    }


    public void paint(Graphics page) {
        super.paint(page);


    }
    private class ButtonListener implements ActionListener{
        public void actionPerformed(ActionEvent event) {
            imageNumber++;
            }

        }
    }

Related Solutions

Design an algorithm that will read an array of 200 characters and display to the screen...
Design an algorithm that will read an array of 200 characters and display to the screen a count of the occurrences of each of the five vowels (a, e, i, o, u) in the array. Your string is: The quick brown fox jumped over the lazy dog That is the question for my pseudo code question, I don't know if I have this correct can i have someone look this over and finish this and explain what i needed to...
Explain the trade-offs, particularly for throughput (performance), involved in preparing an image, video, or 3D image...
Explain the trade-offs, particularly for throughput (performance), involved in preparing an image, video, or 3D image processing task for parallel processing ?
Using pandas Read in the movies.csv into a dataframe named movies, display the first 5 rows...
Using pandas Read in the movies.csv into a dataframe named movies, display the first 5 rows and answer * Use the filter method to select the column names that contain the exact string facebook [ ] * Use the count method to find the number of non-missing values for each column. [ ] * Display the count of missing values for each column
Write a java script function that accepts integer array as input, and display a new array...
Write a java script function that accepts integer array as input, and display a new array by performing fol lowing modifications, • The values in odd index positions must be incremented by 1 • The values in even index positions must be decremented by 1. • Assume the array index starts from 0. Input 1: arr = [1,2,3,4] Output 1: arr = [0,3,2,5 it done html and javascript and plz do it in simple way
Given an array of integers, delete each element from the array which is a multiple of 5, and display the rest of the array.
Given an array of integers, delete each element from the array which is a multiple of 5, and display the rest of the array.Input:    6    2 3 4 11 22 320    where:First line represents the number of elements in the array.Second line represents the elements in the array.Output:    2 3 4 11 22Explanation: Element of the array 320 is the only one in the array which is a multiple of 5, so it is removed from the array.Assumptions:Array can be of size...
Pandas exercises: 1. Write a python program using Pandas to create and display a one-dimensional array-like...
Pandas exercises: 1. Write a python program using Pandas to create and display a one-dimensional array-like object containing an array of data. 2. Write a python program using Pandas to convert a Panda module Series to Python list and print it's type. (Hint: use ds.tolist() to convert the pandas series ds to a list) 3. Create a pandas dataframe called **my_df** with index as integer numbers between 0 to 10, first column (titled "rnd_int") as 10 integer random numbers between...
In C, write a program that initializes a 3D array (the exact size doesn't matter) that...
In C, write a program that initializes a 3D array (the exact size doesn't matter) that contain what ever arbitrary integers and print out the array including the elements and use different functions so that the main only contains variables and function calls.
Using Python read dataset in the HTML in beautiful way. You need to read CSV file...
Using Python read dataset in the HTML in beautiful way. You need to read CSV file ( Use any for example, You can use small dataset) You need to use pandas library You need to use Flask Make search table like YouTube has.
In the MATLAB environment, display an image of a breast mammogram from the MAMMO database. Apply...
In the MATLAB environment, display an image of a breast mammogram from the MAMMO database. Apply gray-level scaling, histogram equalization, and an LOG enhancement mask for image enhancement as given below. Compare the enhanced images to original image qualitatively. LOG enhancement mask to be convolved with the image: - 1 -1 -1 - 1 9 - 1 -1 -1 -1 MAMMO database: http://peipa.essex.ac.uk/pix/mias/
[7] How many MB of video memory is required to display an image with a resolution...
[7] How many MB of video memory is required to display an image with a resolution of 1,920 x 1,080 pixels and 65,536 colors (2^16colors)? However, 1 [MB] = 1,000 [kB] and 1 [kB] = 1,000 (B). [8] What is the amount of video memory required to display an image with a resolution of 1,600 x 1,200 pixels and 65,536 colors (2^16 colors)? However, 1 [MB]= 1,000 [kB], 1 (kB] = 1,000 (B). [9] Minimum required for video distribution at...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT