Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0

    Default i keep getting an Exception

    ok so every time i run the second code i move the slider and when i release the mouse it makes
    the Exception the reason it dose it when i release the mouse is because of the"!" i added that
    to see if it was that "if" statement or not so without it as soon as the value changes it make the Exception and it never put the value into the formatted text field the first bit of code works and i made it the same way as fare as i can tell so could some one tell me why im getting the Exception i really dont wont to reweight it


    the first code works!

    Java Code:
    import java.awt.EventQueue;
    
    import javax.swing.JFrame;
    import javax.swing.JSlider;
    import java.awt.BorderLayout;
    import javax.swing.JTextField;
    import javax.swing.event.ChangeListener;
    import javax.swing.event.ChangeEvent;
    import javax.swing.text.JTextComponent;
    import javax.swing.JFormattedTextField;
    import javax.swing.SwingConstants;
    
    
    public class Controller {
    
    	private JFrame frame;
    	private JTextField a_tf_1;
    	private JSlider a_s_2;
    	private JFormattedTextField a_ftf_1;
    
    	/**
    	 * Launch the application.
    	 */
    	public static void main(String[] args) {
    		EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				try {
    					Controller window = new Controller();
    					window.frame.setVisible(true);
    				} catch (Exception e) {
    					e.printStackTrace();
    				}
    			}
    		});
    	}
    
    	/**
    	 * Create the application.
    	 */
    	public Controller() {
    		initialize();
    	}
    
    	/**
    	 * Initialize the contents of the frame.
    	 */
    	private void initialize() {
    		frame = new JFrame();
    		frame.setBounds(100, 100, 450, 300);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		
    		JSlider a_s_1 = new JSlider();
    		a_s_1.setValue(0);
    		a_s_1.setOrientation(SwingConstants.VERTICAL);
    		a_s_1.addChangeListener(new ChangeListener() {
    			 
    
    			public void stateChanged(ChangeEvent evt) {
    			        JSlider slider = (JSlider)evt.getSource();
    
    			        if (slider.getValueIsAdjusting()) {
    			            
    			           int value = slider.getValue();
    			             String val_str = Integer.toString(value);
    			             a_tf_1.setText(val_str);
    			        }
    			}
    		});
    		frame.getContentPane().add(a_s_1, BorderLayout.CENTER);
    		
    		a_tf_1 = new JTextField("0");
    		frame.getContentPane().add(a_tf_1, BorderLayout.NORTH);
    		a_tf_1.setColumns(10);
    		
    		a_s_2 = new JSlider();
    		a_s_2.setValue(0);
    		a_s_2.setOrientation(SwingConstants.VERTICAL);
    		a_s_2.addChangeListener(new ChangeListener() {
    			public void stateChanged(ChangeEvent evt) {
    		        JSlider slider = (JSlider)evt.getSource();
    
    		        if (slider.getValueIsAdjusting()) {
    		            
    		           int value = slider.getValue();
    		             String val_str = Integer.toString(value);
    		             a_ftf_1.setText(val_str);
    		        }
    			}
    		});
    		frame.getContentPane().add(a_s_2, BorderLayout.WEST);
    		
    		a_ftf_1 = new JFormattedTextField("0");
    		frame.getContentPane().add(a_ftf_1, BorderLayout.SOUTH);
    	}
    
    }



    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at fanui$2.stateChanged(fanui.java:82)
    at javax.swing.JSlider.fireStateChanged(Unknown Source)
    at javax.swing.JSlider$ModelListener.stateChanged(Unk nown Source)
    at javax.swing.DefaultBoundedRangeModel.fireStateChan ged(Unknown Source)
    at javax.swing.DefaultBoundedRangeModel.setRangePrope rties(Unknown Source)
    at javax.swing.DefaultBoundedRangeModel.setValueIsAdj usting(Unknown Source)
    at javax.swing.JSlider.setValueIsAdjusting(Unknown Source)
    at javax.swing.plaf.basic.BasicSliderUI$TrackListener .mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)




    Java Code:
    import java.awt.EventQueue;
    
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.border.EmptyBorder;
    import javax.swing.JTabbedPane;
    import javax.swing.JSlider;
    import javax.swing.JTextArea;
    
    import javax.swing.SwingConstants;
    import java.awt.Color;
    import javax.swing.JFormattedTextField;
    import javax.swing.JLabel;
    import java.awt.Font;
    import javax.swing.JCheckBox;
    import javax.swing.event.ChangeListener;
    import javax.swing.event.ChangeEvent;
    
    
    public class fanui extends JFrame  {
         
    	private JFormattedTextField    a_per_1;
         String val_str;
         
    	private static final long serialVersionUID = 1L;
    
    	
    	public static void main(String[] args) {
    		EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				try {
    					fanui frame = new fanui();
    					frame.setVisible(true);
    				} catch (Exception e) {
    					e.printStackTrace();
    				}
    			}
    		});
    	} 
    
    	
    	public fanui()     {
    		super ("Fan Controller" ) ;
    		
    		setResizable(false);
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setBounds(100, 100, 630, 492);
    		JPanel contentPane = new JPanel();
    		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    		setContentPane(contentPane);
    		contentPane.setLayout(null);	
    		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    		tabbedPane.setBounds(0, 0, 625, 465);
    		contentPane.add(tabbedPane);
    		
    		JPanel panel = new JPanel();
    		panel.setBackground(Color.WHITE);
    		tabbedPane.addTab("New tab", null, panel, null);
    		
    		JPanel panel_1 = new JPanel();
    		panel_1.setBackground(Color.WHITE);
    		tabbedPane.addTab("New tab", null, panel_1, null);
    		panel_1.setLayout(null);
    		
    		final JSlider a1val = new JSlider(); 
    		a1val.setValue(100);
    		a1val.setOrientation(SwingConstants.VERTICAL);
    		a1val.setBounds(30, 24, 18, 100);
    		panel_1.add(a1val);
    		
    		a1val.addChangeListener(new ChangeListener() {
    		    
    
    			// This method is called whenever the slider's value is changed
    		    public void stateChanged(ChangeEvent evt) {
    		        JSlider slider = (JSlider)evt.getSource();
    
    		        if (!slider.getValueIsAdjusting()) {
    		            
    		           int value = slider.getValue();
    		             val_str = Integer.toString(value);
    		             a_per_1.setText(val_str);
    		        }
    			}
    		});
    		
            
    		
    		JSlider a_s_2 = new JSlider(); 
    		a_s_2.setValue(100);
    		a_s_2.setOrientation(SwingConstants.VERTICAL);
    		a_s_2.setBounds(50, 24, 18, 100);
    		panel_1.add(a_s_2);
    		
    		JFormattedTextField a_temp_2 = new JFormattedTextField();
    		a_temp_2.setText("25");
    		a_temp_2.setBounds(50, 124, 20, 20);
    		panel_1.add(a_temp_2);
    		
    		JFormattedTextField a_temp_1 = new JFormattedTextField();
    		a_temp_1.setText("20");
    		a_temp_1.setBounds(30, 124, 20, 20);
    		panel_1.add(a_temp_1);
    		
    		JSlider a_s_3 = new JSlider();
    		a_s_3.setValue(100);
    		a_s_3.setOrientation(SwingConstants.VERTICAL);
    		a_s_3.setBounds(70, 24, 18, 100);
    		panel_1.add(a_s_3);
    		
    		JFormattedTextField a_temp_3 = new JFormattedTextField();
    		a_temp_3.setText("30");
    		a_temp_3.setBounds(70, 124, 20, 20);
    		panel_1.add(a_temp_3);
    		
    		JLabel label = new JLabel("100%");
    		label.setFont(new Font("Dialog", Font.BOLD, 10));
    		label.setBounds(4, 24, 28, 16);
    		panel_1.add(label);
    		
    		JLabel label_1 = new JLabel("0%");
    		label_1.setFont(new Font("Dialog", Font.BOLD, 10));
    		label_1.setBounds(14, 108, 18, 16);
    		panel_1.add(label_1);
    		
    		JSlider a_s_4 = new JSlider();
    		a_s_4.setValue(100);
    		a_s_4.setOrientation(SwingConstants.VERTICAL);
    		a_s_4.setBounds(90, 24, 18, 100);
    		panel_1.add(a_s_4);
    		
    	  		
    		JFormattedTextField a_temp_4 = new JFormattedTextField();
    		a_temp_4.setText("35");
    		a_temp_4.setBounds(90, 124, 20, 20);
    		panel_1.add(a_temp_4);
    		
    		JSlider a_s_5 = new JSlider();
    		a_s_5.setValue(100);
    		a_s_5.setOrientation(SwingConstants.VERTICAL);
    		a_s_5.setBounds(110, 24, 18, 100);
    		panel_1.add(a_s_5);
    		
    		JFormattedTextField a_temp_5 = new JFormattedTextField();
    		a_temp_5.setText("40");
    		a_temp_5.setBounds(110, 124, 20, 20);
    		panel_1.add(a_temp_5);
    		
    		JSlider a_s_6 = new JSlider();
    		a_s_6.setValue(100);
    		a_s_6.setOrientation(SwingConstants.VERTICAL);
    		a_s_6.setBounds(130, 24, 18, 100);
    		panel_1.add(a_s_6);
    		
    		JFormattedTextField a_temp_6 = new JFormattedTextField();
    		a_temp_6.setText("45");
    		a_temp_6.setBounds(130, 124, 20, 20);
    		panel_1.add(a_temp_6);
    		
    		JFormattedTextField a_per_1 = new JFormattedTextField();
    		a_per_1.setText(val_str);
    		a_per_1.setBounds(30, 4, 20, 20);
    		panel_1.add(a_per_1);
    		
    		JFormattedTextField a_per_2 = new JFormattedTextField();
    		a_per_2.setText("00");
    		a_per_2.setBounds(50, 4, 20, 20);
    		panel_1.add(a_per_2);
    		
    		JFormattedTextField a_per_3 = new JFormattedTextField();
    		a_per_3.setText("00");
    		a_per_3.setBounds(70, 4, 20, 20);
    		panel_1.add(a_per_3);
    		
    		JFormattedTextField a_per_4 = new JFormattedTextField();
    		a_per_4.setText("00");
    		a_per_4.setBounds(90, 4, 20, 20);
    		panel_1.add(a_per_4);
    		
    		JFormattedTextField a_per_5 = new JFormattedTextField();
    		a_per_5.setText("00");
    		a_per_5.setBounds(110, 4, 20, 20);
    		panel_1.add(a_per_5);
    		
    		JFormattedTextField a_per_6 = new JFormattedTextField();
    		a_per_6.setText("00");
    		a_per_6.setBounds(130, 4, 20, 20);
    		panel_1.add(a_per_6);
    		
    		JLabel label_2 = new JLabel("00=100%");
    		label_2.setFont(new Font("Dialog", Font.BOLD, 10));
    		label_2.setBounds(156, 24, 45, 20);
    		panel_1.add(label_2);
    		
    		JFormattedTextField frmtdtxtfldNameOfTemp = new JFormattedTextField();
    		frmtdtxtfldNameOfTemp.setText("name of temp sensor to be used");
    		frmtdtxtfldNameOfTemp.setBounds(4, 146, 197, 18);
    		panel_1.add(frmtdtxtfldNameOfTemp);
    		
    		JFormattedTextField frmtdtxtfldFanName = new JFormattedTextField();
    		frmtdtxtfldFanName.setText("name of fan to be used");
    		frmtdtxtfldFanName.setBounds(4, 166, 197, 18);
    		panel_1.add(frmtdtxtfldFanName);
    		
    		JCheckBox chckbxNewCheckBox_1 = new JCheckBox("fan off min temp reached ");
    		chckbxNewCheckBox_1.setFont(new Font("Dialog", Font.BOLD, 10));
    		chckbxNewCheckBox_1.setBounds(4, 186, 197, 22);
    		panel_1.add(chckbxNewCheckBox_1);
    		
    		JLabel label_3 = new JLabel("%");
    		label_3.setBounds(152, 6, 18, 16);
    		panel_1.add(label_3);
    		
    		JCheckBox chckbxNewCheckBox_2 = new JCheckBox("");
    		chckbxNewCheckBox_2.setSelected(true);
    		chckbxNewCheckBox_2.setFont(new Font("Dialog", Font.BOLD, 10));
    		chckbxNewCheckBox_2.setBounds(194, 60, 20, 20);
    		panel_1.add(chckbxNewCheckBox_2);
    		
    		JLabel lblFanPort = new JLabel("fan port 1");
    		lblFanPort.setBounds(244, 86, 55, 20);
    		panel_1.add(lblFanPort);
    		
    		JLabel lblNewLabel = new JLabel("fan port 2");
    		lblNewLabel.setBounds(244, 106, 55, 20);
    		panel_1.add(lblNewLabel);
    		
    		JLabel lblFanPort_1 = new JLabel("fan port 3");
    		lblFanPort_1.setBounds(244, 126, 55, 20);
    		panel_1.add(lblFanPort_1);
    		
    		JLabel lblFanPort_2 = new JLabel("fan port 4");
    		lblFanPort_2.setBounds(244, 146, 55, 20);
    		panel_1.add(lblFanPort_2);
    		
    		JFormattedTextField frmtdtxtfldFan = new JFormattedTextField();
    		frmtdtxtfldFan.setText("fan1");
    		frmtdtxtfldFan.setBounds(300, 86, 100, 20);
    		panel_1.add(frmtdtxtfldFan);
    		
    		JFormattedTextField frmtdtxtfldFam = new JFormattedTextField();
    		frmtdtxtfldFam.setText("fan 2");
    		frmtdtxtfldFam.setBounds(300, 106, 100, 20);
    		panel_1.add(frmtdtxtfldFam);
    		
    		JFormattedTextField frmtdtxtfldFan_1 = new JFormattedTextField();
    		frmtdtxtfldFan_1.setText("fan 3");
    		frmtdtxtfldFan_1.setBounds(300, 126, 100, 20);
    		panel_1.add(frmtdtxtfldFan_1);
    		
    		JFormattedTextField frmtdtxtfldFan_2 = new JFormattedTextField();
    		frmtdtxtfldFan_2.setText("fan 4");
    		frmtdtxtfldFan_2.setBounds(300, 146, 100, 20);
    		panel_1.add(frmtdtxtfldFan_2);
    		
    		JLabel lblTempSensor = new JLabel("temp sensor 1");
    		lblTempSensor.setBounds(217, 166, 82, 20);
    		panel_1.add(lblTempSensor);
    		
    		JFormattedTextField frmtdtxtfldTempSensor = new JFormattedTextField();
    		frmtdtxtfldTempSensor.setText("temp sensor 1");
    		frmtdtxtfldTempSensor.setBounds(300, 166, 100, 20);
    		panel_1.add(frmtdtxtfldTempSensor);
    		
    		JLabel lblNewLabel_1 = new JLabel("temp sensor 2");
    		lblNewLabel_1.setBounds(217, 186, 82, 20);
    		panel_1.add(lblNewLabel_1);
    		
    		JFormattedTextField frmtdtxtfldTempSensor_1 = new JFormattedTextField();
    		frmtdtxtfldTempSensor_1.setText("temp sensor 2");
    		frmtdtxtfldTempSensor_1.setBounds(300, 186, 100, 20);
    		panel_1.add(frmtdtxtfldTempSensor_1);
    		
    		JLabel lblFixed = new JLabel("fixed %");
    		lblFixed.setBounds(150, 60, 45, 16);
    		panel_1.add(lblFixed);
    		
    		JFormattedTextField formattedTextField_12 = new JFormattedTextField();
    		formattedTextField_12.setText("100%");
    		formattedTextField_12.setBounds(156, 86, 45, 20);
    		panel_1.add(formattedTextField_12);
    		
    		JTextArea txtrNameFansAnd = new JTextArea();
    		txtrNameFansAnd.setText("name fans and sensors \r\nor leave them default ");
    		txtrNameFansAnd.setBounds(253, 43, 135, 37);
    		panel_1.add(txtrNameFansAnd);
    		
    		JLabel label_4 = new JLabel("100%");
    		label_4.setFont(new Font("Dialog", Font.BOLD, 10));
    		label_4.setBounds(404, 24, 28, 16);
    		panel_1.add(label_4);
    		
    		JLabel label_5 = new JLabel("0%");
    		label_5.setFont(new Font("Dialog", Font.BOLD, 10));
    		label_5.setBounds(414, 108, 18, 16);
    		panel_1.add(label_5);
    		
    		JSlider b_s_1 = new JSlider();
    		b_s_1.setValue(100);
    		b_s_1.setOrientation(SwingConstants.VERTICAL);
    		b_s_1.setBounds(430, 24, 18, 100);
    		panel_1.add(b_s_1);
    		
    		JSlider b_s_2 = new JSlider();
    		b_s_2.setOrientation(SwingConstants.VERTICAL);
    		b_s_2.setValue(100);
    		b_s_2.setBounds(450, 24, 18, 100);
    		panel_1.add(b_s_2);
    		
    		JSlider b_s_3 = new JSlider();
    		b_s_3.setOrientation(SwingConstants.VERTICAL);
    		b_s_3.setValue(100);
    		b_s_3.setBounds(470, 24, 18, 100);
    		panel_1.add(b_s_3);
    		
    		JSlider b_s_4 = new JSlider();
    		b_s_4.setValue(100);
    		b_s_4.setOrientation(SwingConstants.VERTICAL);
    		b_s_4.setBounds(490, 24, 18, 100);
    		panel_1.add(b_s_4);
    		
    		JSlider b_s_5 = new JSlider();
    		b_s_5.setValue(100);
    		b_s_5.setOrientation(SwingConstants.VERTICAL);
    		b_s_5.setBounds(510, 24, 18, 100);
    		panel_1.add(b_s_5);
    		
    		JSlider b_s_6 = new JSlider();
    		b_s_6.setOrientation(SwingConstants.VERTICAL);
    		b_s_6.setValue(100);
    		b_s_6.setBounds(530, 24, 18, 100);
    		panel_1.add(b_s_6);
    		
    		JFormattedTextField b_per_2 = new JFormattedTextField();
    		b_per_2.setText("00");
    		b_per_2.setBounds(430, 4, 20, 20);
    		panel_1.add(b_per_2);
    		
    		JFormattedTextField b_per_2_1 = new JFormattedTextField();
    		b_per_2_1.setText("00");
    		b_per_2_1.setBounds(450, 4, 20, 20);
    		panel_1.add(b_per_2_1);
    		
    		JFormattedTextField b_per_3 = new JFormattedTextField();
    		b_per_3.setText("00");
    		b_per_3.setBounds(470, 4, 20, 20);
    		panel_1.add(b_per_3);
    		
    		JFormattedTextField b_per_4 = new JFormattedTextField();
    		b_per_4.setText("00");
    		b_per_4.setBounds(490, 4, 20, 20);
    		panel_1.add(b_per_4);
    		
    		JFormattedTextField b_per_5 = new JFormattedTextField();
    		b_per_5.setText("00");
    		b_per_5.setBounds(510, 4, 20, 20);
    		panel_1.add(b_per_5);
    		
    		JFormattedTextField b_per_6 = new JFormattedTextField();
    		b_per_6.setText("00");
    		b_per_6.setBounds(530, 4, 20, 20);
    		panel_1.add(b_per_6);
    		
    		JFormattedTextField tenp_b_1 = new JFormattedTextField();
    		tenp_b_1.setText("20");
    		tenp_b_1.setBounds(430, 124, 20, 20);
    		panel_1.add(tenp_b_1);
    		
    		JFormattedTextField temp_b_2_2 = new JFormattedTextField();
    		temp_b_2_2.setText("25");
    		temp_b_2_2.setBounds(450, 124, 20, 20);
    		panel_1.add(temp_b_2_2);
    		
    		JFormattedTextField temp_b_3 = new JFormattedTextField();
    		temp_b_3.setText("30");
    		temp_b_3.setBounds(470, 124, 20, 20);
    		panel_1.add(temp_b_3);
    		
    		JFormattedTextField temp_b_4 = new JFormattedTextField();
    		temp_b_4.setText("35");
    		temp_b_4.setBounds(490, 124, 20, 20);
    		panel_1.add(temp_b_4);
    		
    		JFormattedTextField temp_b_5 = new JFormattedTextField();
    		temp_b_5.setText("40");
    		temp_b_5.setBounds(510, 124, 20, 20);
    		panel_1.add(temp_b_5);
    		
    		JFormattedTextField temp_b_6 = new JFormattedTextField();
    		temp_b_6.setText("45");
    		temp_b_6.setBounds(530, 124, 20, 20);
    		panel_1.add(temp_b_6);
    		
    		JLabel label_6 = new JLabel("%");
    		label_6.setBounds(552, 6, 18, 16);
    		panel_1.add(label_6);
    		
    		JLabel label_7 = new JLabel("00=100%");
    		label_7.setFont(new Font("Dialog", Font.BOLD, 10));
    		label_7.setBounds(556, 24, 45, 20);
    		panel_1.add(label_7);
    		
    		JLabel lblFixed_1 = new JLabel("fixed %");
    		lblFixed_1.setBounds(550, 60, 45, 16);
    		panel_1.add(lblFixed_1);
    		
    		JCheckBox chckbxNewCheckBox_3 = new JCheckBox("");
    		chckbxNewCheckBox_3.setSelected(true);
    		chckbxNewCheckBox_3.setBounds(594, 60, 20, 20);
    		panel_1.add(chckbxNewCheckBox_3);
    		
    		JFormattedTextField formattedTextField_25 = new JFormattedTextField();
    		formattedTextField_25.setText("100%");
    		formattedTextField_25.setBounds(556, 86, 45, 20);
    		panel_1.add(formattedTextField_25);
    		
    		JFormattedTextField frmtdtxtfldNameOfTemp_1 = new JFormattedTextField();
    		frmtdtxtfldNameOfTemp_1.setText("name of temp sensor to be used");
    		frmtdtxtfldNameOfTemp_1.setBounds(404, 146, 197, 18);
    		panel_1.add(frmtdtxtfldNameOfTemp_1);
    		
    		JFormattedTextField frmtdtxtfldNameOfFan = new JFormattedTextField();
    		frmtdtxtfldNameOfFan.setText("name of fan to be used");
    		frmtdtxtfldNameOfFan.setBounds(404, 166, 197, 18);
    		panel_1.add(frmtdtxtfldNameOfFan);
    		
    		JCheckBox chckbxNewCheckBox_4 = new JCheckBox("fan off min temp reached");
    		chckbxNewCheckBox_4.setFont(new Font("Dialog", Font.BOLD, 10));
    		chckbxNewCheckBox_4.setBounds(404, 186, 197, 22);
    		panel_1.add(chckbxNewCheckBox_4);
    		
    		JFormattedTextField c_per_1 = new JFormattedTextField();
    		c_per_1.setText("00");
    		c_per_1.setBounds(30, 214, 20, 20);
    		panel_1.add(c_per_1);
    		
    		JFormattedTextField c_per_2 = new JFormattedTextField();
    		c_per_2.setText("00");
    		c_per_2.setBounds(50, 214, 20, 20);
    		panel_1.add(c_per_2);
    		
    		JFormattedTextField c_per_3 = new JFormattedTextField();
    		c_per_3.setText("00");
    		c_per_3.setBounds(70, 214, 20, 20);
    		panel_1.add(c_per_3);
    		
    		JFormattedTextField c_per_4 = new JFormattedTextField();
    		c_per_4.setText("00");
    		c_per_4.setBounds(90, 214, 20, 20);
    		panel_1.add(c_per_4);
    		
    		JFormattedTextField c_per_5 = new JFormattedTextField();
    		c_per_5.setText("00");
    		c_per_5.setBounds(110, 214, 20, 20);
    		panel_1.add(c_per_5);
    		
    		JFormattedTextField c_per_6 = new JFormattedTextField();
    		c_per_6.setText("00");
    		c_per_6.setBounds(130, 214, 20, 20);
    		panel_1.add(c_per_6);
    		
    		JLabel label_8 = new JLabel("%");
    		label_8.setBounds(152, 216, 18, 16);
    		panel_1.add(label_8);
    		
    		JSlider c_s_1 = new JSlider();
    		c_s_1.setValue(100);
    		c_s_1.setOrientation(SwingConstants.VERTICAL);
    		c_s_1.setBounds(30, 234, 18, 100);
    		panel_1.add(c_s_1);
    		
    		JSlider c_s_2 = new JSlider();
    		c_s_2.setValue(100);
    		c_s_2.setOrientation(SwingConstants.VERTICAL);
    		c_s_2.setBounds(50, 234, 18, 100);
    		panel_1.add(c_s_2);
    		
    		JSlider c_s_3 = new JSlider();
    		c_s_3.setValue(100);
    		c_s_3.setOrientation(SwingConstants.VERTICAL);
    		c_s_3.setBounds(70, 234, 18, 100);
    		panel_1.add(c_s_3);
    		
    		JSlider C_S_4 = new JSlider();
    		C_S_4.setValue(100);
    		C_S_4.setOrientation(SwingConstants.VERTICAL);
    		C_S_4.setBounds(90, 234, 18, 100);
    		panel_1.add(C_S_4);
    		
    		JSlider C_S_5 = new JSlider();
    		C_S_5.setValue(100);
    		C_S_5.setOrientation(SwingConstants.VERTICAL);
    		C_S_5.setBounds(110, 234, 18, 100);
    		panel_1.add(C_S_5);
    		
    		JSlider C_S_6 = new JSlider();
    		C_S_6.setValue(100);
    		C_S_6.setOrientation(SwingConstants.VERTICAL);
    		C_S_6.setBounds(130, 234, 18, 100);
    		panel_1.add(C_S_6);
    		
    		JLabel label_9 = new JLabel("100%");
    		label_9.setFont(new Font("Dialog", Font.BOLD, 10));
    		label_9.setBounds(4, 234, 28, 16);
    		panel_1.add(label_9);
    		
    		JLabel label_10 = new JLabel("0%");
    		label_10.setFont(new Font("Dialog", Font.BOLD, 10));
    		label_10.setBounds(14, 318, 18, 16);
    		panel_1.add(label_10);
    		
    		JFormattedTextField C_TEMP_1 = new JFormattedTextField();
    		C_TEMP_1.setText("20");
    		C_TEMP_1.setBounds(30, 334, 20, 20);
    		panel_1.add(C_TEMP_1);
    		
    		JFormattedTextField C_TEMP_2 = new JFormattedTextField();
    		C_TEMP_2.setText("25");
    		C_TEMP_2.setBounds(50, 334, 20, 20);
    		panel_1.add(C_TEMP_2);
    		
    		JFormattedTextField C_TEMP_3 = new JFormattedTextField();
    		C_TEMP_3.setText("30");
    		C_TEMP_3.setBounds(70, 334, 20, 20);
    		panel_1.add(C_TEMP_3);
    		
    		JFormattedTextField C_TEMP_4 = new JFormattedTextField();
    		C_TEMP_4.setText("35");
    		C_TEMP_4.setBounds(90, 334, 20, 20);
    		panel_1.add(C_TEMP_4);
    		
    		JFormattedTextField C_TEMP_5 = new JFormattedTextField();
    		C_TEMP_5.setText("40");
    		C_TEMP_5.setBounds(110, 334, 20, 20);
    		panel_1.add(C_TEMP_5);
    		
    		JFormattedTextField C_TEMP_6 = new JFormattedTextField();
    		C_TEMP_6.setText("45");
    		C_TEMP_6.setBounds(130, 334, 20, 20);
    		panel_1.add(C_TEMP_6);
    		
    		JFormattedTextField frmtdtxtfldNameOfTemp_2 = new JFormattedTextField();
    		frmtdtxtfldNameOfTemp_2.setText("name of temp sensor to be used");
    		frmtdtxtfldNameOfTemp_2.setBounds(4, 356, 197, 18);
    		panel_1.add(frmtdtxtfldNameOfTemp_2);
    		
    		JFormattedTextField frmtdtxtfldNameOfFan_1 = new JFormattedTextField();
    		frmtdtxtfldNameOfFan_1.setText("name of fan to be used");
    		frmtdtxtfldNameOfFan_1.setBounds(4, 376, 197, 18);
    		panel_1.add(frmtdtxtfldNameOfFan_1);
    		
    		JCheckBox chckbxNewCheckBox = new JCheckBox("fan off min temp reached");
    		chckbxNewCheckBox.setFont(new Font("Dialog", Font.BOLD, 10));
    		chckbxNewCheckBox.setBounds(4, 396, 197, 22);
    		panel_1.add(chckbxNewCheckBox);
    		
    		JLabel lblNewLabel_3 = new JLabel("00=100%");
    		lblNewLabel_3.setFont(new Font("Dialog", Font.BOLD, 10));
    		lblNewLabel_3.setBounds(156, 234, 45, 20);
    		panel_1.add(lblNewLabel_3);
    		
    		JLabel lblNewLabel_4 = new JLabel("fixed %");
    		lblNewLabel_4.setBounds(150, 270, 45, 16);
    		panel_1.add(lblNewLabel_4);
    		
    		JCheckBox checkBox = new JCheckBox("");
    		checkBox.setSelected(true);
    		checkBox.setBounds(194, 270, 20, 20);
    		panel_1.add(checkBox);
    		
    		JFormattedTextField formattedTextField_38 = new JFormattedTextField();
    		formattedTextField_38.setText("100%");
    		formattedTextField_38.setBounds(156, 296, 45, 20);
    		panel_1.add(formattedTextField_38);
    		
    		JSlider slider_18 = new JSlider();
    		slider_18.setValue(100);
    		slider_18.setOrientation(SwingConstants.VERTICAL);
    		slider_18.setBounds(430, 234, 18, 100);
    		panel_1.add(slider_18);
    		
    		JSlider slider_19 = new JSlider();
    		slider_19.setOrientation(SwingConstants.VERTICAL);
    		slider_19.setValue(100);
    		slider_19.setBounds(450, 234, 18, 100);
    		panel_1.add(slider_19);
    		
    		JSlider slider_20 = new JSlider();
    		slider_20.setValue(100);
    		slider_20.setOrientation(SwingConstants.VERTICAL);
    		slider_20.setBounds(470, 234, 18, 100);
    		panel_1.add(slider_20);
    		
    		JSlider slider_21 = new JSlider();
    		slider_21.setOrientation(SwingConstants.VERTICAL);
    		slider_21.setValue(100);
    		slider_21.setBounds(490, 234, 18, 100);
    		panel_1.add(slider_21);
    		
    		JSlider slider_22 = new JSlider();
    		slider_22.setValue(100);
    		slider_22.setOrientation(SwingConstants.VERTICAL);
    		slider_22.setBounds(510, 234, 18, 100);
    		panel_1.add(slider_22);
    		
    		JSlider slider_23 = new JSlider();
    		slider_23.setOrientation(SwingConstants.VERTICAL);
    		slider_23.setValue(100);
    		slider_23.setBounds(530, 234, 18, 100);
    		panel_1.add(slider_23);
    		
    		JFormattedTextField formattedTextField_39 = new JFormattedTextField();
    		formattedTextField_39.setText("00");
    		formattedTextField_39.setBounds(430, 214, 20, 20);
    		panel_1.add(formattedTextField_39);
    		
    		JFormattedTextField formattedTextField_40 = new JFormattedTextField();
    		formattedTextField_40.setText("00");
    		formattedTextField_40.setBounds(450, 214, 20, 20);
    		panel_1.add(formattedTextField_40);
    		
    		JFormattedTextField formattedTextField_41 = new JFormattedTextField();
    		formattedTextField_41.setText("00");
    		formattedTextField_41.setBounds(470, 214, 20, 20);
    		panel_1.add(formattedTextField_41);
    		
    		JFormattedTextField formattedTextField_42 = new JFormattedTextField();
    		formattedTextField_42.setText("00");
    		formattedTextField_42.setBounds(490, 214, 20, 20);
    		panel_1.add(formattedTextField_42);
    		
    		JFormattedTextField formattedTextField_43 = new JFormattedTextField();
    		formattedTextField_43.setText("00");
    		formattedTextField_43.setBounds(510, 214, 20, 20);
    		panel_1.add(formattedTextField_43);
    		
    		JFormattedTextField formattedTextField_44 = new JFormattedTextField();
    		formattedTextField_44.setText("00");
    		formattedTextField_44.setBounds(530, 214, 20, 20);
    		panel_1.add(formattedTextField_44);
    		
    		JFormattedTextField formattedTextField_45 = new JFormattedTextField();
    		formattedTextField_45.setText("20");
    		formattedTextField_45.setBounds(430, 334, 20, 20);
    		panel_1.add(formattedTextField_45);
    		
    		JFormattedTextField formattedTextField_46 = new JFormattedTextField();
    		formattedTextField_46.setText("25");
    		formattedTextField_46.setBounds(450, 334, 20, 20);
    		panel_1.add(formattedTextField_46);
    		
    		JFormattedTextField formattedTextField_47 = new JFormattedTextField();
    		formattedTextField_47.setText("30");
    		formattedTextField_47.setBounds(470, 334, 20, 20);
    		panel_1.add(formattedTextField_47);
    		
    		JFormattedTextField formattedTextField_48 = new JFormattedTextField();
    		formattedTextField_48.setText("35");
    		formattedTextField_48.setBounds(490, 334, 20, 20);
    		panel_1.add(formattedTextField_48);
    		
    		JFormattedTextField formattedTextField_49 = new JFormattedTextField();
    		formattedTextField_49.setText("40");
    		formattedTextField_49.setBounds(510, 334, 20, 20);
    		panel_1.add(formattedTextField_49);
    		
    		JFormattedTextField formattedTextField_50 = new JFormattedTextField();
    		formattedTextField_50.setText("45");
    		formattedTextField_50.setBounds(530, 334, 20, 20);
    		panel_1.add(formattedTextField_50);
    		
    		JFormattedTextField frmtdtxtfldNameOfTemp_3 = new JFormattedTextField();
    		frmtdtxtfldNameOfTemp_3.setText("name of temp sensor to be used");
    		frmtdtxtfldNameOfTemp_3.setBounds(404, 356, 197, 18);
    		panel_1.add(frmtdtxtfldNameOfTemp_3);
    		
    		JFormattedTextField frmtdtxtfldNameOfFan_2 = new JFormattedTextField();
    		frmtdtxtfldNameOfFan_2.setText("name of fan to be used");
    		frmtdtxtfldNameOfFan_2.setBounds(404, 375, 197, 18);
    		panel_1.add(frmtdtxtfldNameOfFan_2);
    		
    		JCheckBox chckbxFanOffMin = new JCheckBox("fan off min temp reached");
    		chckbxFanOffMin.setFont(new Font("Dialog", Font.BOLD, 10));
    		chckbxFanOffMin.setBounds(404, 396, 197, 22);
    		panel_1.add(chckbxFanOffMin);
    	
    	}
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: i keep getting an Exception

    a_per_1 is null.
    You never initialise the instance attribute.

    You create a local one in the constructor called a_per_1, but that's not the same one as used in the change listener.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0

    Default Re: i keep getting an Exception

    oh thanks i cant believe i missed that thanks

Similar Threads

  1. unreported exception java.lang.Exception
    By Marisabel in forum New To Java
    Replies: 6
    Last Post: 05-01-2011, 04:21 AM
  2. Replies: 5
    Last Post: 02-15-2011, 12:39 AM
  3. Replies: 1
    Last Post: 02-06-2011, 06:38 AM
  4. Replies: 4
    Last Post: 10-25-2010, 08:42 PM
  5. Replies: 1
    Last Post: 03-08-2008, 07:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •