Question
Please finish and let me know how to add images, I am matching movies to the characters in them In JAVA jGrasp This is what
Please finish and let me know how to add images, I am matching movies to the characters in them In JAVA jGrasp
This is what I have so far, will rate well if code works
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class MatchingGame extends JPanel
{
// creates 12 buttons
private JButton LostMovie;
private JButton LostEvangeline;
private JButton SecretWindowMovie;
private JButton SecretWindowDepp;
private JButton TheLegendOfZorroMovie;
private JButton TLoZElena;
private JButton TheHobbitMovie;
private JButton Thranduil;
private JButton MagnificentCenturyMovie;
private JButton Hurrem;
private JButton PiratesOfTheCarribeanMovie;
private JButton Pirate;
public MatchingGame()
{
Icon a=new ImageIcon(getClass().getResource("download.jpg"));
LostMovie=new JButton(a);
//change layout manager
setLayout(new BorderLayout());
// add components to container (add method is overloaded)
add(LostMovie, BorderLayout.NORTH);
add(LostEvangeline, BorderLayout.NORTH);
add(SecretWindowMovie, BorderLayout.NORTH);
add(SecretWindowDepp, BorderLayout.NORTH);
add(TheLegendOfZorroMovie, BorderLayout.NORTH);
add(TLoZElena, BorderLayout.NORTH);
add(TheHobbitMovie, BorderLayout.SOUTH);
add(Thranduil, BorderLayout.SOUTH);
add(MagnificentCenturyMovie, BorderLayout.SOUTH);
add(Hurrem, BorderLayout.SOUTH);
add(PiratesOfTheCarribeanMovie, BorderLayout.SOUTH);
add(Pirate, BorderLayout.SOUTH);
}
}
------------------------------------------------------------------
import javax.swing.*;
public class MatchingTest
{
public static void main(String[] args)
{
JFrame myFrame = new JFrame("Match the characters to the movie");
/* (0,0) is on the top left hand corner
y direction brings it down */
myFrame.setLocation(500,500);
myFrame.setSize(500,500);
// close program
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// DEPENDING ON CLASS
myFrame.setContentPane(new MatchingGame());
// makes frame visible so it can be seen
myFrame.setVisible(true);
}
}
-------------------------------------------------------------------------------------------------
My Matching Game java Write a Driver similar to the ones you wrote in the other GUI labs. write a matching game program. Use BorderLayout with 3 panels. The north panel will have 5-6 buttons with an icon or words on each. Use Paint to resize all the pictures to the same dimensions. The center panel will have a title and or directions. The south panel will have 5-6 buttons that can be "matched" to the north buttons. The order in the south will be different than the north. Output a statement or sound when the match is correct or not. IRGNIA Match the ACC school with it's mascot The Logic In the panel you will need to keep track of the first button pressed, so when the second button is pressed, you'll know if you have a match. Below is the easiest way to do it. Create a private int, called choice, above the constructor (with the components). Attach each button to its own Listener. When a top row button is selected, set choice to a number representing that button. In the matching bottom row button's Listener, check choice and determine if the match was correct or not. Play your correct sound or incorrect sound. Then reset choice to 0. You must select a top row button first, and then a bottom row button. See below: private class NCSUListener implements ActionListener lattached to the NCSU logo in top row public void actionPerformed (ActionEvent e) choice 1; llNCSU will be private class NCsUMascotListener implements ActionListener lattached to NCSU mascot in bottom rowStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started