对于我正在制作的简单纸牌游戏,我想制作一个可以玩我的纸牌游戏的GUI。以前,我依靠JOptionPane来向我展示我画的内容。现在,我不知道如何使用我在NetBeans中使用swing接口创建的GUI绘制卡片。所以我想知道在NetBeans生成的GUI代码的按钮中实现原始绘图方法的最佳方法。谢谢!
这是绘图方法:
public static void Draw() {
System.out.println(player1 + " drew " + suits[cardSuit(deck1[deck1CardPosition])] + " of power " + (cardPower(deck1[deck1CardPosition])));
JOptionPane.showMessageDialog(null, player1 + " drew " + suits[cardSuit(deck1[deck1CardPosition])] + " of power " + (cardPower(deck1[deck1CardPosition])));
System.out.println(player2 + " drew " + suits[cardSuit(deck2[deck2CardPosition])] + " of power " + (cardPower(deck2[deck2CardPosition])));
JOptionPane.showMessageDialog(null, player2 + " drew " + suits[cardSuit(deck2[deck2CardPosition])] + " of power " + (cardPower(deck2[deck2CardPosition])));
}
更新:添加NetBeans为我自动生成的代码块:
private void DrawActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
动作监听器:
Draw.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DrawActionPerformed(evt);
}
答案 0 :(得分:0)
您可以使用javax.swing和java.awt。库,以实现您想要实现的目标。