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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:08:28+00:00 2026-05-20T06:08:28+00:00

I am trying to make a applet with a simple login screen, if I

  • 0

I am trying to make a applet with a simple login screen, if I use normal components it works fine but if I use swing components the object wont show up until it is clicked on. I would use regular components but i need a masked password field (if there is a non swing version please let me know).

I am trying to get a vertical placement in the top left corner.

public class RdpApplet extends JApplet {
   JButton Connect;
   JTextField Username;
   JPasswordField Password;
   JLabel UsernameLabel;
   JLabel PasswordLabel;

   //(Snip)

   public void paint(Graphics g){
   }
   public void start(){
   }
   public void stop(){
   }
   public void init(){
       SwingUtilities.invokeLater(new Runnable() {
        public void run() {
           JPanel panel = new JPanel (new GridBagLayout());
           GridBagConstraints gbc = new GridBagConstraints();
           gbc.insets = new Insets(2,5,1,1);
           gbc.weightx = 1.0;
           gbc.anchor = GridBagConstraints.WEST;
           gbc.gridwidth = GridBagConstraints.REMAINDER;

           UsernameLabel = new JLabel("Username:");
           panel.add(UsernameLabel,gbc);

           Username = new JTextField(15);
           panel.add(Username,gbc);

           PasswordLabel = new JLabel("Password:");
           panel.add(PasswordLabel,gbc);

           Password = new JPasswordField(15);
           panel.add(Password,gbc);

           Connect = new JButton("Connect");
           panel.add(Connect,gbc);
           gbc.weighty = 1.0;
           gbc.anchor = gbc.NORTHWEST;

           setLayout(new FlowLayout(FlowLayout.LEFT));
           add(panel);
           validate();
           panel.validate();
       }});
   }

   //(Snip)
}

If I use JButton and JTextField and JLabel the items do not show up until i interact with them(click on the text field, mouse over for the button, I cant get the label to show up) and if I use the normal versions I get the ugly gray backgrounds around the labels.

Can anyone help show me what I am doing wrong to get everything working properly.

EDIT:
Changing from Applet to JApplet did not solve the problem.

EDIT2:
added other methods.

EDIT3:
Cursor now starts in the user name box but everything is still invisible until interacted with. Updated code with all of the latest suggestions.

  • 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-20T06:08:29+00:00Added an answer on May 20, 2026 at 6:08 am

    You are overwriting the paint method without doing anything in there. This causes that the descendants of the applet are not drawn at all.

    In Swing, you should usually never overwrite the paint() method, only the paintComponent() method (and there usually call super.paintComponent(...) somewhere.)

    In your applet it looks like you don’t need the paint method at all, simply delete it.

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

Sidebar

Related Questions

Trying to make this simple applet - the first part just creates a simple
I'm trying to make the case for click-once and smart client development but my
I am trying to make a simple url call. I cannot convert the bytes
I'm trying to make an applet which I can simply drag an image. And
For quite awhile I have been trying to make a simple game in Java
So as a learning exercise, I am trying to make a simple file browser
I'm trying to avoid the default Silverlight loading screen displaying before my applet and
I'm trying to make to make some text appear before my applet loads so
I am trying to make use of a C library in an iPhone project.
trying to make 5 curl childs for curl handler and defining them, but can't

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.