package gametest;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
public class JFrameGamePlay extends javax.swing.JFrame {
String playerimage;
String cpuimage;
String BattlesWon = "0";
String BattlesLost = "0";
String Gold = "0";
String PlayerLevel = "1";
public JFrameGamePlay() {
initComponents();
}
public JFrameGamePlay(String playername, String playerselected) {
initComponents();
JPanel leftpanel = new JPanel();
JPanel rightpanel = new JPanel();
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftpanel, rightpanel);
pnlPlayerInfo.setBackground(Color.WHITE);
JLabel lblPlayer = new JLabel(new ImageIcon("/resources/House.png"));
leftpanel.add(lblPlayer);
leftpanel.validate();
leftpanel.repaint();
leftpanel.setVisible(true);
//Setting variables
txtPlayerName.setText(playername);
txtPlayerName.setEditable(false);
txtBattlesWon.setText(BattlesWon);
txtBattlesWon.setEditable(false);
txtBattlesLost.setText(BattlesLost);
txtBattlesLost.setEditable(false);
txtGold.setText(Gold);
txtGold.setEditable(false);
txtPlayerLevel.setText(PlayerLevel);
txtPlayerLevel.setEditable(false);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
pnlPlayerInfo = new javax.swing.JPanel();
lblPlayerName = new javax.swing.JLabel();
txtPlayerName = new javax.swing.JTextField();
lblGold = new javax.swing.JLabel();
txtGold = new javax.swing.JTextField();
lblPlayerLevel = new javax.swing.JLabel();
txtPlayerLevel = new javax.swing.JTextField();
lblBattlesWon = new javax.swing.JLabel();
txtBattlesWon = new javax.swing.JTextField();
lblBattlesLost = new javax.swing.JLabel();
txtBattlesLost = new javax.swing.JTextField();
pnlPlayer = new javax.swing.JPanel();
pnlCPU = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
pnlPlayerInfo.setBackground(new java.awt.Color(255, 255, 255));
lblPlayerName.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblPlayerName.setLabelFor(txtPlayerName);
lblPlayerName.setText("Player Name:");
lblPlayerName.setToolTipText("");
txtPlayerName.setText("jTextField1");
lblGold.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblGold.setLabelFor(txtGold);
lblGold.setText("Gold:");
txtGold.setText("jTextField1");
lblPlayerLevel.setText("Player Level:");
txtPlayerLevel.setText("jTextField1");
lblBattlesWon.setLabelFor(txtBattlesWon);
lblBattlesWon.setText("Battles Won:");
lblBattlesWon.setToolTipText("");
txtBattlesWon.setText("JTextField1");
txtBattlesWon.setToolTipText("");
txtBattlesWon.setName("txtBattlesWon"); // NOI18N
lblBattlesLost.setLabelFor(txtBattlesLost);
lblBattlesLost.setText("Battles Lost:");
txtBattlesLost.setText("jTextField1");
javax.swing.GroupLayout pnlPlayerInfoLayout = new javax.swing.GroupLayout(pnlPlayerInfo);
pnlPlayerInfo.setLayout(pnlPlayerInfoLayout);
pnlPlayerInfoLayout.setHorizontalGroup(
pnlPlayerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlPlayerInfoLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlPlayerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtPlayerName)
.addComponent(lblPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE))
.addGap(36, 36, 36)
.addGroup(pnlPlayerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtGold)
.addComponent(lblGold, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(34, 34, 34)
.addGroup(pnlPlayerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblPlayerLevel)
.addComponent(txtPlayerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(40, 40, 40)
.addGroup(pnlPlayerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblBattlesWon)
.addComponent(txtBattlesWon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(44, 44, 44)
.addGroup(pnlPlayerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtBattlesLost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblBattlesLost))
.addContainerGap(18, Short.MAX_VALUE))
);
pnlPlayerInfoLayout.setVerticalGroup(
pnlPlayerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlPlayerInfoLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlPlayerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPlayerName)
.addComponent(lblGold)
.addComponent(lblPlayerLevel)
.addComponent(lblBattlesWon)
.addComponent(lblBattlesLost))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlPlayerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtPlayerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtGold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtPlayerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtBattlesWon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtBattlesLost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(15, Short.MAX_VALUE))
);
pnlPlayer.setBorder(new javax.swing.border.MatteBorder(null));
javax.swing.GroupLayout pnlPlayerLayout = new javax.swing.GroupLayout(pnlPlayer);
pnlPlayer.setLayout(pnlPlayerLayout);
pnlPlayerLayout.setHorizontalGroup(
pnlPlayerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 141, Short.MAX_VALUE)
);
pnlPlayerLayout.setVerticalGroup(
pnlPlayerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 244, Short.MAX_VALUE)
);
pnlCPU.setBorder(new javax.swing.border.MatteBorder(null));
javax.swing.GroupLayout pnlCPULayout = new javax.swing.GroupLayout(pnlCPU);
pnlCPU.setLayout(pnlCPULayout);
pnlCPULayout.setHorizontalGroup(
pnlCPULayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 141, Short.MAX_VALUE)
);
pnlCPULayout.setVerticalGroup(
pnlCPULayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlPlayerInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(pnlPlayer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlCPU, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(pnlPlayerInfo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(pnlPlayer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlCPU, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 84, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
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(JFrameGamePlay.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(JFrameGamePlay.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(JFrameGamePlay.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(JFrameGamePlay.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 JFrameGamePlay().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel lblBattlesLost;
private javax.swing.JLabel lblBattlesWon;
private javax.swing.JLabel lblGold;
private javax.swing.JLabel lblPlayerLevel;
private javax.swing.JLabel lblPlayerName;
private javax.swing.JPanel pnlCPU;
private javax.swing.JPanel pnlPlayer;
private javax.swing.JPanel pnlPlayerInfo;
private javax.swing.JTextField txtBattlesLost;
private javax.swing.JTextField txtBattlesWon;
private javax.swing.JTextField txtGold;
private javax.swing.JTextField txtPlayerLevel;
private javax.swing.JTextField txtPlayerName;
// End of variables declaration
}