How to open new JFrame by clicking on button in other JFrame?

Tictactoe java source code?

  • I’ve been working on a tic-tac-toe program and I’m stuck on a part where I’m trying to check if a player has won or not. Here is my code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class mygame extends JFrame implements ActionListener { private JPanel panel; private JLabel l; private JButton[] button; private String status; public mygame() { panel = new JPanel(); l = new JLabel("X'S TURN"); l.setPreferredSize(new Dimension(60,60)); status = "X"; for(int i=0;i<9;i++) { button[i]= new JButton(""); panel.add(button[i]); button[i].addActionListener(this); button[i].setPreferredSize(new Dimension(50,50)); button[i].setFont(new Font("sansserif", Font.BOLD, 32)); button[i].setFocusPainted(false); } panel.add(l); this.setResizable(false); this.setSize(150,210); this.setDefaultCloseOperation(JFrame… } public void actionPerformed(ActionEvent e) { for(int i=0; i<9; i++) { if(e.getSource()==button[i]) { button[i].setText("X"); button[i].setEnabled(false); status = "O'S TURN"; // button[i].checkStatus(this); } } } private void checkStatus(); { for(int i = 0; i<9;i++) { //this is what I’ve been trying to get if(button[i+2].getText().equals(butt… (button[i+1].getText().equals(button[… (button[i].getText().equals(button[i+… (button[i+2].getText().equals(button[… (button[i].getText().equals(button[i+… (button[i].getText().equals(button[i+… (button[i+3].getText().equals(button[… (button[i+6].getText().equals(button[… { }*/ } } public static void main(String[] args) { mygame test = new mygame(); } }

  • Answer:

    Check in Google.

Drake Bijuu at Yahoo! Answers Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.