Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7519407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:53:51+00:00 2026-05-30T01:53:51+00:00

I am creating a simple Sudoku game. Since this is my first big i

  • 0

I am creating a simple Sudoku game. Since this is my first “big” i want to do everything myself (without the NetBeans interface designer that i normally use to make GUIs). So for the GUI i created a class that extends JApplet and i drew a simple sudoku field in the paint() method.

Now i need to make 81 text fields each of which will take in 1 number. How do i position them on the screen? Also, i was thinking of making an array so i’ll be able to change the enitre matrix of fields with one for loop.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:53:51+00:00Added an answer on May 30, 2026 at 1:53 am

    Suggestions:

    • Never draw directly in the paint method of a top-level component such as a JApplet, JFrame, JDialog, or the like.
    • If you need to do custom drawing, do this instead in the paintComponent(...) method override of a component that extends JComponent such as a JPanel or JComponent itself.
    • Your problem doesn’t really require custom painting, at least not yet, and is much better and more simply solved by other means.
    • Use components such as JLabels, JTextFields, etc… and position them using the Swing layout managers (the other means noted above). You can find the tutorial on how to use this here: Laying Out Components in a Container
    • Layouts to focus on first include GridLayout for your Sudoku “cells” and BorderLayout for the overall GUI. Avoid the GridBagLayout and GroupLayout, at least when starting out.
    • Remember that you can create complex applications by nesting JPanels that each use a simple layout manager.
    • A simple way to “paint” gridlines is to set the background color of the the JPanel that uses GridLayout and holds the JTextFields to Color.BLACK, and be sure to give your GridBagLayout a small vertical and horizontal gap so that the black shows through. The tutorials listed above will show you how to do this.
    • If this were my application, I’d gear my GUI towards creating a JPanel that held the application. Then if I needed to display it in a JApplet, I’d create a very small application that subclasses JApplet and then in the init() method, add my Sudoku JPanel into the JApplet’s contentPane. This way, if I wanted to instead display my app in a JFrame, all I’d need to do would be to create another small class that creates a JFrame and add’s my Sudoku JPanel into the JFrame’s contentPane, then call pack() on the JFrame, and then setVisible(true).

    Regarding your question on how to add a JPanel to a JApplet, again the tutorials will show you how to do this. If you haven’t linked to the tutorial’s big index, you will want to do so: The Really Big Index.

    A very simple example goes like so:

    import java.lang.reflect.InvocationTargetException;
    import javax.swing.*;
    
    public class MyApplet extends JApplet {
       @Override
       public void init() {
          try {
             SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                   getContentPane().add(new MyJPanel());             
                }
             });
          } catch (InterruptedException e) {
             e.printStackTrace();
          } catch (InvocationTargetException e) {
             e.printStackTrace();
          }
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a simple RPG game, first time using XNA. Trying to get my character
Im creating a simple bowling game using OOP, and i want to have a
When creating a simple Flex 4.6 App, where the creationComplete-handler looks like this: protected
I am fairly familiar with creating simple custom controls, but I haven't had this
I'm creating simple image viewer, but I want to make a sorting of pictures
I am creating simple blog web application using play framework and i want to
I am creating simple chess board game in java, and they are running smoothly,
I'm creating a simple game using HTML and CSS. I have a background image
I am creating a simple game designed to prompt the user for the Greek
I am creating simple reports module by following this tutorial .When i try to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.