How can I use general string in Jspinner?









up vote
0
down vote

favorite












I have problem with JSpinner over to show Month in JSpinner and i have follow code bellow.I use swing control with jframe form to use spinner control. When I run project it always set default value 0. How to solve this error?



 static protected String getMonthStrings() months[lastIndex].length()<=0)
String mS=new String[lastIndex];
System.arraycopy(months,0,mS, lastIndex,0);
return mS;

else
return months;


public spinner(boolean CycleMonths)

initComponents();
JTextField tf=null;
String monthStrings = getMonthStrings();
SpinnerListModel monthModel=null;
if(CycleMonths)
monthModel=new CycleSpinnerList(monthStrings);

else
monthModel=new SpinnerListModel(monthStrings);

spMonth=new JSpinner(monthModel);










share|improve this question























  • "When i run project it always set default value 0" - I don't understand what you mean by that. Do you mean that 1) the JSpinner displays "January" (index 0) and you don't want that? Or do you mean 2) that the JSpinner just displays a zero? Or maybe 3) that the JSpinner displays nothing? Please post a Short, Self Contained, Correct (Compilable), Example, so the problem becomes clearer and is actually runnable for us. (also see Minimal, Complete, and Verifiable example)
    – Lukas Rotter
    Sep 8 '15 at 17:37











  • Oh!yes the jspinner just only displays a zero.
    – nara son
    Sep 9 '15 at 1:55














up vote
0
down vote

favorite












I have problem with JSpinner over to show Month in JSpinner and i have follow code bellow.I use swing control with jframe form to use spinner control. When I run project it always set default value 0. How to solve this error?



 static protected String getMonthStrings() months[lastIndex].length()<=0)
String mS=new String[lastIndex];
System.arraycopy(months,0,mS, lastIndex,0);
return mS;

else
return months;


public spinner(boolean CycleMonths)

initComponents();
JTextField tf=null;
String monthStrings = getMonthStrings();
SpinnerListModel monthModel=null;
if(CycleMonths)
monthModel=new CycleSpinnerList(monthStrings);

else
monthModel=new SpinnerListModel(monthStrings);

spMonth=new JSpinner(monthModel);










share|improve this question























  • "When i run project it always set default value 0" - I don't understand what you mean by that. Do you mean that 1) the JSpinner displays "January" (index 0) and you don't want that? Or do you mean 2) that the JSpinner just displays a zero? Or maybe 3) that the JSpinner displays nothing? Please post a Short, Self Contained, Correct (Compilable), Example, so the problem becomes clearer and is actually runnable for us. (also see Minimal, Complete, and Verifiable example)
    – Lukas Rotter
    Sep 8 '15 at 17:37











  • Oh!yes the jspinner just only displays a zero.
    – nara son
    Sep 9 '15 at 1:55












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have problem with JSpinner over to show Month in JSpinner and i have follow code bellow.I use swing control with jframe form to use spinner control. When I run project it always set default value 0. How to solve this error?



 static protected String getMonthStrings() months[lastIndex].length()<=0)
String mS=new String[lastIndex];
System.arraycopy(months,0,mS, lastIndex,0);
return mS;

else
return months;


public spinner(boolean CycleMonths)

initComponents();
JTextField tf=null;
String monthStrings = getMonthStrings();
SpinnerListModel monthModel=null;
if(CycleMonths)
monthModel=new CycleSpinnerList(monthStrings);

else
monthModel=new SpinnerListModel(monthStrings);

spMonth=new JSpinner(monthModel);










share|improve this question















I have problem with JSpinner over to show Month in JSpinner and i have follow code bellow.I use swing control with jframe form to use spinner control. When I run project it always set default value 0. How to solve this error?



 static protected String getMonthStrings() months[lastIndex].length()<=0)
String mS=new String[lastIndex];
System.arraycopy(months,0,mS, lastIndex,0);
return mS;

else
return months;


public spinner(boolean CycleMonths)

initComponents();
JTextField tf=null;
String monthStrings = getMonthStrings();
SpinnerListModel monthModel=null;
if(CycleMonths)
monthModel=new CycleSpinnerList(monthStrings);

else
monthModel=new SpinnerListModel(monthStrings);

spMonth=new JSpinner(monthModel);







java swing jspinner






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 14:51









Cœur

16.9k9102139




16.9k9102139










asked Sep 8 '15 at 16:52









nara son

195




195











  • "When i run project it always set default value 0" - I don't understand what you mean by that. Do you mean that 1) the JSpinner displays "January" (index 0) and you don't want that? Or do you mean 2) that the JSpinner just displays a zero? Or maybe 3) that the JSpinner displays nothing? Please post a Short, Self Contained, Correct (Compilable), Example, so the problem becomes clearer and is actually runnable for us. (also see Minimal, Complete, and Verifiable example)
    – Lukas Rotter
    Sep 8 '15 at 17:37











  • Oh!yes the jspinner just only displays a zero.
    – nara son
    Sep 9 '15 at 1:55
















  • "When i run project it always set default value 0" - I don't understand what you mean by that. Do you mean that 1) the JSpinner displays "January" (index 0) and you don't want that? Or do you mean 2) that the JSpinner just displays a zero? Or maybe 3) that the JSpinner displays nothing? Please post a Short, Self Contained, Correct (Compilable), Example, so the problem becomes clearer and is actually runnable for us. (also see Minimal, Complete, and Verifiable example)
    – Lukas Rotter
    Sep 8 '15 at 17:37











  • Oh!yes the jspinner just only displays a zero.
    – nara son
    Sep 9 '15 at 1:55















"When i run project it always set default value 0" - I don't understand what you mean by that. Do you mean that 1) the JSpinner displays "January" (index 0) and you don't want that? Or do you mean 2) that the JSpinner just displays a zero? Or maybe 3) that the JSpinner displays nothing? Please post a Short, Self Contained, Correct (Compilable), Example, so the problem becomes clearer and is actually runnable for us. (also see Minimal, Complete, and Verifiable example)
– Lukas Rotter
Sep 8 '15 at 17:37





"When i run project it always set default value 0" - I don't understand what you mean by that. Do you mean that 1) the JSpinner displays "January" (index 0) and you don't want that? Or do you mean 2) that the JSpinner just displays a zero? Or maybe 3) that the JSpinner displays nothing? Please post a Short, Self Contained, Correct (Compilable), Example, so the problem becomes clearer and is actually runnable for us. (also see Minimal, Complete, and Verifiable example)
– Lukas Rotter
Sep 8 '15 at 17:37













Oh!yes the jspinner just only displays a zero.
– nara son
Sep 9 '15 at 1:55




Oh!yes the jspinner just only displays a zero.
– nara son
Sep 9 '15 at 1:55












1 Answer
1






active

oldest

votes

















up vote
0
down vote













In your constructor code, you are calling initComponents, then creating your SpinnerListModel, creating a new JSpinner, but never adding it anywhere... So it looks like the problem is that you're just not adding the JSpinner anywhere



 public spinner(boolean CycleMonths) 

initComponents();
JTextField tf=null;
String monthStrings = getMonthStrings();
SpinnerListModel monthModel=null;
if(CycleMonths)
monthModel=new CycleSpinnerList(monthStrings);

else
monthModel=new SpinnerListModel(monthStrings);

spMonth=new JSpinner(monthModel);







share|improve this answer




















  • But spMonth is Jspinner,sir.
    – nara son
    Sep 9 '15 at 2:12











  • spMonth is just a field within your class, which you've set to point to the JSpinner. But you still haven't added this to your GUI
    – ControlAltDel
    Sep 9 '15 at 11:44










  • Thank you for your reply.
    – nara son
    Sep 9 '15 at 17:12










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32463215%2fhow-can-i-use-general-string-in-jspinner%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













In your constructor code, you are calling initComponents, then creating your SpinnerListModel, creating a new JSpinner, but never adding it anywhere... So it looks like the problem is that you're just not adding the JSpinner anywhere



 public spinner(boolean CycleMonths) 

initComponents();
JTextField tf=null;
String monthStrings = getMonthStrings();
SpinnerListModel monthModel=null;
if(CycleMonths)
monthModel=new CycleSpinnerList(monthStrings);

else
monthModel=new SpinnerListModel(monthStrings);

spMonth=new JSpinner(monthModel);







share|improve this answer




















  • But spMonth is Jspinner,sir.
    – nara son
    Sep 9 '15 at 2:12











  • spMonth is just a field within your class, which you've set to point to the JSpinner. But you still haven't added this to your GUI
    – ControlAltDel
    Sep 9 '15 at 11:44










  • Thank you for your reply.
    – nara son
    Sep 9 '15 at 17:12














up vote
0
down vote













In your constructor code, you are calling initComponents, then creating your SpinnerListModel, creating a new JSpinner, but never adding it anywhere... So it looks like the problem is that you're just not adding the JSpinner anywhere



 public spinner(boolean CycleMonths) 

initComponents();
JTextField tf=null;
String monthStrings = getMonthStrings();
SpinnerListModel monthModel=null;
if(CycleMonths)
monthModel=new CycleSpinnerList(monthStrings);

else
monthModel=new SpinnerListModel(monthStrings);

spMonth=new JSpinner(monthModel);







share|improve this answer




















  • But spMonth is Jspinner,sir.
    – nara son
    Sep 9 '15 at 2:12











  • spMonth is just a field within your class, which you've set to point to the JSpinner. But you still haven't added this to your GUI
    – ControlAltDel
    Sep 9 '15 at 11:44










  • Thank you for your reply.
    – nara son
    Sep 9 '15 at 17:12












up vote
0
down vote










up vote
0
down vote









In your constructor code, you are calling initComponents, then creating your SpinnerListModel, creating a new JSpinner, but never adding it anywhere... So it looks like the problem is that you're just not adding the JSpinner anywhere



 public spinner(boolean CycleMonths) 

initComponents();
JTextField tf=null;
String monthStrings = getMonthStrings();
SpinnerListModel monthModel=null;
if(CycleMonths)
monthModel=new CycleSpinnerList(monthStrings);

else
monthModel=new SpinnerListModel(monthStrings);

spMonth=new JSpinner(monthModel);







share|improve this answer












In your constructor code, you are calling initComponents, then creating your SpinnerListModel, creating a new JSpinner, but never adding it anywhere... So it looks like the problem is that you're just not adding the JSpinner anywhere



 public spinner(boolean CycleMonths) 

initComponents();
JTextField tf=null;
String monthStrings = getMonthStrings();
SpinnerListModel monthModel=null;
if(CycleMonths)
monthModel=new CycleSpinnerList(monthStrings);

else
monthModel=new SpinnerListModel(monthStrings);

spMonth=new JSpinner(monthModel);








share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 8 '15 at 18:26









ControlAltDel

21.1k53257




21.1k53257











  • But spMonth is Jspinner,sir.
    – nara son
    Sep 9 '15 at 2:12











  • spMonth is just a field within your class, which you've set to point to the JSpinner. But you still haven't added this to your GUI
    – ControlAltDel
    Sep 9 '15 at 11:44










  • Thank you for your reply.
    – nara son
    Sep 9 '15 at 17:12
















  • But spMonth is Jspinner,sir.
    – nara son
    Sep 9 '15 at 2:12











  • spMonth is just a field within your class, which you've set to point to the JSpinner. But you still haven't added this to your GUI
    – ControlAltDel
    Sep 9 '15 at 11:44










  • Thank you for your reply.
    – nara son
    Sep 9 '15 at 17:12















But spMonth is Jspinner,sir.
– nara son
Sep 9 '15 at 2:12





But spMonth is Jspinner,sir.
– nara son
Sep 9 '15 at 2:12













spMonth is just a field within your class, which you've set to point to the JSpinner. But you still haven't added this to your GUI
– ControlAltDel
Sep 9 '15 at 11:44




spMonth is just a field within your class, which you've set to point to the JSpinner. But you still haven't added this to your GUI
– ControlAltDel
Sep 9 '15 at 11:44












Thank you for your reply.
– nara son
Sep 9 '15 at 17:12




Thank you for your reply.
– nara son
Sep 9 '15 at 17:12

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32463215%2fhow-can-i-use-general-string-in-jspinner%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

Evgeni Malkin