Its pretty standard, why the hell isnt the window showing?? Cant figure it out :(

import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;

public  class GUIpart {   
    //All ze variables required
    int tempboard[][]=new int[9][9];
    SudokuBoard fresh= new SudokuBoard();
    JFrame sudoku = new JFrame("Srik Sudoku");
    JFormattedTextField guiboard[][] = new JFormattedTextField[9][9];
    
    public void GUIpart(){
        sudoku.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel grids = new JPanel();
        grids.setLayout(new GridLayout(10,9));
        try{
            MaskFormatter format=new MaskFormatter("#");
            
            for(int i=0;i<9;i++){
                for(int j=0;j<9;j++){
                    guiboard[i][j]=new JFormattedTextField(format);
                    guiboard[i][j].setColumns(1);
                    grids.add(guiboard[i][j]);
                }
            }
        }
        catch(Exception e){
            System.out.println("Jai");
        }
        
        JButton solve = new JButton("Solve");
        solve.addActionListener(new solveActionListener());
        grids.add(solve);
        
        sudoku.getContentPane().add(grids);
        sudoku.pack();
        sudoku.setVisible(true);
        
        
    }
    
    public  static void gogui(){
        JFrame.setDefaultLookAndFeelDecorated(true);

        GUIpart yay= new GUIpart(); 
        
    }
    private  class solveActionListener implements ActionListener{
           public void actionPerformed(ActionEvent e){
                for(int i=0;i<9;i++){
                    for(int j=0;j<9;j++){
 tempboard[i][j]=Integer.parseInt(guiboard[i][j].getText());
                    }               
                }
                fresh.inputBoard(tempboard);
                fresh.generateSolution();
                tempboard=fresh.sendBoard();
                for(int i=0;i<9;i++){
                    for(int j=0;j<9;j++){
                        guiboard[i][j].setText(Integer.toString(tempboard[i][j]));
                    }               
                }
           }
        
    }

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                gogui();
            }
        });
    }
    
}

public static void gogui() you do not realy need this method as you can set L&F before in the main method. Your code would work if you called yay.GUIpart() . Bellow is simpler solution. Remove public static void gogui() and replace main method with code bellow

public static void main(String[] args) 
{
    	JFrame.setDefaultLookAndFeelDecorated(true);
    	
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                GUIpart gui = new GUIpart();
                gui.GUIpart();
            }
        });
    }

Hmm yes that is much more simpler and easier to read!

And the problem in the my program was that GUIpart wasnt a constructor because I had put public void GUIpart() and constructors shouldn't have return types. Which is why I see you've called GUIpart()...

Thanks! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.