I need to create an applet in Java?
-
It needs to display images of playing cards. The applet should shuffle the deck (use a random number generator) and display the first 10 cards of the shuffled deck. Display the cards ...show more
-
Answer:
here I have got smtng hope this will help u import javax.swing.*; import java.awt.*; import java.io.*; import java.awt.event.*; import java.util.*; import javax.swing.JApplet.*; class GameBoard extends JPanel { JButton but[]=new JButton[10];//counting will strt frm 0 so declre 10 it will halt at 9 ImageIcon icon[]=new ImageIcon[10]; String imageNames[]={"a.png","b.png","c.png","d... JPanel p=new JPanel(); public GameBoard() { JButton k=new JButton("Shuffel it (Maximize and minimize to repaint or try other methds I dnt knw)"); p.add(k); k.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent a) { shuffel(); repaint(); } }); setLayout(new GridLayout(2,5)); for(int i=0;i<but.length;i++) { but[i]=new JButton(imageNames[i]); icon[i]=new ImageIcon(imageNames[i]); but[i].setIcon(icon[i]); add(but[i]); } } public void shuffel() { for(int i=0;i<but.length;i++) { this.remove(but[i]); } repaint(); Collections.shuffle(Arrays.asList(but)); for(int i=0;i<but.length;i++) { this.add(but[i]); repaint(); } } } public class dsa extends JApplet { public dsa() { GameBoard GameBoard=new GameBoard(); setSize(400,400); add(GameBoard,BorderLayout.CENTER); add(GameBoard.p,BorderLayout.NORTH); repaint(); setVisible(true); } }
L24L4MHFDZU2HSRPO53YXY7YNA at Yahoo! Answers Visit the source
Related Q & A:
- how to close the applet in java code?Best solution by Stack Overflow
- How to create RSS feed in Java?Best solution by Stack Overflow
- I need help on what I need to buy or do.Best solution by Yahoo! Answers
- I need help with writing up the Java Code.Best solution by Yahoo! Answers
- Need to clean out my work shop. What are some good organizational skills that I need to?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.