Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 2 12 LastLast
Results 1 to 25 of 32

Thread: n00b asking jspinner question

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question n00b asking jspinner question

    Here is some random code i found just to illustrate the problem .
    Two things:
    1.When i enter data in jspinner i have to click on enter for data to be accepted ,is it possible for data to be accepted instantly as i`m typing?

    2.When i click on checkbox(just so jspinner loses the focus) and back on jspinner all the data is selected and i want to be
    able with first mouse click to select desired numbers in the middle
    Here is the video that show how i am unable to select numbers i want (with first mouse click)
    jspinner - YouTube
    I would be really grateful if someone who knows the solution can write some simple example.

    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;

    public class SpinDemo3 {
    public static void main(String args[]) {

    // create a JFrame

    JFrame frame = new JFrame("SpinDemo3");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);

    // create a JSpinner set to the current
    // date, with increment/decrement
    // set to minutes

    final SpinnerModel sm =
    new SpinnerDateModel(new Date(),
    null, null, Calendar.MINUTE);
    JSpinner jsp = new JSpinner(sm);

    // add a change listener for the JSpinner

    jsp.addChangeListener(
    new ChangeListener() {
    public void stateChanged(
    ChangeEvent e) {
    Date d = (Date)sm.getValue();
    System.out.println(
    "new date: " + d);
    }
    });

    // create a JPanel

    JPanel panel = new JPanel();
    panel.setPreferredSize(
    new Dimension(300, 300));

    JCheckBox chckbxNewCheckBox = new JCheckBox("New check box");
    panel.add(chckbxNewCheckBox);
    panel.add(jsp);
    frame.getContentPane().add(panel);

    // display the frame

    frame.pack();
    frame.setVisible(true);
    }
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: n00b asking jspinner question

    When posting code, please use the highlight tags. Unformatted code is very hard to read.

    You're going to have to set up some custom listeners or create a custom editor that does what you want.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    john123 (March 19th, 2012)

  4. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    Quote Originally Posted by KevinWorkman View Post
    When posting code, please use the highlight tags. Unformatted code is very hard to read.

    You're going to have to set up some custom listeners or create a custom editor that does what you want.
    Ok thanks for replying.
    That is way beyond may limited knowledge so if someone has the will to maybe show some code here .it would be great.
    I`l understand if its to complicated .

  5. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: n00b asking jspinner question

    It's not complicated, that's the thing. Create a JTextField that behaves how you want, then set it as the editor using the JSpinner.setEditor() function.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. The Following User Says Thank You to KevinWorkman For This Useful Post:

    john123 (March 19th, 2012)

  7. #5
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    Quote Originally Posted by KevinWorkman View Post
    It's not complicated, that's the thing. Create a JTextField that behaves how you want, then set it as the editor using the JSpinner.setEditor() function.
    I would love to do that but i`m not java programmer and i am just trying to edit existing program i own.
    If i see the code i can apply it just like i already rearrange 50 different things to my liking in that same program(just so you dont think i am lazy ,yesterday i was actually coding one simple upgrade and it took me solid 10 hours :-)).
    And this thing is driving me crazy because googling for some helpful code is not working unlike other java question i was able to solve.
    Thanks
    Last edited by john123; March 16th, 2012 at 11:44 AM.

  8. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: n00b asking jspinner question

    Which part is giving you trouble? I suggest building a standalone program separate from your main code, that way you can work with the JTextField by itself, then set that JTextField as a JSpinner's editor without worrying about any other code. That will also make it easier for us to help you as you get stuck along the way.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. The Following User Says Thank You to KevinWorkman For This Useful Post:

    john123 (March 19th, 2012)

  10. #7
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    Bah , i `m trying the whole day doing something with listeners and JTextField but it gives me this error:
    The method addFocusListener(FocusListener) in the type Component is not applicable for the arguments (OrderDialog)
    I dont know ,like i said i am not a java programmer so if someone has the time to do some code example i could then learn from
    it would be great.
    Last edited by john123; March 17th, 2012 at 08:58 AM.

  11. #8
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: n00b asking jspinner question

    If you posted an SSCCE along with the full stack trace, I'm sure somebody would be happy to help you.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  12. #9
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    Quote Originally Posted by KevinWorkman View Post
    If you posted an SSCCE along with the full stack trace, I'm sure somebody would be happy to help you.
    Can you,or anyone please give me any useful link to a code that resembles the solution to my jspinner problem described in the first post.
    I just need something to start with .

  13. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: n00b asking jspinner question

    If you are interested in learning java you would do better to start at the beginning.
    You can find many topics here: The Really Big Index

  14. #11
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    I am trying to do a jspinner with jtextfield editor as advised here but i dont understand why in code below when i click(second time) on a button
    error appears?

    package components;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
     
    import javax.swing.*;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    import javax.swing.text.JTextComponent;
     
    public class JSpinnerComp{
    	protected static final JTextComponent label_1 = null;
    	private JTextField textfield;
    	public static void main(String[] args) {
    		JSpinnerComp h = new JSpinnerComp();
    	}
    	private double TextTolabel() {		
    		return Double.valueOf(textfield.getText());
     
    	}
     
     
    	public JSpinnerComp(){
    		JFrame frame = new JFrame("Creating a JSpinner Component");
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.getContentPane().setLayout(null);
     
    		textfield = new JTextField();
    		textfield.setBounds(36, 226, 148, 54);
     
    		textfield.getDocument().addDocumentListener(new DocumentListener() {
     
    			public void changedUpdate(DocumentEvent e) {
    				System.out.println(TextTolabel());
     
    			}
    			  public void removeUpdate(DocumentEvent e) {
    				  System.out.println(TextTolabel());
     
    			  }
    			  public void insertUpdate(DocumentEvent e) {
    				  System.out.println(TextTolabel());
     
    			  }
    		});
     
    		frame.getContentPane().add(textfield);
    		textfield.setColumns(10);
     
    		JSpinner spinner_1 = new JSpinner();
    		spinner_1.setBounds(61, 140, 243, 20);
    		frame.getContentPane().add(spinner_1);
    		frame.setSize(414,380);
    		frame.setVisible(true);
    		spinner_1.setEditor(textfield);
     
    		JButton btnNewButton = new JButton("New button");
    		btnNewButton.setBounds(215, 233, 89, 23);
    		frame.getContentPane().add(btnNewButton);
    		btnNewButton.addActionListener(new ActionListener() {
    			public void actionPerformed(final ActionEvent arg0) {				
     
    				textfield.setText("112");
    			}
    		});	
     
    	}
    	}
    Last edited by john123; March 19th, 2012 at 12:51 PM.

  15. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: n00b asking jspinner question

    error appears
    Please post the full text of the error message.

    Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
    If you don't understand my answer, don't ignore it, ask a question.

  16. #13
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    This is the error message


    112.0
    Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String
    at sun.misc.FloatingDecimal.readJavaFormatString(Unkn own Source)
    at java.lang.Double.valueOf(Unknown Source)
    at components.JSpinnerComp.TextTolabel(JSpinnerComp.j ava:17)
    at components.JSpinnerComp.access$0(JSpinnerComp.java :16)
    at components.JSpinnerComp$1.removeUpdate(JSpinnerCom p.java:37)
    at javax.swing.text.AbstractDocument.fireRemoveUpdate (Unknown Source)
    at javax.swing.text.AbstractDocument.handleRemove(Unk nown Source)
    at javax.swing.text.AbstractDocument.remove(Unknown Source)
    at javax.swing.text.AbstractDocument.replace(Unknown Source)
    at javax.swing.text.JTextComponent.setText(Unknown Source)
    at components.JSpinnerComp$2.actionPerformed(JSpinner Comp.java:62)
    at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(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.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectio nPrivilege(Unknown Source)
    at java.security.AccessControlContext$1.doIntersectio nPrivilege(Unknown Source)
    at java.awt.EventQueue$2.run(Unknown Source)
    at java.awt.EventQueue$2.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectio nPrivilege(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)

  17. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: n00b asking jspinner question

    Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String
    at sun.misc.FloatingDecimal.readJavaFormatString(Unkn own Source)
    at java.lang.Double.valueOf(Unknown Source)
    at components.JSpinnerComp.TextTolabel(JSpinnerComp.j ava:17)
    The String passed to valueOf on line 17 was empty.
    You need to test if the String passed to the Double class's valueOf() method is empty before calling the method.
    If the String is empty the method will throw the above exception.
    See the String class API doc for methods to test if a String is empty.
    If you don't understand my answer, don't ignore it, ask a question.

  18. The Following User Says Thank You to Norm For This Useful Post:

    john123 (March 19th, 2012)

  19. #15
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    Ok tnx , i will see what next

  20. #16
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    Ok , i am 99% done .
    I resolve empty string problem and few other issues as well , and only 1 little thing is left.
    In this example i manage for jspinner to finally start spinning numbers displayed on his new textfield editor but
    the problem is that it will not display 5 decimal places all the time
    So it goes like this:
    1.30090
    1.301
    1.3011

    And i want it to spin like this:
    1.30090
    1.30100
    1.30110

    I tried formatting the textfield with number format as shown in code but that work only if i manually enter the number and remove the focus
    How can i solve this?

    package components;
    import java.awt.event.ActionEvent;
     
    public class JSpinnerComp{
    	protected static final JTextComponent label_1 = null;
    	private JTextField textfield;
    	public static void main(String[] args) {
    		JSpinnerComp h = new JSpinnerComp();
    	}
    	 double a;		
     
     
    		private double place() {
    			return Double.valueOf(textfield.getText().trim().length());
    		} 
     
    	public JSpinnerComp(){
     
    		JFrame frame = new JFrame("Creating a JSpinner Component");
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.getContentPane().setLayout(null);
    		textfield = new JFormattedTextField(new DecimalFormat("#.00000"));
    		textfield.setText("1.12345");
    		textfield.setBounds(36, 226, 148, 54);
    				textfield.getDocument().addDocumentListener(new DocumentListener() {	
    			public void changedUpdate(DocumentEvent e) {
    				System.out.println(a);
    			}
    			  public void removeUpdate(DocumentEvent e) {
    				  System.out.println(a);
    			  }
    			  public void insertUpdate(DocumentEvent e) {
    				  System.out.println(a);
    			  }
    		});
     
     
     
    		 frame.getContentPane().add(textfield);
    		textfield.setColumns(10);
     
    		final JSpinner spinner_1 = new JSpinner();
    		spinner_1.setModel(new SpinnerNumberModel(new Double(0), null, null, new Double(1)));
    		spinner_1.setBounds(61, 140, 243, 20);
    		frame.getContentPane().add(spinner_1);
    		frame.setSize(414,380);
    		frame.setVisible(true);
    		spinner_1.setEditor(textfield);
     
     
    		spinner_1.addChangeListener(new ChangeListener() {
    			double newValue = (Double) spinner_1.getValue();
    			double old;
    			public void stateChanged(final ChangeEvent arg0) {
     
     
    				if (old >newValue) {
    					if (place()>0){
    	            	  textfield.setText(Double.toString(Math.round(((Double.valueOf(textfield.getText())-0.00010))*100000)/100000.0));
     
    				}
    				} else {
    					if (place()>0){
     
    					textfield.setText(Double.toString(Math.round(((Double.valueOf(textfield.getText())+0.00010))*100000)/100000.0));
     
     
    					}
    			}
     
    				old=newValue;
    			}
     
    		});
     
     
    		 JButton btnNewButton = new JButton("New button");
    		btnNewButton.setBounds(215, 233, 89, 23);
    		frame.getContentPane().add(btnNewButton);
     
    		JCheckBox chckbxNewCheckBox = new JCheckBox("New check box");
    		chckbxNewCheckBox.setBounds(38, 270, 97, 23);
    		frame.getContentPane().add(chckbxNewCheckBox);
    		btnNewButton.addActionListener(new ActionListener() {
    			public void actionPerformed(final ActionEvent arg0) {				
     
     
    			}
    		});	
     
    	}
    	}
    Last edited by john123; March 21st, 2012 at 10:33 AM.

  21. #17
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: n00b asking jspinner question

    Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting

    Your end code tag is wrong. Change QUOTE to CODE

    You will need to use a number formatting class or method to create the String representation that you want for a numeric value.

    See the DecimalFormat class or the String class's formatting method.
    Last edited by Norm; March 21st, 2012 at 10:34 AM.
    If you don't understand my answer, don't ignore it, ask a question.

  22. The Following User Says Thank You to Norm For This Useful Post:

    john123 (March 21st, 2012)

  23. #18
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    Thank you ,formatting the string was the key: String x = String.format("%.5f", name);
    I was trying decimal format before but i think that it lost decimal place again when it was converted to string

  24. #19
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    Hmm, i dont think this is a big issue because there are no visible bugs after it happens but i am curious ,
    When i select numbers over the new jspinner textfield editor i sometimes ,not always, get this error message showing .
    Mouse dragging when selecting is doing something,so is there some easy fix or maybe i should just ignore this ?

    EDIT;BTW number 7 at the beginning is max number of characters allowed to be entered in jtextfield editor.

    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 7
    at sun.font.FontDesignMetrics.charsWidth(Unknown Source)
    at javax.swing.text.Utilities.getTabbedTextOffset(Unk nown Source)
    at javax.swing.text.Utilities.getTabbedTextOffset(Unk nown Source)
    at javax.swing.text.Utilities.getTabbedTextOffset(Unk nown Source)
    at javax.swing.text.PlainView.viewToModel(Unknown Source)
    at javax.swing.text.FieldView.viewToModel(Unknown Source)
    at javax.swing.plaf.basic.BasicTextUI$RootView.viewTo Model(Unknown Source)
    at javax.swing.plaf.basic.BasicTextUI.viewToModel(Unk nown Source)
    at javax.swing.text.DefaultCaret.moveCaret(Unknown Source)
    at javax.swing.text.DefaultCaret.mouseDragged(Unknown Source)
    at java.awt.AWTEventMulticaster.mouseDragged(Unknown Source)
    at java.awt.Component.processMouseMotionEvent(Unknown Source)
    at javax.swing.JComponent.processMouseMotionEvent(Unk nown 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)
    Last edited by john123; March 22nd, 2012 at 05:10 AM.

  25. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: n00b asking jspinner question

    ArrayIndexOutOfBoundsException: 7
    The code is using an index that is past the end of the array.
    Remember that array index values are 0 based and range from 0 to the length-1 of the array.

    To keep this from happening, do not use an array index that is past the end of the array. Use an if statement to test its value.
    If you don't understand my answer, don't ignore it, ask a question.

  26. The Following User Says Thank You to Norm For This Useful Post:

    john123 (March 22nd, 2012)

  27. #21
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    I`m gonna get back to you on this,because as your signature says, i shouldn't ignore the answer

  28. #22
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: n00b asking jspinner question

    I'll see you when you get back.

  29. #23
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    Quote Originally Posted by Norm View Post
    The code is using an index that is past the end of the array.
    Remember that array index values are 0 based and range from 0 to the length-1 of the array.

    To keep this from happening, do not use an array index that is past the end of the array. Use an if statement to test its value.

    I decide to drop this,since changing the fonts i cant even reproduce the problem.
    One small annoying thing is left.
    Is there any way to disable JTextField highlighting when i double click it,and i mean without disabling focus altogether?

  30. #24
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: n00b asking jspinner question

    Not sure what highlighting means. Many components use various visual changes to show change in state. what state does the double click change the textfield to? There might be ways to change the display for the textfield when it is in that state. Look at the API doc
    If you don't understand my answer, don't ignore it, ask a question.

  31. The Following User Says Thank You to Norm For This Useful Post:

    john123 (March 24th, 2012)

  32. #25
    Junior Member
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: n00b asking jspinner question

    Maybe i am spelling it wrong ;highlighting =focus is selected in the whole jtextfield ,
    and that happens when i doubleclick on it.
    Any advice on avoiding this ?

Page 1 of 2 12 LastLast

Similar Threads

  1. [SOLVED] n00b having problems running code
    By cha0s619 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: November 10th, 2012, 04:31 PM
  2. Remove focus from JSpinner?
    By hafunui in forum AWT / Java Swing
    Replies: 4
    Last Post: June 16th, 2011, 04:17 PM
  3. Really Quick n00b question, should take three seconds to answer
    By joeschmidt45 in forum Java Theory & Questions
    Replies: 4
    Last Post: February 24th, 2011, 05:23 AM
  4. Help with JSpinner Problem
    By leoeroz in forum AWT / Java Swing
    Replies: 0
    Last Post: December 25th, 2010, 12:42 PM
  5. Java n00b
    By Campos in forum AWT / Java Swing
    Replies: 6
    Last Post: July 22nd, 2009, 09:26 AM