Now its not recreating a window

In my Jdesktop i have one internatframe and when I press evaluate it should display a new window or frame, why is this not working
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.awt.Color;
import java.awt.Graphics;
class GUI
     private static JTextField field1;
     private static JLabel statusLabel; // Label for status/result info
private static JLabel outputinfix;
private static JLabel minimumValue;
private static JLabel outputpostfix;
private static JLabel outputsolver;
private static String result="";
     private static JInternalFrame fr2;
     private static JDesktopPane desktop;
     private static JFrame f;
     public static void main(String[] args)
     JFrame f = new JFrame("");
          ActionHandler action = new ActionHandler();
          /*Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          screenSize.width -=42;
          screenSize.height -= 42;*/
          f.setSize(1024,768);
          f.setLocation(20,20);
          f.setVisible(true);
     desktop = new JDesktopPane();
          desktop.setPreferredSize(new Dimension(1024, 768));
          desktop.setBackground(new Color(148,102,75));
          desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
          f.setContentPane(desktop);
          final JInternalFrame fr = new JInternalFrame("infix", false, true, true, true);
          fr.setSize(203, 126);
          fr.setLocation(50, 50);
          fr.setVisible(true);
          fr.setOpaque(false);
          fr.setBackground(new Color(100,0,255,140));
     JPanel panel = new JPanel();
          panel.setLayout(new BorderLayout());
     //panel.setLayout(new BorderLayout(0,0));
          panel.setSize(203,126);
          panel.setBackground(new Color(0,0,255,140));
          panel.setOpaque(false);
          JTextField field1 = new JTextField("",60);
          field1.setPreferredSize(new Dimension(200, 21));
          panel.add(field1,BorderLayout.NORTH);
          JButton evaluate = new JButton("Evaluate");
          evaluate.addActionListener(action);
          evaluate.setPreferredSize(new Dimension(101,25));
          panel.add(evaluate,BorderLayout.CENTER);
          JButton clear = new JButton("Clear");
          clear.addActionListener(action);
          clear.setPreferredSize(new Dimension(101,25));
          panel.add(clear,BorderLayout.EAST);
     JLabel label = new JLabel("");
          label.setPreferredSize(new Dimension(34,50));
          panel.add(label,BorderLayout.SOUTH);
          fr.add(panel);     
          desktop.add(fr);
          JInternalFrame fr2 = new JInternalFrame("test", true, true, true,false);
          fr2.setSize(230, 300);
          fr2.setLocation(50, 50);
          fr2.setVisible(true);
          fr2.setOpaque(false);
          fr2.setBackground(new Color(0,0,255,140));
     JPanel panel2 = new JPanel();
     panel2.setLayout(new BorderLayout(0, 0));
          fr2.add(panel2);
          desktop.add(fr2);*/
                    f.add(desktop);
     private static class ActionHandler implements ActionListener
          public void actionPerformed(ActionEvent event)
               if(event.getActionCommand().equals("Evaluate"))
               Infixtopost theTrans = new Infixtopost(field1.getText());
               result= theTrans.Trans();
               outputpostfix.setText(result);
               outputinfix.setText(field1.getText());
               JInternalFrame fr2 = new JInternalFrame("test", true, true, true,false);
          fr2.setSize(230, 300);
          fr2.setLocation(50, 50);
          fr2.setVisible(true);
     fr2.setOpaque(false);
          fr2.setBackground(new Color(0,0,255,140));
     JPanel panel2 = new JPanel();
     panel2.setLayout(new BorderLayout(0, 0));
          fr2.add(panel2);
          desktop.add(fr2);
          f.add(desktop);
               else if(event.getActionCommand().equals("Clear"))
                    System.out.println("this is a test2");
     }

when I try that I get this
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
here is so new code
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.awt.Color;
import java.awt.Graphics;
class GUI
     private static JTextField field1;
     private static JLabel statusLabel; // Label for status/result info
private static JLabel outputinfix;
private static JLabel minimumValue;
private static JLabel outputpostfix;
private static JLabel outputsolver;
private static String result="";
     private static JInternalFrame fr2;
     private static JDesktopPane desktop;
     private static JFrame f;
     public static void main(String[] args)
     JFrame f = new JFrame("");
          ActionHandler action = new ActionHandler();
          /*Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          screenSize.width -=42;
          screenSize.height -= 42;*/
          f.setSize(1024,768);
          f.setLocation(20,20);
          f.setVisible(true);
     desktop = new JDesktopPane();
          desktop.setPreferredSize(new Dimension(1024, 768));
          int backcolor = (int)(Math.random()*100);
          desktop.setBackground(new Color(backcolor,backcolor,backcolor+78));
          desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
          f.setContentPane(desktop);
          final JInternalFrame fr = new JInternalFrame("infix", true, false, true, true);
          fr.setSize(203, 126);
          fr.setLocation(50, 50);
          fr.setVisible(true);
          fr.setOpaque(false);
          fr.setBackground(new Color(100,0,255,140));
     JPanel panel = new JPanel();
          panel.setLayout(new BorderLayout());
     //panel.setLayout(new BorderLayout(0,0));
          panel.setSize(203,126);
          panel.setBackground(new Color(0,0,255,140));
          panel.setOpaque(false);
          JTextField field1 = new JTextField("",60);
          field1.setPreferredSize(new Dimension(200, 21));
          panel.add(field1,BorderLayout.NORTH);
          JButton evaluate = new JButton("Evaluate");
          evaluate.addActionListener(action);
          evaluate.setPreferredSize(new Dimension(101,25));
          panel.add(evaluate,BorderLayout.CENTER);
          JButton clear = new JButton("Clear");
          clear.addActionListener(action);
          clear.setPreferredSize(new Dimension(101,25));
          panel.add(clear,BorderLayout.EAST);
     JLabel label = new JLabel("");
          label.setPreferredSize(new Dimension(34,50));
          panel.add(label,BorderLayout.SOUTH);
          fr.add(panel);     
          desktop.add(fr);
          f.add(desktop);
     private static class ActionHandler implements ActionListener
          public void actionPerformed(ActionEvent event)
               if(event.getActionCommand().equals("Evaluate"))
          //     Infixtopost theTrans = new Infixtopost(field1.getText());
               //result= theTrans.Trans();
               //outputpostfix.setText(result);
               //outputinfix.setText(field1.getText());
               result = field1.getText();
               System.out.println(result);
                    int r = (int)(Math.random()*300);
                    int g = (int)(Math.random()*300);
                    int b = (int)(Math.random()*300);
                    int p = (int)(Math.random()*700);
                    int p2 =(int)(Math.random()*700);
                    JInternalFrame fr2 = new JInternalFrame("test", true, true, true,true);
                    fr2.setSize(203, 126);
                    fr2.setLocation(p ,p2);
                    fr2.setVisible(true);
                    fr2.setOpaque(false);
                    fr2.setBackground(new Color(r,g,b,140));
               JPanel panel2 = new JPanel();
               panel2.setLayout(new BorderLayout(0, 0));
                    panel2.setSize(203,126);
                    panel2.setBackground(new Color(r,g,b,140));
                    panel2.setOpaque(false);
                    fr2.add(panel2);
                    desktop.add(fr2);
                    f.add(desktop);
               else if(event.getActionCommand().equals("Clear"))
               fr2.invalidate();
                    System.out.println("this is a test2");
now if I comment out the result=field.getText(); then I can recreate windows,

Similar Messages

Maybe you are looking for

  • How to print the text in points wise in sap script

    hi friends, how to print the text in points wise in sap script. ex: if suppose paragraph consists of 15 lines. then according to one sentence or one fullstop (.) it should give point 1. like that... 1. hai how ru. 2. what r  u doing. 3.where r u. lik

  • MAPToolkit 9.1 Installation on Windows 2008 R2 Std SP1 64-bit fails

    Hi, I tried an installation of the MAPToolkit V9.1 on Windows 2008 R2 SP1 with an SQL Server 2012 MAPS instance installed, but it fails with: Applying execute package: MAPSetup_x64.msi, action: Install,  path: C:\ProgramData\Package Cache\{D1E2ED68-9

  • What's wrong with this save method

    It won't let me add any new records to my database. Please help      String sql = "insert into Sold_Vehicles(Serial_Number, Owner_Name, Make, Address, Model, Phone_Number, Year, Drivers_License_Number, Kilometers, Date_Purchased, Transmission, Warran

  • Previous weeks data

    Hi all, I have a requirement where I need to show the Unbilled amount of this week as well as last 20 weeks based on region. Let say I am on fiscal week 20. Now if create a report based on region and Unbilled amount I will get $ 20 for europe. Now if

  • Folio Builder Panel Sign in failed. Please try again.

    I am not able to sign in to Folio Builder Panel in Indesign CS5.5 Anyone facing the same issue now?