import java.util.Random;
import java.awt.*;
import java.awt.Window.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.IOException;
import java.io.InputStream;
import javax.swing.event.*;
public class Main extends JFrame{
Dialogmoney dialog123 = new Dialogmoney();
DialogEx dialog1 = new DialogEx("!!!LUCK!!!");
DialogEx dialog2 = new DialogEx("SUCCESS!");
DialogEx dialog3 = new DialogEx("BAD");
DialogEx dialog4 = new DialogEx("Not Bad");
GamblingThread th = new GamblingThread();
JButton inputmoney = new JButton("돈 충전하기");
int att;
int btt;
int ctt;
boolean gambling = false;
Random random = new Random();
InputStream is = Main.class.getResourceAsStream("BMJUA_ttf.ttf");
JLabel a = new JLabel("1");
JLabel b = new JLabel("2");
JLabel c = new JLabel("3");
JButton bt = new JButton("Start");
ImageIcon background=new ImageIcon("Background.png");
Container ct = getContentPane();
public Main() {
setResizable(false);
setTitle("Casino World Online");
ct.setBackground(Color.white);
JLabel la = new JLabel(background);
ct.add(la);
la.setLocation(0,0);
la.setSize(553,325);
setLayout(null);
a.setFont(new Font("배달의민족 주아", Font.PLAIN,30));
b.setFont(new Font("배달의민족 주아", Font.PLAIN,30));
c.setFont(new Font("배달의민족 주아", Font.PLAIN,30));
bt.setFont(new Font("배달의민족 주아", Font.PLAIN,30));
inputmoney.setFont(new Font("배달의민족 주아", Font.PLAIN,30));
a.setSize(100, 100);
a.setBackground(Color.LIGHT_GRAY);
a.setOpaque(true);
a.setHorizontalAlignment(SwingConstants.CENTER);
b.setSize(100, 100);
b.setBackground(Color.LIGHT_GRAY);
b.setOpaque(true);
b.setHorizontalAlignment(SwingConstants.CENTER);
c.setSize(100, 100);
c.setBackground(Color.LIGHT_GRAY);
c.setOpaque(true);
c.setHorizontalAlignment(SwingConstants.CENTER);
a.setLocation(50, 50);
b.setLocation(210,50);
c.setLocation(370, 50);
bt.setLocation(190, 200);
bt.setSize(150, 50);
bt.addActionListener(new MyActionListener());
inputmoney.addActionListener(new money());
inputmoney.setSize(230,30);
inputmoney.setLocation(150,0);
ct.add(inputmoney);
ct.add(a);
ct.add(b);
ct.add(c);
ct.add(bt);
revalidate();
repaint();
setVisible(true);
setSize(553, 325);
th.start();
}
public static void main(String[] args) {
new Main();
}
class GamblingThread extends Thread{
synchronized public void waitForGambling() {
if(!gambling)
{
try {
System.out.println("waiting...");
this.wait();
} catch (InterruptedException e) {
// TODO: handle exception
return;
}
}
}
synchronized public void startGambling() {
gambling = true;
this.notify();
}
public void run() {
while(true) {
waitForGambling();
System.out.println("thread start... ");
att=random.nextInt(5);
String as = Integer.toString(att);
btt=random.nextInt(5);
String bs = Integer.toString(btt);
ctt=random.nextInt(5);
String cs = Integer.toString(ctt);
/*
*사기꾼 모드
if(att == btt)
{
if(btt == ctt) {
ctt=random.nextInt(5);
cs = Integer.toString(ctt);
}
}
*/
int lk;
String lks;
for(int i=10;i<20;i++){
lk = random.nextInt(5);
lks = Integer.toString(lk);
a.setText(lks);
System.out.println(lks);
try {
sleep(i);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
a.setText(as);
try {
sleep(500);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
for(int i=10;i<20;i++) {
lk = random.nextInt(5);
lks = Integer.toString(lk);
b.setText(lks);
System.out.println(lks);
try {
sleep(i);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
b.setText(bs);
try {
sleep(500);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
for(int i=10;i<20;i++) {
lk = random.nextInt(5);
lks = Integer.toString(lk);
c.setText(lks);
System.out.println(lks);
try {
sleep(i);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
c.setText(cs);
gambling = false;
int R = random.nextInt(255);
int G = random.nextInt(255);
int B = random.nextInt(255);
Color color = new Color(R,G,B);
ct.setBackground(color);
System.out.println("thread end");
bt.setEnabled(true);
if(att == 0 && btt==0) {
if(ctt==0) {
dialog1.setVisible(true);
}
}
else if(att == btt) {
if(btt == ctt && ctt == att) {
dialog2.setVisible(true);
}
}
else if(att == btt || btt == ctt || att == ctt) {
dialog4.setVisible(true);
}
else {
dialog3.setVisible(true);
}
}
}
}
class MyActionListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
System.out.println("click");
bt.setEnabled(false);
th.startGambling();
gambling = true;
}
}
class money implements ActionListener{
public void actionPerformed(ActionEvent e) {
System.out.println("click");
dialog123.setVisible(true);
}
}
public class DialogEx extends JDialog{
JLabel tf = new JLabel();
public DialogEx(String title) {
setTitle(title);
setLayout(new FlowLayout());
tf.setText(title);
setSize(200,100);
add(tf);
System.out.println("Cheack1");
try{
Thread.sleep(2000);
}
catch (InterruptedException e) {
throw new RuntimeException(e);
}
setVisible(false);
System.out.println("Check2");
}
}
public class Dialogmoney extends JDialog{
JLabel tf = new JLabel();
public Dialogmoney() {
setTitle("돈 보내기");
setLayout(new FlowLayout());
tf.setText("Making🚧");
setSize(300,300);
add(tf);
System.out.println("Cheack1");
try{
Thread.sleep(2000);
}
catch (InterruptedException e) {
throw new RuntimeException(e);
}
setVisible(false);
System.out.println("Check2");
}
}
}
download
https://drive.google.com/drive/folders/1yG4nL4g3O6oUjNpC8_-GZp3IMCkTQYRF?usp=sharing