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 6320675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:01:03+00:00 2026-05-24T16:01:03+00:00

I have a poker game where I designed a nice pretty GUI that displays

  • 0

I have a poker game where I designed a nice pretty GUI that displays the cards and players. I did it all extending JPanel inside paint() with a lot of g2d.drawImage’s and g2d.drawString()’s, with definite x and y locations.

My problem now is that I need to have a couple interactive buttons underneath it.. but whenever I try to add a JButton, it appears top and center. I’ve used setLocation(x, y) and setLayout(null) and everything I’ve seen in other replies, but none of them seem to match my need (Or at least I don’t have a very well understanding of where to put it)

This is how my code is set up:
pokerserver.java

public class pokerserver extends JFrame {

    public pokerserver() {
        add(new drawing());    
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(720, 640);
        setLocationRelativeTo(null);
        setTitle("Poker HANGOUTS");
        setResizable(false);
        setVisible(true);            
    }

    public static void main(String args[]) {
        new pokerserver();    
    }

And then in drawing.class

public drawing() {      
    setFocusable(true);
    setBackground(new Color(39,91,46));
    setDoubleBuffered(true);        
    gameCards = new cards();
    gameCards.shuffle();

    for (int i = 0; i < 10; i++)
        seats[i] = -1;

    HQ = new HeadQuarters(this);
    HQ.start();

}

public void paint(Graphics g) {
    super.paint(g);       

    Graphics2D g2d = (Graphics2D)g;

    //All my UI code
    }

My last attempt was trying to add

   JButton button = new JButton("TEST");
    add(button);
   button.setLocation(10, 500);

at the end of public drawing(). I Keep seeing things on layout management, but it’s not helping me — mainly because I’m not sure how to implement it

Here’s a screenshot to help visualize what I’m talking about->

https://i.stack.imgur.com/O11C0.png

Trying to get the button underneath. Unless there’s a way to add an ActionListener to a drawImage()?

  • 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-24T16:01:04+00:00Added an answer on May 24, 2026 at 4:01 pm

    For your main panel use a BorderLayout.

    Then to the “CENTER” you can add your game panel with all your custom painting.

    Then create a panel and add the buttons to it. Now you can add this panel to the NORTH of the main panel.

    In other words you are not restricted to using a single panel.

    Also, custom painting should be done in the paintComponent() method of your panel, NOT the paint() method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSlider which shows bet sizes (for a poker game) I am
I have a normal map in my OpenGL game engine and I realized that
I'm modeling a Poker game and I have a little design doubt: I've a
I'm building a JavaScript based poker game that get some updates from a server
I have a game which uses OpenGL ES for rendering. And it requires that
I have a game consisting of ships that fly around on a 2d grid.
I'm doing a poker game and have hit a wall. Any help would be
It recently emerged on a large poker site that some players were possibly able
I need to make a poker game for school in c++. I have made
I have an Android app which calculates poker odds ( Shufflebot if you're interested).

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.