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

  • Home
  • SEARCH
  • 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 8904575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:10:04+00:00 2026-06-15T02:10:04+00:00

I would like to create a simple Blackjack GUI in Java. I know the

  • 0

I would like to create a simple Blackjack GUI in Java. I know the basics of creating JLabel, JPanel etc. However, I cannot find why my JLabel is not displayed on the screen. Here is my code:

        //Create and set up the window.
        JFrame frame = new JFrame("BlackJack");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //new border panel
        JPanel gui = new JPanel(new BorderLayout(2,2));

        //create players panel
        JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
        panel2.setPreferredSize(new Dimension(600, 200));
        panel2.setBackground(Color.ORANGE);
        gui.add(panel2, BorderLayout.CENTER);


        //Display the window.
        frame.pack();
        frame.setVisible(true);
        frame.setTitle("BlackJack!");


        //add players name
        String name = JOptionPane.showInputDialog(null, "Name?");
        JLabel playerName = new JLabel(name);
        playerName.setPreferredSize(new Dimension(100, 40));
        playerName.setFont(new Font("sansserif", Font.BOLD, 18));
        panel2.add(playerName);

When I hit compile, what I get is a dialog for name? and then an empty panel. I do not understand why my JLabel is not in the panel since I have added it to my frame. Am I missing something?

  • 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-06-15T02:10:05+00:00Added an answer on June 15, 2026 at 2:10 am
    if(nloop != 1 || nloop != 2){
    

    This is a tautology.

    For each number – it cannot be both 1 and 2 – so the condition (nloop != 1 || nloop != 2) always yields true.

    Maybe you wanted && instead of ||?


    The while loop: while(run2 = true){ also smells, as pointed in comments (though it doesn’t seem to be the issue stated in the question).

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

Sidebar

Related Questions

I would like to create simple objects at runtime (textbox, label, etc) and add
I would like to create a simple XMPP client in java that shares his
I'm new to REST on Java and I would like to create simple REST
I would like to create a simple chat room like GUI interface that will
I would like to create a simple copy console application (I know copy already
I would like to create a simple fluid layout whereby 4 columns of Equal
I would like to create a simple control that inherits from HeaderedContentControl, and has
I would like to create a simple designer which looks like visual studio. Specifically,
I would like to create an online, simple WYSIWYG drawing editor allowing people to
I would like to create simple C++ calculator using bison and flex. Please note

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.