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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:56:52+00:00 2026-06-15T21:56:52+00:00

As an improvement to my encryption project I decided to make a little GUI.

  • 0

As an improvement to my encryption project I decided to make a little GUI. However, when I run the program, only the top element shows up on the screen and it appears to obscure the others, though I have no way of checking. Does anyone know why?

Below is my code in its entirety besides e() and d() because those simply encrypt a string and have nothing to do with a GUI. I would also like a way to speed it up as much as possible without editing the encryption, just to make it as great as possbile.

@SuppressWarnings("serial")
public class EncDecExample extends JFrame implements ActionListener {
    final static JPanel top = new JPanel();
    final static JPanel mid = new JPanel();
    final static JPanel bot = new JPanel();
    final static JTextField in = new JTextField(10);
    final static JTextField out = new JTextField(10);
    final static JButton enc = new JButton("Encrypt");
    final static JButton dec = new JButton("Decrypt");
    final static JFrame f = new JFrame("Encryption/decryption");

    public static void main(String[] args) {
//        EncDec.exampleImplement();

        f.setSize(500, 500);
        f.setResizable(false);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        out.setEditable(false);
        out.setText("Hello");
        in.setVisible(true);
        out.setVisible(true);
        enc.setVisible(true);
        dec.setVisible(true);
        top.add(in);
        mid.add(enc);
        mid.add(dec);
        bot.add(out);
        f.add(top);
        f.add(mid);
        f.add(bot);
        f.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == enc && !in.getText().equalsIgnoreCase("")) {
            out.setText(EncDec.e(in.getText(), 5));
        }
        else if(e.getSource() == dec && !in.getText().equalsIgnoreCase("")) {
            out.setText(EncDec.d(in.getText()));
        }
    }
}
  • 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-15T21:56:54+00:00Added an answer on June 15, 2026 at 9:56 pm

    The content pane of a JFrame has a BorderLayout. If you place a component in a BL with no constraints it ends up in the CENTER. The center can only display one component.

    For an immediate effect, I suggest:

    f.add(top, BorderLayout.PAGE_START);
    f.add(mid);
    f.add(bot, BorderLayout.PAGE_END);
    

    Other points.

    1. Take out f.setSize(500, 500); and call pack() immediately before setVisible(true)
    2. For a better way to end the GUI, change f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); to f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    3. in.setVisible(true); Except for the frame itself, take these out. A component automatically becomes visible when it is added to a top level container and that container is itself made visible.
    4. Change
      public class EncDecExample extends JFrame
      to
      public class EncDecExample
      This code keeps a reference to a frame, and that is the right way to go.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I now want to make some interface improvement for ASP.NET project. Example: Show a
How i can make some improvement in my IRC client made in Python. The
I have a program that occasionally needs to scan some directories recursively (an improvement
I need some performance improvement guidance, my query takes several seconds to run and
For reasons of self-improvement / broadening my horizons I have decided to learn some
Type-hints can make a huge improvement on execution time where reflection occurs many times.
For graphics exercises and some self-improvement sorta stuff, i've decided to basically just mess
I am working on an iPhone app improvement project. Original project was done using
My connected sortables work great but I'm trying to make one improvement: If a
I'm trying to make some SEO improvement on my site. I'd like to add

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.