0

Today I started learning Java GUI and tried to create a simple window on my Ubuntu. I am using jre7 for now. I wrote code exactly from tutorial because from experience there are stuff that doesn't work even if it's correctly typed onto my screen. So, now I used thenewboston's first tutorial with Java GUI. Typed all syntax correctly, classes seems fine, no errors. He got window that was expected - mine only got blank window with no title and no text.

Screenshot with that
(source: scaleengine.net)

Code in JFrames.java file:

import java.awt.FlowLayout; // importē plūstošo skatu / default layout
import javax.swing.JFrame; // dod iespēju piekļūt pamata logu struktūrai
import javax.swing.JLabel; // ļauj rakstīt tekstu logos

public class JFrames extends JFrame {

    private JLabel item1;
    
    public JFrames() {
        super("The Title Of The Program"); // par�?da title bar ar tekstu
        setLayout(new FlowLayout());
        
        item1 = new JLabel("This is sentence with something");
        item1.setToolTipText("This is tooltip on hover");
        add(item1); // pievieno logam šo lietiņu
    }
}

Please, ignore latvian comments, that's just for my reference. So I want to know - why my window appears blank?

1
  • For better help sooner, post an MCVE (Minimal, Complete, Verifiable Example) as opposed to one code snippet and a screenshot of your IDE. Commented Sep 6, 2014 at 4:08

1 Answer 1

5

In the screenshot, your code says:

JFrame frame = new JFrame();

That should be JFrames with an s.

JFrames frame = new JFrames();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.