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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:53:06+00:00 2026-06-03T05:53:06+00:00

This is the main class (doesn’t contain the main method) import javax.swing.*; import java.awt.*;

  • 0

This is the “main” class (doesn’t contain the main method)

import javax.swing.*;
import java.awt.*;
//import java.lang.Object;
//import java.awt.event.ActionListener;
//import java.awt.event.;

public class Program {

  public JFrame frame;
  public JPanel header;
  public JPanel text;
  public JPanel body;
  public JTextField input;
  public JButton agregar;

  public List listA;
  public List listB;

  public Program(String title) {
    frame = new JFrame(title);
    frame.setSize(500,600);
    frame.setResizable(false);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(null);

    header = new JPanel();
    header.setBackground(new Color(255,204,50));
    header.setBounds(0,0,500,100);

    text = new JPanel();
    text.setBackground(new Color(255,204,100));
    text.setBounds(0,100,500,50);
    text.setLayout(null);

    //Inicializando la "entrada"
    input = new JTextField(20);
    input.setBounds(50,13,300,25);
    text.add(input);

    agregar = new JButton();
    agregar.setBounds(360,12,80,25);
    agregar.setText("Agregar");
    text.add(agregar);
    //Listo

    body = new JPanel();
    body.setBackground(new Color(255,204,150));
    body.setBounds(0,150,500,450);

    //Lo que está dentro del body
    listA = new List(20);
    body.add(listA);

    listB = new List(20);
    body.add(listB);
    //Listo

    //Añadir todos los paneles al frame principal
    frame.add(header);
    frame.add(text);
    frame.add(body);

  }
}

And this is the MAIN class (This one contains the main method):

public class Main {
  public static void main(String[] args) {
    new Program("Ordenamiento Recursivo");
  }
}

Each time I run the application, the UI components are presented differently, please see attached screen shot.


Well, thanks to everyone who responded the post, I finished the program and I’m very happy with the final result, here it is:

Programa para Moquillaza

In case anyone wants to take a look at the code, here it is: Link

  • 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-03T05:53:07+00:00Added an answer on June 3, 2026 at 5:53 am

    Problems:

    • You’re call setVisible(true) on your JFrame before adding components and this will lead to unreliable drawing of your program’s graphics and is why you are seeing different results. Don’t do this, but rather call it after you’ve added all to the top-level Window.
    • As the others are saying, read up and learn to use the layout managers.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know why this doesn't compile? public class ArrayCompare{ public static void main
in java we can do this: public class A{ public static void main(String...str){ B
I'm creating a website with structure like this: class main { } class mysql
I've built a simple snake game that uses a Main class (this is my
I have this class: class View(object): def main_page(self, extra_placeholders = None): file = '/media/Shared/sites/www/subdomains/pypular/static/layout.tmpl'
First look at this code: class Program { static void Main(string[] args) { var
My coworker did this experiment: public class DoubleDemo { public static void main(String[] args)
Take a look at this code: public class Test { public static void main(String...
For context - read this . Problem: class Program { static void Main() {
Why you can do this in C#? class Test { static void Main() {

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.