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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:04:22+00:00 2026-06-06T04:04:22+00:00

I’m just starting out in Java, and only ever used PHP before – finding

  • 0

I’m just starting out in Java, and only ever used PHP before – finding it hard to get my head round the object-orientated thing. I am using the Eclipse IDE.

I am trying to make a program that will tell you your weight on another planet – seems simple enough

All I have done so far is make half the interface in Swing (is that what it’s called?)

Sometimes I run it, and it comes up as I would expect, with the title, textboxes etc….
other times (when absolutely no changes have been made), it just comes up with a blank screen
enter image description here

The image shows what it looks like when it is working. When it’s not working, there are just no objects. It works about 20% of the time.

I think this might have been because of my drop down menu – or JComboBox, this has been such a head ache – Eclipse made me add “< Object>” after each mention of JComboBox – it said “JComboBox is a raw type. References to generic type JComboBox should be parameterized”

I have no idea why this is, and I’m probably just being really thick, sorry if this is a stupid question, but how can I fix this problem, what’s wrong with my code?

package calc;

import javax.swing.*;
import java.awt.*;

public class View extends JFrame {

static String titleText = "Calculate your Mass on another Plannet";

public View(){
    super(titleText);
    setSize(500,400);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);

    FlowLayout flo = new FlowLayout();
    setLayout(flo);

    JPanel inputData = new JPanel();


    //Labels
    JLabel lblTitle = new JLabel (titleText, JLabel.CENTER);
    lblTitle.setFont(new Font("Arial", Font.BOLD, 24));
    JLabel lblInputMass = new JLabel ("Weight", JLabel.LEFT);
    JLabel lblInputUnits = new JLabel("Units");     


    //Input Boxes and Lists
    JTextField txtInputMass = new JTextField(5);

    JComboBox<Object> comInputUnits;
    String arrUnits[] = {"Kilos", "Stone", "Pounds"};
    comInputUnits = new JComboBox<Object>(arrUnits);
    comInputUnits.setSelectedIndex(1);


    //Buttons
    JButton btnCalculate = new JButton("Calculate");

    //Append objects
    add(lblTitle);
    inputData.add(lblInputMass);
    inputData.add(txtInputMass);
    inputData.add(lblInputUnits);
    inputData.add(comInputUnits);
    inputData.add(btnCalculate);

    add(inputData);


}
/**
 * @param args
 */
public static void main(String[] args) {
    View sal = new View();


}

}

Sorry it’s quite a long question, and I’d be so grateful to any suggestions or answers,
as I said, I know barley anything about Java, and am just starting out – thank you 🙂

  • 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-06T04:04:24+00:00Added an answer on June 6, 2026 at 4:04 am

    You should

    • only manipulate Swing components inside the event dispatch thread;
    • call setVisible(true) only after all the components have been added to the frame;
    • spell Planet with only one n, although that’s less important.

    The <Object> that “Eclipse made you add” are called generic types. Read the tutorial on generics.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.