Why does this code fail in command line?

I am using the "ListDemo" from the java swing tutorial. If I compile it on the command line
javac ListDemo.java
It compiles fine. Then when I run it, it says:
C:\Development\Java\Projects\Projects>java ListDemo
Exception occurred during event dispatching:
java.lang.NoSuchMethodError
at ListDemo.createAndShowGUI(ListDemo.java:196)
at ListDemo.access$400(ListDemo.java:7)
at ListDemo$1.run(ListDemo.java:217)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Yet when I load up the same file into Netbeans, it compiles and runs fine! Here is the file:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
/* ListDemo.java is a 1.4 application that requires no other files. */
public class ListDemo extends JPanel
                      implements ListSelectionListener {
    private JList list;
    private DefaultListModel listModel;
    private static final String hireString = "Hire";
    private static final String fireString = "Fire";
    private JButton fireButton;
    private JTextField employeeName;
    public ListDemo() {
        super(new BorderLayout());
        listModel = new DefaultListModel();
        listModel.addElement("Alan Sommerer");
        listModel.addElement("Alison Huml");
        listModel.addElement("Kathy Walrath");
        listModel.addElement("Lisa Friendly");
        listModel.addElement("Mary Campione");
        listModel.addElement("Sharon Zakhour");
        //Create the list and put it in a scroll pane.
        list = new JList(listModel);
        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        list.setSelectedIndex(0);
        list.addListSelectionListener(this);
        list.setVisibleRowCount(5);
        JScrollPane listScrollPane = new JScrollPane(list);
        JButton hireButton = new JButton(hireString);
        HireListener hireListener = new HireListener(hireButton);
        hireButton.setActionCommand(hireString);
        hireButton.addActionListener(hireListener);
        hireButton.setEnabled(false);
        fireButton = new JButton(fireString);
        fireButton.setActionCommand(fireString);
        fireButton.addActionListener(new FireListener());
        employeeName = new JTextField(10);
        employeeName.addActionListener(hireListener);
        employeeName.getDocument().addDocumentListener(hireListener);
        String name = listModel.getElementAt(
                              list.getSelectedIndex()).toString();
        //Create a panel that uses BoxLayout.
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new BoxLayout(buttonPane,
                                           BoxLayout.LINE_AXIS));
        buttonPane.add(fireButton);
        buttonPane.add(Box.createHorizontalStrut(5));
        buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
        buttonPane.add(Box.createHorizontalStrut(5));
        buttonPane.add(employeeName);
        buttonPane.add(hireButton);
        buttonPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
        add(listScrollPane, BorderLayout.CENTER);
        add(buttonPane, BorderLayout.PAGE_END);
    class FireListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            //This method can be called only if
            //there's a valid selection
            //so go ahead and remove whatever's selected.
            int index = list.getSelectedIndex();
            listModel.remove(index);
            int size = listModel.getSize();
            if (size == 0) { //Nobody's left, disable firing.
                fireButton.setEnabled(false);
            } else { //Select an index.
                if (index == listModel.getSize()) {
                    //removed item in last position
                    index--;
                list.setSelectedIndex(index);
                list.ensureIndexIsVisible(index);
    //This listener is shared by the text field and the hire button.
    class HireListener implements ActionListener, DocumentListener {
        private boolean alreadyEnabled = false;
        private JButton button;
        public HireListener(JButton button) {
            this.button = button;
        //Required by ActionListener.
        public void actionPerformed(ActionEvent e) {
            String name = employeeName.getText();
            //User didn't type in a unique name...
            if (name.equals("") || alreadyInList(name)) {
                Toolkit.getDefaultToolkit().beep();
                employeeName.requestFocusInWindow();
                employeeName.selectAll();
                return;
            int index = list.getSelectedIndex(); //get selected index
            if (index == -1) { //no selection, so insert at beginning
                index = 0;
            } else {           //add after the selected item
                index++;
            listModel.insertElementAt(employeeName.getText(), index);
            //If we just wanted to add to the end, we'd do this:
            //listModel.addElement(employeeName.getText());
            //Reset the text field.
            employeeName.requestFocusInWindow();
            employeeName.setText("");
            //Select the new item and make it visible.
            list.setSelectedIndex(index);
            list.ensureIndexIsVisible(index);
        //This method tests for string equality. You could certainly
        //get more sophisticated about the algorithm.  For example,
        //you might want to ignore white space and capitalization.
        protected boolean alreadyInList(String name) {
            return listModel.contains(name);
        //Required by DocumentListener.
        public void insertUpdate(DocumentEvent e) {
            enableButton();
        //Required by DocumentListener.
        public void removeUpdate(DocumentEvent e) {
            handleEmptyTextField(e);
        //Required by DocumentListener.
        public void changedUpdate(DocumentEvent e) {
            if (!handleEmptyTextField(e)) {
                enableButton();
        private void enableButton() {
            if (!alreadyEnabled) {
                button.setEnabled(true);
        private boolean handleEmptyTextField(DocumentEvent e) {
            if (e.getDocument().getLength() <= 0) {
                button.setEnabled(false);
                alreadyEnabled = false;
                return true;
            return false;
    //This method is required by ListSelectionListener.
    public void valueChanged(ListSelectionEvent e) {
        if (e.getValueIsAdjusting() == false) {
            if (list.getSelectedIndex() == -1) {
            //No selection, disable fire button.
                fireButton.setEnabled(false);
            } else {
            //Selection, enable the fire button.
                fireButton.setEnabled(true);
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
    private static void createAndShowGUI() {
        //Make sure we have nice window decorations.
        JFrame.setDefaultLookAndFeelDecorated(true);
        //Create and set up the window.
        JFrame frame = new JFrame("ListDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Create and set up the content pane.
        JComponent newContentPane = new ListDemo();
        newContentPane.setOpaque(true); //content panes must be opaque
        frame.setContentPane(newContentPane);
        //Display the window.
        frame.pack();
        frame.setVisible(true);
    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();

You are not running this code under JDK 1.4
The setDefaultLookAndFeelDecorated method requires JDK 1.4 version.

Similar Messages

  • Why does this code not work?

    String answer = new String("");
    in = new BufferedReader(new InputStreamReader( connection.getInputStream ()));
    String test = new String("");
    for (int i = 0 ; i < 1000 ; i++)
    answer = in.readLine();
    if (answer == null)
    System.out.println ("null");
    break;
    else
    test += answer;
    System.out.println ("answer: " + answer);
    System.out.println ("test: " + test);
    Many times, the loop will go through 2 iterations but each time, test is only equal to the first answer. The second, third, fourth etc.time it goes through the loop, it should concatenate the value of answer to the end of the string variable test. So why is it that whenever i run the program that has this code, the loop might lloop many times (let's say 2 time) but the value of test is only the first answer, and not the first answer concatenated with the second answer.

    It worked for me...my code looks like this...i used FileInputStream instead of connection..
    import java.io.*;
    class Forum {
      public static void main(String a[]) throws IOException{
        String answer = new String("");
        BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream("hi.txt")));
        String test = new String("");
        for (int i = 0 ; i < 1000 ; i++)
        answer = in.readLine();
        if (answer == null)
        System.out.println ("null");
        break;
        else
        test += answer;
        System.out.println ("answer: " + answer);
        System.out.println ("test: " + test);
    my hi.txt is like this:
    fasd rea reks krie
    fsdfasd
    asdfasd
    sfasdf
    asdfasd
    The output is
    answer: fasd rea reks krie
    answer: fsdfasd
    answer: asdfasd
    answer: sfasdf
    answer: asdfasd
    null
    test: fasd rea reks kriefsdfasdasdfasdsfasdfasdfasd
    Is this not the way u want???

  • Simple Question: Why does this code not exit properly?

    This code is pretty simple. All I want to do is load and play a sound file in an application, but this code to load the sound file does not exit properly. I know that some resources must be allocated which I need to deallocate in order to shut down the process, but I don't know what to call to do a proper shut-down. Any help would be appreciated.
    -adam
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class PlaySoundTest extends java.applet.Applet
    public static void main( java.lang.String[ ] aryArgs )
    java.net.URL urlSound = null;
    try
    urlSound = new java.net.URL( "file:/" + aryArgs[ 0 ] );
    catch( java.net.MalformedURLException murle )
    murle.printStackTrace( );
    System.exit( 1 );
    java.applet.AudioClip acSound = java.applet.Applet.newAudioClip( urlSound );

    HI , If u'r still looking for the solution, this code is working on my system -
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class PlaySoundTest extends java.applet.Applet
    public static void main( java.lang.String[ ] aryArgs ){
    java.net.URL urlSound = null;
    try{  //rahul
    try
    urlSound = new java.net.URL( "file:" + aryArgs[ 0 ] );
    catch( java.net.MalformedURLException murle )
    murle.printStackTrace( );
    System.exit( 1 );
    urlSound = new java.net.URL( "file:" + aryArgs[ 0 ] );
    java.applet.AudioClip acSound = java.applet.Applet.newAudioClip( urlSound );
    if(acSound != null){
    acSound.play();
    catch( Exception murle )
    {        //rahul
    murle.printStackTrace( );
    System.exit( 1 );
    }//main
    The only change I made was in the URL part - file: instead of file:/ .
    The other was of course to play the soundclip ...... :- ) I got really confused the first time I played it .

  • Why does this code always gotoAndStop at the same frame?

    The symbol "alldoor" contains the following six frames in sequential order: "door1","red_door1","door2","red_door2","door3" and "red_door3".
    var doors:Array =["door1", "door2", "door3"];
    var doorSelector:String = doors[newDoors(0, doors.length - 1)]
    function newDoors (min:Number, max:Number):Number
    var  doorColors:Number = Math.round(Math.random() * (min - max) + max);
    return doorColors;
    alldoor.gotoAndStop(doorSelector);
    alldoor.addEventListener(MouseEvent.CLICK,changeColors );
    function changeColors(e:MouseEvent)
        if (e.currentTarget.currentLabel == doorSelector)
            e.currentTarget.gotoAndStop(currentFrame + 1);
         I am attempting to get this code select one of the frames starting with the string "door" at start up. Then, the door should move to the frame
    directly following it on the timeline when clicked. However, as the code is written, the frame always jumps to the second frame in the symbol,regardless of what the current label is. What should I change?

    either:
    1.  those frames aren't loaded when that code executes or
    2.  you don't have those labels on the timeline that contains that code or
    3.  there is other code executing after your goto changing your frame
    use the trace() function to debug and find which is your problem.

  • Repaint() an applet from a swing applet, why does this code not work?

    below are three files that work as planned except for the call to repaint(). This is envoked when a button is hit in one applet and it should repaint another applet. I opened them up in a html file that simply runs both applets. If you could see why the repaint doesn't work I'd love to know. good luck.
    //speech1
    import java.awt.*;
    import java.applet.Applet;
    import java.awt.event.*;
    //java extension packages
    import javax.swing.*;
    public class speechapp1 extends JApplet implements ActionListener{
    // setting up Buttons and Drop down menus
    char a[];
    Choice choicebutton;
    JLabel resultLabel;
    JTextField result;
    JLabel enterLabel;
    JTextField enter;
    JButton pushButton;
    TreeTest PicW;
    // setting up applets G.U.I
    public void init(){
    // Get content pane and set it's layout to FlowLayout
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    // initialise buttons and shit
    a = new char[30];
    choicebutton = new Choice();
    enterLabel = new JLabel("Test");
    enter = new JTextField(30);
    resultLabel= new JLabel("speech label");
    result = new JTextField(30);
    result.setEditable(false);
    // Add items to Choice Button
    choicebutton.addItem("abc");
    choicebutton.addItem("def");
    choicebutton.addItem("ghi");
    choicebutton.addItem("jkl");
    pushButton = new JButton("Click to continue");
    // Add new Tree from file TreeTest.java
    PicW = new TreeTest();
    // Add buttons to container.
    container.add(resultLabel);
    container.add(result);
    container.add(enterLabel);
    System.out.println("");
    container.add(choicebutton);
    System.out.println("");
    container.add(pushButton);
    pushButton.addActionListener(this);
    //choicebutton.addActionListener( this );
    // Set the text in result;
    result.setText("Hello");
    //public void paint(Graphics gg){
    // result.setText("Hello");
    public void actionPerformed(ActionEvent event){
    // continue when action performed on pushButton
    String searchKey = event.getActionCommand();
    System.out.println("");
    if (choicebutton.getSelectedItem().equals("abc"))
    PicW.getPicWeight(1);
    if (choicebutton.getSelectedItem().equals("def"))
    PicW.getPicWeight(2);
    if (choicebutton.getSelectedItem().equals("ghi"))
    PicW.getPicWeight(3);
    if (choicebutton.getSelectedItem().equals("jkl"))
    PicW.getPicWeight(4);
    System.out.println("repainting from actionPerformed method()");
    PicW.repaint();
    import java.applet.Applet;
    import java.awt.*;
    import java.util.*;
    public class TreeTest extends Applet{
    Tree BackgroundImageTree;
    Tree PlayerImageTree;
    Image snow,baby;
    int weight;
    public void getPicWeight(int w){
    weight = w;
    System.out.println("the new weight has been set at: "+weight);
    this.repaint();
    public void init()
    // initialising trees for backgound images and player images
    BackgroundImageTree = new Tree();
    PlayerImageTree = new Tree();
    // initialising images and correcting size of images to correctly fit the screen
    snow = getImage(getDocumentBase(),"snow.gif");
    baby = getImage(getDocumentBase(),"baby.gif");
    // inserting images into correct tree structure
    System.out.println("inserting images into tree: ");
    // inserting background images into tree structure
    BackgroundImageTree.insertImage(1,snow);
    // inserting players into tree structure
    PlayerImageTree.insertImage(1,baby);
    public void paint(Graphics g){
    System.out.println("Searching for selected Image");
    if((BackgroundImageTree.inorderTraversal(1)==null)&&(PlayerImageTree.inorderTraversal(1)==null)){
    System.out.println("There is no tree with the selected value in the trees");
    }else{
    g.drawImage(BackgroundImageTree.inorderTraversal(1),1,3,this);
    //g.drawImage(PlayerImageTree.inorderTraversal(1),55,150,this);
    import java.awt.*;
    import java.applet.Applet;
    class TreeNode {
    TreeNode left;
    Image data;
    TreeNode right;
    int value;
    public TreeNode(int weight,Image picture){
    left = right = null;
    value = weight;
    data = picture;
    public void insert(int v, Image newImage){
    if ( v< value){
    if (left ==null)
    left = new TreeNode(v,newImage);
    else
    left.insert(v,newImage);
    else if (v>value){
    if (right ==null)
    right = new TreeNode(v,newImage);
    else
    right.insert(v, newImage);
    public class Tree{
    private TreeNode root;
    public Tree() {
    root = null;
    public void insertImage(int value, Image newImage){
    if (root == null)
    root = new TreeNode(value,newImage);
    else
    root.insert(value,newImage);
    // in order search of tree.
    public Image inorderTraversal(int n)
    return(inorderHelper(root,n));
    private Image inorderHelper(TreeNode node, int n){
    Image temp = null;
    if (node == null)
    return null;
    if (node.value == n ){
    return(node.data);
    temp = inorderHelper(node.left,n);
    if (temp == null){
    temp = inorderHelper(node.right,n);
    return temp;
    }

    I can fix your problems
    1. You get an error here because you can only invoke the superclass's constructor in the subclass's constructor. It looks like that's what you're trying to do, but you're not doing it right. Constructors don't return any value (actually they do, but it's implied, so you don't need the void that you've got in your code)
    2. I'm not sure, but I think your call to show might be wrong. Move the setsize and setvisible calls to outside of the constructor

  • Why does this script fail with OS X Lion?

    The following AppleScript has been woorking just fine ronning Snow Leopard. Under Lion only the first site is loaded and the other Safari tabs are Untitled. Does anyone know what is wrong and how do I fix it? Thanks for any help.
    Hugh
    ---------------------------------------------------- Non-working script ---------------------------------------------------------------------
    tell application "Safari"
              open location "http://www.macrumors.com/"
              tell window 1 to set current tab to make new tab with properties {URL:"http://www.macworld.com/"}
              tell window 1 to set current tab to make new tab with properties {URL:"http://www.macnn.com/"}
              tell window 1 to set current tab to make new tab with properties {URL:"http://reviews.cnet.com/macfixit/?tag=mfiredir"}
              tell window 1 to set current tab to make new tab with properties {URL:"http://www.macintouch.com/"}
              tell window 1 to set current tab to make new tab with properties {URL:"http://arstechnica.com/apple/"}
              tell window 1 to set current tab to make new tab with properties {URL:"http://www.appleinsider.com/"}
    end tell

    Does anyone know what is wrong and how do I fix it?
    Actually, I don't know why your script fails with Mac OS X Lion. I can only suggest the following workaround, which seems to work properly:
    set myURLs to {"http://www.macworld.com/", "http://www.macnn.com/", "http://reviews.cnet.com/macfixit/?tag=mfiredir", "http://www.macintouch.com/", "http://arstechnica.com/apple/", "http://www.appleinsider.com/"}
    open location "http://www.macrumors.com/"
    tell application "Safari"
        activate
        tell window 1 to repeat with thisURL in myURLs
            set current tab to make new tab
            my newTab(thisURL)
        end repeat
    end tell
    on newTab(theURL)
        tell application "System Events"
            keystroke "l" using command down
            keystroke theURL & return
        end tell
    end newTab

  • Why does this code crash the flash 10.2 plugin?

    A very simple piece of code that causes the flash 10.2 plugin container to crash on all platforms, but does not crash on 10.1 player.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="300" minHeight="200">
         <fx:Script>
              <![CDATA[
                   import mx.controls.Alert;
                   private function crash(type:int, ...additionalArgs):void {
                        var msg:String;
                        switch (type) {
                             case 1: msg = "Crashes!"; break;
                             case 2: msg = additionalArgs[0]; break;
                        Alert.show("Crash : " + msg);
                   private function notCrash(type:int, ...additionalArgs):void {
                        // Does nothing at all, but stops the crash....
                        if (additionalArgs) {}
                        var msg:String;
                        switch (type) {
                             case 1:msg = "Not crash"; break;
                             case 2: msg = additionalArgs[0]; break;
                        Alert.show("NotCrash : " + msg);
              ]]>
         </fx:Script>
         <s:Button label="Does not crash flash" click="notCrash(2,'value')" x="10" y="10"/><s:Button label="Crash flash" click="crash(2,'value')" x="150" y="10"/>
    </s:Application>

    Crash long on Safari :
    Process:         WebKitPluginHost [43418]
    Path:            /System/Library/Frameworks/WebKit.framework/WebKitPluginHost.app/Contents/MacOS/WebKitPluginHost
    Identifier:      com.apple.WebKit.PluginHost
    Version:         6533 (6533.13)
    Build Info:      WebKitPluginHost-75331300~12
    Code Type:       X86 (Native)
    Parent Process:  WebKitPluginAgent [43105]
    PlugIn Path:       /Library/Internet Plug-Ins/Flash Player.plugin/Contents/PlugIns/FlashPlayer-10.6.plugin/Contents/MacOS/FlashPlayer-10.6
    PlugIn Identifier: com.macromedia.FlashPlayer-10.6.plugin
    PlugIn Version:    10.2.152.26 (10.2.152.26)
    Date/Time:       2011-02-22 21:56:12.733 +0200
    OS Version:      Mac OS X 10.6.6 (10J567)
    Report Version:  6
    Exception Type:  EXC_BAD_ACCESS (SIGBUS)
    Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000010
    Crashed Thread:  0  Dispatch queue: com.apple.main-thread
    Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
    0   ...dia.FlashPlayer-10.6.plugin     0x140043ee main + 1461822
    1   ???                                0x1d9db79f 0 + 496875423
    2   ???                                0x1d9db8b3 0 + 496875699
    3   ???                                0x1d9db937 0 + 496875831
    4   ...dia.FlashPlayer-10.6.plugin     0x140068c6 main + 1471254
    5   ...dia.FlashPlayer-10.6.plugin     0x140087d7 main + 1479207
    6   ...dia.FlashPlayer-10.6.plugin     0x13a9f658 0x139ca000 + 874072
    7   ...dia.FlashPlayer-10.6.plugin     0x13a989e1 0x139ca000 + 846305
    8   ...dia.FlashPlayer-10.6.plugin     0x13aa48de 0x139ca000 + 895198
    9   ...dia.FlashPlayer-10.6.plugin     0x13ba6572 0x139ca000 + 1951090
    10  ???                                0x194083b5 0 + 423658421
    11  ???                                0x1c7fee20 0 + 478146080
    12  ???                                0x1dbe2844 0 + 499001412
    13  ???                                0x1db3d61c 0 + 498325020
    14  ???                                0x1db3dcfc 0 + 498326780
    15  ???                                0x1db37b5c 0 + 498301788
    16  ...dia.FlashPlayer-10.6.plugin     0x13a9f658 0x139ca000 + 874072
    17  ...dia.FlashPlayer-10.6.plugin     0x13aa06b6 0x139ca000 + 878262
    18  ...dia.FlashPlayer-10.6.plugin     0x13bb42be 0x139ca000 + 2007742
    19  ...dia.FlashPlayer-10.6.plugin     0x13d407c8 0x139ca000 + 3631048
    20  ...dia.FlashPlayer-10.6.plugin     0x13d40eab 0x139ca000 + 3632811
    21  ...dia.FlashPlayer-10.6.plugin     0x13ea39c7 main + 17431
    22  com.apple.CoreFoundation           0x950184cb __CFRunLoopDoSources0 + 1563
    23  com.apple.CoreFoundation           0x95015f8f __CFRunLoopRun + 1071
    24  com.apple.CoreFoundation           0x95015464 CFRunLoopRunSpecific + 452
    25  com.apple.CoreFoundation           0x95015291 CFRunLoopRunInMode + 97
    26  com.apple.HIToolbox                0x901a8004 RunCurrentEventLoopInMode + 392
    27  com.apple.HIToolbox                0x901a7dbb ReceiveNextEventCommon + 354
    28  com.apple.HIToolbox                0x901a7c40 BlockUntilNextEventMatchingListInMode + 81
    29  com.apple.AppKit                   0x9130978d _DPSNextEvent + 847
    30  com.apple.AppKit                   0x91308fce -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
    31  com.apple.AppKit                   0x912cb247 -[NSApplication run] + 821
    32  com.apple.WebKit.PluginHost        0x1842240f 0x18421000 + 5135
    33  com.apple.WebKit.PluginHost        0x1842204d 0x18421000 + 4173

  • After Effects CC 2014 will not upgrade?  Gets to 100% and then says application failed.  Why does this not upgrade?

    After Effects CC 2014 will not upgrade?  Gets to 100% and then says application failed.  Why does this not upgrade?

    We can't know anything. You have not provided any useful details like system information or the install logs.
    Mylenium

  • Why does this little program crash sometimes?

    I don't know if the code of the program is the most important here, I'm guessing I have to learn some extra things to help the program not crash anymore. But what?
    My question remains, still: Why does this little program crash sometimes?, because I might guess wrong.
    The program is a small application that let's you introduce two numbers in 2 text fields (or if you want, there is also a button that generates some random int numbers to complete the text fields for you), let's you introduces the result of the division of those numbers in another text field, and the result of the multiplication of those numbers in another text field. Then you have another 2 buttons that after being pushed, tell you if you resolved the operations right.
    The application runs fine most of the times, but sometimes it just freezes when I push the button that generates new random numbers.
    Why does this happen? Why does this happen only sometimes and not all the time?

    package my.NumberAddition;
    * @author  zi02
    public class NumberAdditionUI extends javax.swing.JFrame {
        /** Creates new form NumberAdditionUI */
        public NumberAdditionUI() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
        private void initComponents() {
            buttonGroup1 = new javax.swing.ButtonGroup();
            jPanel1 = new javax.swing.JPanel();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jTextField1 = new javax.swing.JTextField();
            jTextField2 = new javax.swing.JTextField();
            jTextField3 = new javax.swing.JTextField();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
            jTextField4 = new javax.swing.JTextField();
            jButton4 = new javax.swing.JButton();
            jTextField5 = new javax.swing.JTextField();
            jLabel4 = new javax.swing.JLabel();
            jTextField6 = new javax.swing.JTextField();
            jButton5 = new javax.swing.JButton();
            jButton3 = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED), "Number Addition", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 153, 204))); // NOI18N
            jLabel1.setText("First Number:");
            jLabel2.setText("Second Number:");
            jLabel3.setText("Multiply:");
            jTextField3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextField3ActionPerformed(evt);
            jButton1.setText("Clear");
            jButton1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
            buttonGroup1.add(jButton1);
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jButton2.setText("Result");
            jButton2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
            buttonGroup1.add(jButton2);
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
            jButton4.setText("Result");
            jButton4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
            buttonGroup1.add(jButton4);
            jButton4.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton4ActionPerformed(evt);
            jLabel4.setText("Divide:");
            jTextField6.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextField6ActionPerformed(evt);
            jButton5.setText("New Numbers");
            jButton5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
            jButton5.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton5ActionPerformed(evt);
            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField6, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jTextField3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButton4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE)
                                .addComponent(jTextField5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(84, 84, 84)
                            .addComponent(jButton5)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jButton1))
                        .addComponent(jTextField2)
                        .addComponent(jTextField1))
                    .addContainerGap())
            jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton1, jButton2, jButton4});
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(jButton2)
                        .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton4)
                        .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel4)
                        .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton1)
                        .addComponent(jButton5))
                    .addContainerGap(15, Short.MAX_VALUE))
            jButton3.setText("Exit");
            jButton3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
            jButton3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton3ActionPerformed(evt);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)
                        .addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton3)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            pack();
        }// </editor-fold>                       
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        System.exit(0);
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        jTextField1.setText("");
        jTextField2.setText("");
        jTextField3.setText("");
        jTextField4.setText("");
        jTextField5.setText("");
        jTextField6.setText("");
        @SuppressWarnings("empty-statement")
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // First we define float variables.
        float num1, num2, num3,  result;
        // We have to parse the text to a type float.
        num1 = Float.parseFloat(jTextField1.getText());
        num2 = Float.parseFloat(jTextField2.getText());
        // Now we can perform the addition.
        num3 = Float.parseFloat(jTextField3.getText());
        // We will now pass the value of result to jTextField3.
        // At the same time, we are going to
        // change the value of result from a float to a string.
        result = num1*num2;
        if (num3==result)
        jTextField5.setText("Correct");
        else jTextField5.setText("Wrong");
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // First we define float variables.
        float num1, num2, num4, result;
        // We have to parse the text to a type float.
        num1 = Float.parseFloat(jTextField1.getText());
        num2 = Float.parseFloat(jTextField2.getText());
        // Now we can perform the addition.
        num4 = Float.parseFloat(jTextField6.getText());
        // We will now pass the value of result to jTextField3.
        // At the same time, we are going to
        // change the value of result from a float to a string.
        result = num1/num2;
        if (num4==result)
        jTextField4.setText("Correct");
        else jTextField4.setText("Wrong");
    private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {                                           
    // TODO add your handling code here:
    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {                                           
    // TODO add your handling code here:
    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        int number1,number2;
        number1 = (int)(Math.random()*100);
        number2 = (int)(Math.random()*100);
        while ((number1 < number2) || (number2 == 0) ||(number2==1)
                || (number1 % number2 !=0))
            number2 = (int)(Math.random()*10);       
        jTextField1.setText(String.valueOf(number1));
        jTextField2.setText(String.valueOf(number2));
        jTextField3.setText("");
        jTextField4.setText("");
        jTextField5.setText("");
        jTextField6.setText("");
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NumberAdditionUI().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.ButtonGroup buttonGroup1;
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton3;
        private javax.swing.JButton jButton4;
        private javax.swing.JButton jButton5;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JTextField jTextField1;
        private javax.swing.JTextField jTextField2;
        private javax.swing.JTextField jTextField3;
        private javax.swing.JTextField jTextField4;
        private javax.swing.JTextField jTextField5;
        private javax.swing.JTextField jTextField6;
        // End of variables declaration                  
    }

  • HT2500 I sometimes get e-mails where the sender sends me several PDF's attachments. These attachments appear already opened on the e-mail unlike most PDF's which I open by clicking on the PDF icon. Why does this happen?

    I sometimes get e-mails with pdf attachments. However instead of opening a PDF icon the body of the e-mail message has the PDF's already opened. Why does this happen? Is there anything I can change on my mac book pro to make these PDF's come thru with their individual icons which can then be opened.

    This is a long-standing design flaw in Apple Mail.
    Prior to Mavericks, this command in Terminal would stop the annoying behavior:
    defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes
    This Terminal command stopped working in Mail 7.1 under Mavericks. I have reported this to Apple as both a feature request and a bug. You should too.
    http://www.apple.com/feeback

  • HP Photosmart C8180 Printer! WHY does this keep happening every day??

    I have only had this for 3 months and it already has problems.
    It keeps telling me its out of paper when it is not.
    i always have at least 20 sheets in there!
    You can hear the rollers going but it can't pick up the paper and I only use high quality A4 paper in there.
    i then have to pull the tray out and push it back in, and yes i have the paper inserted in there correctly
    also, sometimes when i get this "out of paper" message, i ignore it and just press OK and it works fine 
    why does this keep happening?
    this is disgusting coming from a Quality brand like HP
    think its time to go to BBC Watchdog! 
    A printer is an item meant to print. 
    It is generally helpful if a printer recognizes such out-of-the-ordinary, eccentric, unheard-of media such as...oh, I dunno, 8.5 x 11-inch PAPER?????
    It claims repeatedly to have run out of paper. No paper. No paper. Insert paper into paper tray. Now, granted, the minimalist quality of the paper tray--it holds 20 pages, roughly--might convince you that I had indeed used up all my paper; this is not the case. 18 of the 20 sheets are still there. So I readjust that paper, close the tray. It starts to pull in a piece of paper, and then there is the giant crunchy noise of a paper jam in progress. And forget about “easy access” for removing them, either.
    In the months I have had this printer, I don’t believe it has EVER allowed me to print five pages consecutively without some sort of problem.  To me, this is known as an EPIC FAIL. 
    Message Edited by Waynester on 04-16-2009 04:09 PM

    So how is the printer set up?  Is it wireless or USB?  If USB you will need a cable, purchased seperately.  It is a standard A/B USB cable widely available inexpensively.  (The $1 cables form the dollar store work fine....
    Running the diagnostics at http://www.hp.com/go/tools may help resolve the issue.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Why does the pen tool remove previous line when I add new anchor points??

    Why does the pen tool remove previous lines??
    Video here:  http://youtu.be/8AmPUkD88h0 
    It removes the hairline on the face, when I add more anchor points. Why? And how do I correct it?

    The ins and outs of the new and changed behaviors in the re-engineered pen tool have been disussed here on this forum and I'm sure a little detour to the help files will also shed some light on this...
    Mylenium

  • While trying to instal Mountain Lion OS on my macbook pro, I got the error message that my HD was damaged and it reverted to my Lion OS. Why does this happen? I bought the OS online through the app store

    While trying to instal Mountain Lion OS on my macbook pro, I got the error message that my HD was damaged and it reverted to my Lion OS. Why does this happen? I bought the OS online through the app store.

    The Mountain Lion installer looks at your internal drive to make certain that it's error-free before continuing installation. You should have an application named "Install OS X Mountain Lion.app" in your Applications folder now so you shouldn't have to download it again. Do this...
    Boot to your Lion recovery partition by holding down both the Command and the R keys while booting. Open Disk Utility from the Recovery partition and select your hard drive (usually named "Macintosh HD" unless you've renamed it) and click on Verify Disk. If you come up with any errors, click on Repair Disk. At the end of the cycle you will get a message that the disk was successfully repaired or a message that the hard drive could not be repaired.
    If you're able to repair the disk, just reboot as normal and open the "Install OS X Mountain Lion.app" and the installation will proceed. If Disk Utility was unable to repair the disk, you need to get to your local Apple Store as soon as possible so that they can see if the disk is salvageable or beyond repair.
    Good luck,
    Clinton

  • Why does this logo have jagged edges?

    I'm working on a new logo and before I get too far along I need to resolve this issue;  why does this shape have jagged edges when posted on the web?
      you can see it on-line auctionontario.ca
    Thx

    auctioneer,
    Obviously, you are using the transparency available for the GIF format.
    In addition, you should tick the Anti-Aliasing which is, unfortunately, hidden away like a hidden feature in the Image Size window within Save for Web.

  • Why can't I access the command line I just downloaded for xcode?

    Why I can't access the command line I just downloaded for xcode?

    Firefox will not appear in the Market for most phones with incompatible hardware. I believe the Motorola Bravo is supported. You can check if your phone is supported here:
    https://wiki.mozilla.org/Mobile/Platforms/Android
    On some supported devices, a bug prevents Firefox from appearing in the Market. This may be related to the recent Market update. You can go to Settings/Applications and uninstall the Market update, then find and install Firefox.
    Or, you can download the app directly from here:
    http://ftp.mozilla.org/pub/mozilla.org/mobile/releases/4.0b3/android-r7/multi/
    (Note: To download the app directly for an AT&T phone, you will have to search for instructions on how to "sideload" the APK file, since AT&T disables the option to install from non-Market sources.)

Maybe you are looking for