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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:10:30+00:00 2026-06-14T21:10:30+00:00

Hi guys I’m planning to create login panel. In that panel should be user

  • 0

Hi guys I’m planning to create login panel. In that panel should be user JLabel, password JLabel, user JTextField, password JTextField, and JButon. I would like to use that button to switch to new JPanel. I’ve read the best way is CardLayout and I’m trying to modify that code:

//Where the GUI is assembled:
//Put the JComboBox in a JPanel to get a nicer look.
JPanel comboBoxPane = new JPanel(); //use FlowLayout
String comboBoxItems[] = { BUTTONPANEL, TEXTPANEL };
JComboBox cb = new JComboBox(comboBoxItems);
cb.setEditable(false);
cb.addItemListener(this);
comboBoxPane.add(cb);
...
pane.add(comboBoxPane, BorderLayout.PAGE_START);
pane.add(cards, BorderLayout.CENTER);
...

//Method came from the ItemListener class implementation,
//contains functionality to process the combo box item selecting
public void itemStateChanged(ItemEvent evt) {
    CardLayout cl = (CardLayout)(cards.getLayout());
    cl.show(cards, (String)evt.getItem());
}

I’m trying to modify that part of code

JComboBox cb = new JComboBox(comboBoxItems);
cb.setEditable(false);
cb.addItemListener(this);
comboBoxPane.add(cb);
pane.add(comboBoxPane, BorderLayout.PAGE_START);
pane.add(cards, BorderLayout.CENTER);

and change it in to:

JButton loginButton = new JButton();
loginButton.addItemListener(this);
comboBoxPane.add(loginButton);
pane.add(loginButton, BorderLayout.PAGE_START);
pane.add(cards, BorderLayout.CENTER);

I can’t use:

JButton loginButton = new JButton(comboBoxItems);

because compiler return error: The constructor JButton(String[]) is undefined

is any one can help me with my problem. I’m newbie in Java programming

  • 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-14T21:10:31+00:00Added an answer on June 14, 2026 at 9:10 pm

    JButton does not have a constructor which takes a String array. It is sufficient to call:

    JButton loginButton = new JButton("Login");
    

    See: Creating a GUI With JFC/Swing

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

Sidebar

Related Questions

guys please help me to create one simple search engine it should be like
guys, I would like to you evaluate next code below. As you see, I
Guys, I'm quite new to extJS and I would like your help. I have
guys, i would like to know if sorl-thumbnail have any option to crop from
guys please post me an example for threading in MFC....it should show the progress
guys i have a xml file which is like this: <Point TestFlag=0 id=1 name=Conversation
guys i got a php file that use it as xml for a flash
Guys, Can you please tell me that ,I wants to learn Azure , by
Guys, I need to develop a tool which would meet following requirements: Input: XHTML
Guys i've got an array thats like this: array(3) { [2]=> array(1) { [name]=>

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.