Click here to Skip to main content
15,886,422 members
Home / Discussions / Java
   

Java

 
QuestionDevelopment IDE Pin
Muhammad Nauman Yousuf11-Dec-08 23:34
Muhammad Nauman Yousuf11-Dec-08 23:34 
AnswerRe: Development IDE Pin
Expert Coming14-Dec-08 12:27
Expert Coming14-Dec-08 12:27 
GeneralRe: Development IDE Pin
Muhammad Nauman Yousuf14-Dec-08 21:45
Muhammad Nauman Yousuf14-Dec-08 21:45 
GeneralRe: Development IDE Pin
Naruki23-Dec-08 17:36
Naruki23-Dec-08 17:36 
AnswerRe: Development IDE Pin
toxcct17-Dec-08 21:54
toxcct17-Dec-08 21:54 
QuestionNeed help with registry search and delete Pin
chooch048-Dec-08 1:45
chooch048-Dec-08 1:45 
QuestionImplementing a String collection class Pin
fazl3h6-Dec-08 8:04
fazl3h6-Dec-08 8:04 
QuestionNeed Help Please Pin
AZBOY205-Dec-08 0:51
AZBOY205-Dec-08 0:51 
hi my problem is that im trying to build a one armed bandit using Java but i carnt figure out the If statement that lets you get:-

3 shapes of the same type win £1
2 shapes of the same type win 50p
one particular shape, say a apple win 20p

my coding that i have already should be below
any help with this problem would be great
thanks
Adam

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.Timer;

public class ConcentricCirclesWithTimer extends JFrame implements ActionListener
{
private JPanel panelDraw;
private JButton btnDraw, btnBye;
private Random random;
private Timer timer;
int width = 10;
int height = 10;
int x= 100;
int y = 100;
int timerCounter = 0;
public static void main(String[] args)
{
ConcentricCirclesWithTimer drawConcentCirc = new
ConcentricCirclesWithTimer();

}

public ConcentricCirclesWithTimer()
{
setLayout(new FlowLayout());
random = new Random();
panelDraw = new JPanel();
panelDraw.setPreferredSize(new Dimension(200, 200));
panelDraw.setBackground(Color.GRAY);
btnBye = new JButton("Bye!!");
btnDraw = new JButton("Draw.. .");

add(panelDraw); add(btnDraw); add(btnBye);
btnDraw.addActionListener(this);
btnBye.addActionListener(this);

setTitle("Using Pannel to Draw . . . .");
setSize(300, 300);
setVisible(true);



}





public void actionPerformed(ActionEvent event){

if (event.getSource()== btnDraw) {
timer = new Timer(400, this);
timer.start();

}// end of if
if (event.getSource() == timer ){
drawConcentricCircles() ;
}
if (event.getSource()== btnBye) {
System.exit(0);
}
}// end of actionPerformed


private void drawConcentricCircles(){
// x, y, height and width need to be declared globally?? Why??
// declare them here and run program!!
timerCounter = timerCounter + 1;
Graphics drawOnPanel = panelDraw.getGraphics();
drawOnPanel.setColor(new Color(random.nextInt(255),
random.nextInt(255), random.nextInt(255)));
drawOnPanel.drawOval(x, y, width, height);
width = width+20;
height = height+20;
x = x - 10;
y = y-10;

if (timerCounter>11){
timer.stop();
JOptionPane.showMessageDialog(null,"Timer stopped!!");

}

}
}
AnswerRe: Need Help Please Pin
Naruki8-Dec-08 19:55
Naruki8-Dec-08 19:55 
Questioncommunicating from one system to another using chat application Pin
ckanth3-Dec-08 19:36
ckanth3-Dec-08 19:36 
AnswerRe: communicating from one system to another using chat application Pin
Apurba Saha3-Dec-08 23:26
Apurba Saha3-Dec-08 23:26 
GeneralRe: communicating from one system to another using chat application Pin
ckanth4-Dec-08 22:53
ckanth4-Dec-08 22:53 
QuestionHow to create an exe file? Pin
Cheyahere3-Dec-08 3:20
Cheyahere3-Dec-08 3:20 
AnswerRe: How to create an exe file? Pin
Expert Coming14-Dec-08 12:31
Expert Coming14-Dec-08 12:31 
QuestionDifference between JPA and Hibernate Pin
sunil_jvfrm3-Dec-08 3:17
sunil_jvfrm3-Dec-08 3:17 
QuestionChanging locale for updates! Pin
Naruki2-Dec-08 13:24
Naruki2-Dec-08 13:24 
QuestionJava UTF8 applet Pin
Allan Larson26-Nov-08 15:12
Allan Larson26-Nov-08 15:12 
AnswerRe: Java UTF8 applet Pin
Naruki23-Dec-08 17:38
Naruki23-Dec-08 17:38 
GeneralRe: Java UTF8 applet Pin
Allan Larson24-Dec-08 6:11
Allan Larson24-Dec-08 6:11 
QuestionGraph layout Pin
ventomito26-Nov-08 8:06
ventomito26-Nov-08 8:06 
QuestionHelp mee,,,,, I'm confused,,,, Pin
VANDAWAA25-Nov-08 15:09
VANDAWAA25-Nov-08 15:09 
QuestionJavascript - href - servlet - java Pin
asifhirani78625-Nov-08 14:51
asifhirani78625-Nov-08 14:51 
Questionjava code for creating a unstructered p2p n/w Pin
venkatesh1111121-Nov-08 22:35
venkatesh1111121-Nov-08 22:35 
QuestionJava to COM Bridge Pin
railay2919-Nov-08 4:58
railay2919-Nov-08 4:58 
AnswerRe: Java to COM Bridge Pin
ramesh_rc24-Nov-08 0:21
ramesh_rc24-Nov-08 0:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.