3 Replies - 3463 Views - Last Post: 29 January 2011 - 07:50 PM Rate Topic: -----

#1 Guest_roachmmflhyr*


Reputation:

Java swing app not showing up correctly in Win7

Posted 29 January 2011 - 05:27 PM

I cannot get Java to display my GUI components correctly on Windows 7. Java version "1.6.0_23"
Java™ SE Runtime Environment (build 1.6.0_23-b04)
Java HotSpot™ Client VM (build 19.0-b09, mixed mode, sharing)

I am compiling with the latest and fully updated Netbeans. I can wave the mouse over it and sometimes the missing components will appear. But not always.

I use the same code and same version of Netbeans and Java on Ubuntu 10.10 and it compiled and displays correctly, everytime....hmm odd



This is what it looks like:
Posted Image
import javax.swing.*;

public class Main {

    public static void main(String[] args) {
        //Create a button with text OK
        JButton jbtOK = new JButton("OK");
        //Create a button with text Cancel
        JButton jbtCancel = new JButton("Cancel");
        //Create a label with text "Enter your name: "
        JLabel jlblName = new JLabel("Entere your name: ");
        //Create a text field with text "Type Name Here"
        JTextField jtfName = new JTextField("Type Name Here");
        //Create a check box with text bold
        JCheckBox jchkBold = new JCheckBox("Bold");
        //Create a check box with text Italic
        JCheckBox jchkItalic = new JCheckBox("Italic");
        //Create a radio button with text red
        JRadioButton jrbRed = new JRadioButton("Red");
        //Create a radio button with text yellow
        JRadioButton jrbYellow = new JRadioButton("Yellow");
        //Create a combo box with several choices
        JComboBox jcboColor = new JComboBox(new String[]{"Freshman","Sophomore","Junior","Senior"});

        //Create a panel to group components
        JPanel panel = new JPanel();
        panel.add(jbtOK);
        panel.add(jbtCancel);
        panel.add(jlblName);
        panel.add(jtfName);
        panel.add(jchkBold);
        panel.add(jchkItalic);
        panel.add(jrbRed);
        panel.add(jrbYellow);
        panel.add(jcboColor);

        JFrame frame = new JFrame(); //Create a  frame
        frame.add(panel);
        frame.setTitle("Show GUI components");
        frame.setSize(450,100);
        frame.setLocation(200,100);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);

    }

}




Is This A Good Question/Topic? 0

Replies To: Java swing app not showing up correctly in Win7

#2 eker676  Icon User is offline

  • Software Engineer
  • member icon

Reputation: 378
  • View blog
  • Posts: 1,833
  • Joined: 18-April 09

Re: Java swing app not showing up correctly in Win7

Posted 29 January 2011 - 05:51 PM

Well it works fine on this end.

Have you updated your graphics card drivers lately?
If that doesn't work, try reinstalling the jre.
Was This Post Helpful? 0
  • +
  • -

#3 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2871
  • View blog
  • Posts: 11,026
  • Joined: 15-July 08

Re: Java swing app not showing up correctly in Win7

Posted 29 January 2011 - 06:36 PM

Confirmed it works on Windows 7: 64 bit.

Quote

C:\Users\Stephen>java -version
java version "1.6.0_23"
Java™ SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot™ 64-Bit Server VM (build 19.0-b09, mixed mode)


Will your class compile and run via the command line? I have had issues with Netbeans before, so I would give that a shot before other options.
Was This Post Helpful? 0
  • +
  • -

#4 Guest_roachmmflhyr*


Reputation:

Re: Java swing app not showing up correctly in Win7

Posted 29 January 2011 - 07:50 PM

View PostDogstopper, on 29 January 2011 - 06:36 PM, said:

Confirmed it works on Windows 7: 64 bit.

Quote

C:\Users\Stephen>java -version
java version "1.6.0_23"
Java™ SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot™ 64-Bit Server VM (build 19.0-b09, mixed mode)


Will your class compile and run via the command line? I have had issues with Netbeans before, so I would give that a shot before other options.



Unfortunately, issuing c:\>java -jar myapp.jar renders the same results.
Was This Post Helpful? 0

Page 1 of 1