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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:46:19+00:00 2026-06-03T02:46:19+00:00

I wish to display my gui in the main method however it doesn’t seem

  • 0

I wish to display my gui in the main method however it doesn’t seem to do so…
I’ve used the suggestion here:
jformdesigner design it won't display?

But that did not work,

My error at the moment is that eclipse is suggesting I need to create a method called setDefaultCloseOperation which is already defined in the class and the same for the setvisible.

“The method setDefaultCloseOperation(int) is undefined for the type bmicalc

The method setVisible(boolean) is undefined for the type bmicalc”

main method:

import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.WindowConstants;

public class iu {
public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            bmicalc GUI = new bmicalc();
            GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            GUI.setVisible(true);
        }
    });
class bmicalc extends JFrame{

public bmicalc() {
    initComponents();

}
private void initComponents() {
    JFrame bmiCalculatorFrame = new JFrame();
    {
        bmiCalculatorFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        bmiCalculatorFrame.setTitle("BMI Calculator");
        Container bmiCalculatorFrameContentPane = bmiCalculatorFrame.getContentPane();
        bmiCalculatorFrameContentPane.setLayout(new GridLayout());
    }
}}}}
  • 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-03T02:46:21+00:00Added an answer on June 3, 2026 at 2:46 am

    Your bmicalc class should extend JFrame, but it is not. setDefaultCloseOperation and setVisible methods belong to JFrame.

    Also, it is not very clear, but it looks like the JFormDesigner generated another JFrame.

    EDIT:

    Here is a example of JFrame generated by JFormDesigner:

    public class TestFrame extends JFrame {
         public static void main(String[] args) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        TestFrame frame = new TestFrame();
                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        frame.setVisible(true);
                    }
                });
         }
    
        public TestFrame() {
            initComponents();
        }
    
        private void initComponents() {
            // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    
            //======== this ========
            Container contentPane = getContentPane();
            contentPane.setLayout(new FormLayout(
                "default",
                "default"));
            pack();
            setLocationRelativeTo(getOwner());
            // JFormDesigner - End of component initialization  //GEN-END:initComponents
        }
    
        // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
        // JFormDesigner - End of variables declaration  //GEN-END:variables
    }
    

    EDIT – according to the last question edit

    To address your compilation issues see the snippet below. However, it is not clear what are you trying to achieve with JFrame bmiCalculatorFrame.

    class bmicalc extends JFrame{
    
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                bmicalc GUI = new bmicalc();
                GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                GUI.setVisible(true);
            }
        });
    }
    
    public bmicalc() {
        initComponents();
    
    }
    
    private void initComponents() {
        //............
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please can anyone help me out here, I wish to display the following: for
On my main window I have a DataGridView that I wish to display my
I wish to display icon into the spark combobox main area. I can display
I am making an Android app within which I wish to display ads, however
I wish to display content depending on the given role(s) of the active user
I have two panels that i wish to display to the user. I decided
I have a website with live stats that I wish to display to every
Under certain circumstances, I wish to display an error message to the user if
I wish to add a singleton method to a particular object. I wish that
I wish to get a list of all strings that are used in a

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.