PBO - Final Project
Screenshot aplikasi:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package fppbo; | |
import java.awt.Color; | |
/** | |
* | |
* @author gscul | |
*/ | |
public class MainForm extends javax.swing.JFrame { | |
RandomText game; | |
String com; | |
/** | |
* Creates new form MainForm | |
*/ | |
public MainForm() { | |
initComponents(); | |
game = new RandomText(jScrollPane1.getWidth(), jScrollPane1.getHeight()); | |
//game.repaint(); | |
jScrollPane1.setViewportView(game); | |
jScrollPane1.setBackground(Color.WHITE); | |
System.out.println("String: " + game.huruf[game.nama]); | |
jTextField1.setFocusable(true); | |
} | |
/** | |
* This method is called from within the constructor to initialize the form. | |
* WARNING: Do NOT modify this code. The content of this method is always | |
* regenerated by the Form Editor. | |
*/ | |
@SuppressWarnings("unchecked") | |
// <editor-fold defaultstate="collapsed" desc="Generated Code"> | |
private void initComponents() { | |
jLayeredPane1 = new javax.swing.JLayeredPane(); | |
jTextField1 = new javax.swing.JTextField(); | |
jLabel1 = new javax.swing.JLabel(); | |
jScrollPane1 = new javax.swing.JScrollPane(); | |
jMenuBar1 = new javax.swing.JMenuBar(); | |
jMenu1 = new javax.swing.JMenu(); | |
jMenuItem1 = new javax.swing.JMenuItem(); | |
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | |
setPreferredSize(new java.awt.Dimension(272, 325)); | |
jLayeredPane1.setAutoscrolls(true); | |
jLayeredPane1.setNextFocusableComponent(jTextField1); | |
jLayeredPane1.setPreferredSize(new java.awt.Dimension(534, 325)); | |
jTextField1.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jTextField1ActionPerformed(evt); | |
} | |
}); | |
jLabel1.setFont(new java.awt.Font("Montserrat Alternates ExLight", 0, 11)); // NOI18N | |
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); | |
jLabel1.setText("Judul Game"); | |
jScrollPane1.setAutoscrolls(true); | |
jScrollPane1.setMaximumSize(new java.awt.Dimension(272, 325)); | |
jLayeredPane1.setLayer(jTextField1, javax.swing.JLayeredPane.DEFAULT_LAYER); | |
jLayeredPane1.setLayer(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER); | |
jLayeredPane1.setLayer(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER); | |
javax.swing.GroupLayout jLayeredPane1Layout = new javax.swing.GroupLayout(jLayeredPane1); | |
jLayeredPane1.setLayout(jLayeredPane1Layout); | |
jLayeredPane1Layout.setHorizontalGroup( | |
jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jLayeredPane1Layout.createSequentialGroup() | |
.addContainerGap() | |
.addGroup(jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | |
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE) | |
.addComponent(jTextField1)) | |
.addContainerGap()) | |
); | |
jLayeredPane1Layout.setVerticalGroup( | |
jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jLayeredPane1Layout.createSequentialGroup() | |
.addContainerGap() | |
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGap(18, 18, 18) | |
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addContainerGap(53, Short.MAX_VALUE)) | |
); | |
jMenu1.setText("Game"); | |
jMenuItem1.setText("Exit"); | |
jMenuItem1.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jMenuItem1ActionPerformed(evt); | |
} | |
}); | |
jMenu1.add(jMenuItem1); | |
jMenuBar1.add(jMenu1); | |
setJMenuBar(jMenuBar1); | |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); | |
getContentPane().setLayout(layout); | |
layout.setHorizontalGroup( | |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
); | |
layout.setVerticalGroup( | |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
); | |
pack(); | |
}// </editor-fold> | |
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) { | |
System.exit(0); | |
} | |
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { | |
com = game.huruf[game.nama - 1]; | |
String te = jTextField1.getText(); | |
String baru1 = com.toLowerCase(); | |
String baru2 = te.toLowerCase(); | |
System.out.println("Gambar = " + baru1); | |
System.out.println("Jawab = " + baru2); | |
if(baru1.compareTo(baru2) == 0) { | |
System.out.println("Benar"); | |
game.reset(); | |
game.addScore(100); | |
jTextField1.setText(""); | |
} else { | |
System.out.println("Salah"); | |
jTextField1.setText(""); | |
game.minusScore(50); | |
} | |
} | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String args[]) { | |
/* Set the Nimbus look and feel */ | |
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> | |
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. | |
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html | |
*/ | |
try { | |
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { | |
if ("Nimbus".equals(info.getName())) { | |
javax.swing.UIManager.setLookAndFeel(info.getClassName()); | |
break; | |
} | |
} | |
} catch (ClassNotFoundException ex) { | |
java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
} catch (InstantiationException ex) { | |
java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
} catch (IllegalAccessException ex) { | |
java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
} catch (javax.swing.UnsupportedLookAndFeelException ex) { | |
java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
} | |
//</editor-fold> | |
/* Create and display the form */ | |
java.awt.EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
new MainForm().setVisible(true); | |
} | |
}); | |
} | |
// Variables declaration - do not modify | |
private javax.swing.JLabel jLabel1; | |
private javax.swing.JLayeredPane jLayeredPane1; | |
private javax.swing.JMenu jMenu1; | |
private javax.swing.JMenuBar jMenuBar1; | |
private javax.swing.JMenuItem jMenuItem1; | |
private javax.swing.JScrollPane jScrollPane1; | |
private javax.swing.JTextField jTextField1; | |
// End of variables declaration | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package fppbo; | |
import java.awt.Color; | |
import java.awt.Font; | |
import java.awt.Graphics; | |
import java.awt.Image; | |
import javax.swing.ImageIcon; | |
import javax.swing.JOptionPane; | |
import javax.swing.JPanel; | |
/** | |
* | |
* @author gscul | |
*/ | |
public class RandomText extends JPanel implements Runnable { | |
private int yImage, vy, height, width, delay, score; | |
private Thread animasi; | |
private boolean isPlay = true; | |
private Image gbr, balon; | |
int lebarGbr, tinggiGbr, nama,x; | |
int level = 1; | |
String huruf[] = {"apple", "bag", "banana", "door", "flatiron", "tie", | |
"towel", "trash", "water", "window"}; | |
public RandomText(int width, int height){ | |
this.width = width; | |
this.height = height; | |
nama = 1; | |
x = 150; | |
start(); | |
System.out.println("height: " + height); | |
vy = 1; | |
delay = 60; | |
score = 0; | |
} | |
public Image image(){ | |
try { | |
ImageIcon image = new ImageIcon(this.getClass().getResource("/fppbo/pic/back.png")); | |
gbr = image.getImage(); | |
return gbr; | |
} catch(Exception e) { | |
System.out.println("Gambar tidak ada"); | |
return null; | |
} | |
} | |
public Image imageBubble() { | |
try { | |
ImageIcon bubble = new ImageIcon(this.getClass().getResource("/fppbo/pic/" + nama + ".png")); | |
balon = bubble.getImage(); | |
lebarGbr = bubble.getIconWidth(); | |
tinggiGbr = bubble.getIconHeight(); | |
return balon; | |
} catch(Exception e) { | |
return null; | |
} | |
} | |
public void gambarBubble(Graphics g) { | |
if(imageBubble() != null) { | |
g.drawImage(imageBubble(), 50, 0, this); | |
} | |
} | |
public void cetakScore(Graphics g) { | |
g.setFont(new Font("Arial", Font.BOLD, 14)); | |
g.setColor(Color.GREEN); | |
g.drawString("Score", 5, 300); | |
g.setColor(Color.RED); | |
g.drawString(getScore() + "", 70, 300); | |
} | |
@Override | |
public void paint(Graphics g) { | |
gambarBubble(g); | |
cetakScore(g); | |
} | |
public int getScore() { | |
return score; | |
} | |
public void setScore(int score) { | |
this.score = score; | |
} | |
public void addScore(int i) { | |
score = score + i; | |
} | |
public void minusScore(int i) { | |
score = score - i; | |
} | |
public void gerakan() { | |
//yImage -= vy; | |
if(yImage < - (tinggiGbr/2)) { | |
endGame(); | |
} | |
if(score > 400 && level == 1) { | |
naikLevel(); | |
} else if(score > 1400 && level == 2) { | |
naikLevel(); | |
vy = vy * 2; | |
} else if(score > 1900 && level == 3) { | |
JOptionPane.showMessageDialog(null, "<html><font color=#FF0000>Selamat anda telah menyelesaikan game ini !!!</font></html>"); | |
System.exit(1); | |
vy = vy * 3; | |
} | |
} | |
public void endGame() { | |
int i = JOptionPane.showConfirmDialog(null, "GAME OVER!! " + "\n" + " 'Yes' untuk new game, 'No' keluar game", "Konfirmasi", +JOptionPane.YES_NO_OPTION); | |
if (i == JOptionPane.YES_OPTION) { | |
score = 0; | |
reset(); | |
vy = 1; | |
level = 1; | |
} | |
if(i == JOptionPane.NO_OPTION) { | |
System.exit(1); | |
} | |
} | |
public void naikLevel() { | |
int i = JOptionPane.showConfirmDialog(null, "Selamat anda telah menyelesaikan level " + level +"\n Tekan 'Yes' untuk Melanjutkan 'No' untuk keluar", "Konfirmasi", JOptionPane.YES_NO_OPTION); | |
if(i == JOptionPane.YES_OPTION) { | |
level++; | |
System.out.println("Yes"); | |
} | |
if(i == JOptionPane.NO_OPTION) { | |
System.exit(1); | |
} | |
} | |
public void reset() { | |
nama = (int) (Math.random() * 9 + 1); | |
yImage = height; | |
x = 150; | |
System.out.println("Width: " + width); | |
System.out.println("gbWidth: " + lebarGbr); | |
System.out.println("Height: " + height); | |
System.out.println("Hasil x: " + x); | |
System.out.println("Source: " + nama + ".png"); | |
} | |
public void start() { | |
yImage = height; | |
if(animasi == null) { | |
animasi = new Thread(this); | |
animasi.start(); | |
} | |
} | |
@Override | |
public void run() { | |
while(isPlay) { | |
repaint(); | |
gerakan(); | |
try { | |
Thread.sleep(delay); | |
} catch(InterruptedException e) { | |
System.out.println("Error load image"); | |
} | |
} | |
} | |
} |
PBO - Final Project
Reviewed by Ganendra
on
23.21
Rating:

RNGS Casino - Home
BalasHapusA review 넷마블 바카라 of all bet365 the casino games and slots available online, 라이브채팅 including 러시안 룰렛 more casino games, Slots RNGS Casino | 러시안 룰렛 100% up to €100 in Free Spins.