My listing program can't execute normally, Please HELP me

Hello,
I am in trouble, this is my listing program:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.border.*;
class Server extends JFrame implements DocumentListener, ActionListener
     private JPanel panel1;
private JPanel panel2;
private JTextField field1;
private JTextField field2;
private JTextField field3;
private JLabel label1;
private JLabel label2;
private JLabel label3;
     private JButton button1;
private JButton button2;
private JOptionPane pane1;
     public Server()
          super("Server");
          setTitle( "Port" );
          setSize( 640, 480 );
          setBackground( Color.gray );
          JPanel topPanel     = new JPanel();
          topPanel.setLayout(new GridLayout(2,2));     
          getContentPane().add( topPanel );
          panel1.setLayout(null);
          panel2.setLayout(null);
          /* --- Panel Message Server --- */
          // Components
          JTextField field1 = new JTextField();
          field1.setBounds(150,40,100,25);
          field1.setFocusAccelerator('a');
          panel1.add(field1);
          JLabel label1 = new JLabel("Port Number:");
          label1.setBounds(60, 40, 260, 20);
          label1.setLabelFor(field1);
          label1.setDisplayedMnemonic('A');
          panel1.add(label1);
          Border etched;
          etched = BorderFactory.createEtchedBorder();
     TitledBorder title;
     title = BorderFactory.createTitledBorder(etched, "Message Server");
title.setTitleJustification(TitledBorder.LEFT);
panel1.setBorder(title);
topPanel.add(panel1);
          /* --- Panel Radius Server --- */
          // Components
          JTextField field2 = new JTextField();
field2.setBounds(170, 40, 100, 25);
field2.setFocusAccelerator('b');
          panel2.add(field2);
          JLabel label2 = new JLabel("Authorized Port:");
          label2.setBounds(60, 40, 260, 20);
          label2.setLabelFor(field2);
          label2.setDisplayedMnemonic('B');
          panel2.add(label2);
          JTextField field3 = new JTextField(10);
          field3.setBounds(170, 80, 100, 25);
          field3.setFocusAccelerator('c');                         
panel2.add(field3);
          JLabel label3 = new JLabel("Account Port:");
          label3.setBounds(60, 80, 260, 20);     
          label3.setLabelFor(field3);
          label3.setDisplayedMnemonic('C');
          panel2.add(label3);
Border etched2;
          etched2 = BorderFactory.createEtchedBorder();
     TitledBorder title2;
     title2 = BorderFactory.createTitledBorder(etched2, "Radius Server");
title2.setTitleJustification(TitledBorder.LEFT);
panel2.setBorder(title2);
topPanel.add(panel2);
          /* --- Button components --- */
          JPanel leftcolumn3 = new JPanel();
          leftcolumn3.add(button1);
          button1.setEnabled(false);
          JPanel rightcolumn3 = new JPanel();
          rightcolumn3.add(button2);
          JPanel ButtonPanel = new JPanel();
          //ButtonPanel.setLayout(new BorderLayout());
          ButtonPanel.add(button1);
          ButtonPanel.add(button2);
          topPanel.add(ButtonPanel);
     // Add a document listener to the first field
          Document document =     field1.getDocument();
          document.addDocumentListener( this );
     // Handle keyboard accelerators
     public void     actionPerformed( ActionEvent e )
          // Get the source of the action event
          JLabel label = (JLabel)e.getSource();
          // Give the associated component the focus
          Component fieldComponent = label.getLabelFor();
          fieldComponent.requestFocus();
     // Handle insertions into the text field
     public void     insertUpdate( DocumentEvent event )
          String     sString     = field1.getText();
          try     
               int     iValue = Integer.parseInt( sString );
               button1.setEnabled( true );
          catch( NumberFormatException e )
               JOptionPane.showMessageDialog(pane1,
"Invalid password. Try again.",
"Error Message",
JOptionPane.ERROR_MESSAGE);
     // Handle deletions     from the text field
     public void removeUpdate( DocumentEvent event )
          // Prevent the user     from entering a blank field
          if(     field1.getText().length() == 0 )
               button1.setEnabled( false );
          else
               // Do the same error checking as insertUpdate()
               insertUpdate( event );
     // Handle changes to the text field
     public void changedUpdate( DocumentEvent event )
          // Nothing to do here
     public static void main( String args[] )
          // Create an instance of the test application
          Server window     = new Server();
          window.setVisible( true );
If I execute this file will appear command like:
" Exception in thread "main" java.lang.NullPointerException
at server.<init><server.java:39>
at server.main<server.java:188> "
Would you help me? please get out me from this problem.
thank's

If I execute this file will appear command like:
" Exception in thread "main"
java.lang.NullPointerException
at server.<init><server.java:39></server>
at server.main<server.java:188></server> "The first thing you need to do is take a look at line 39 in server.java. This is where you are getting your NullPointerException. At a guess I'd say its the following line
panel1.setLayout(null);You don't appear to be assigning any value to panel1 before trying to call a method on it.
Col

Similar Messages

Maybe you are looking for

  • For loops and dynamic sql string syntax

    Hi is there a why to loop through a dynamic sql string normally you would have FOR cur IN (select * from emp) LOOP but I have a dynamic sql string called l_sql I have tried the following FOR cur IN l_sql LOOP but I get PLS-00456: item 'L_SQL' is not

  • Updating Mobileme Gallery with iPhoto Library

    I have been using my mobileme gallery to publish photos and to let my friends upload their photos as well. The problem is that when they upload their photos, I am able to see them in my Mobileme gallery, but I am not able to import them to my Library

  • User exit for pricing in Sales Order

    Hi Gurus, I have a requirement while changing Sales Order and an Inquiry.Below is the requirement. I have a custom filed at the Sales Order Item level as VBAP-XXXXX. When the user changes this value to a value (say abc) then the NET value in the Cond

  • Wrong distribution key in profit center planning 7KE1

    I have entered the profit center budget in Transaction 7KE1 for profit centet and account using appropriate profile and layout.  The distribution key appearing is "2" however the cost distribution is as per distribution key "1" (equal distribution). 

  • How to disable Alt-Left Click windowing?

    So, I set up my Magic mouse to take advantage of the "highlight-paste" feature of X11 by having a gesture (click 3 fingers on the mouse) on the mouse do the Alt-Left Click to paste what I've just highlighted.  This gesture is easily done on accident,