Wednesday, 15 April 2015

java - shifting Label in array of JLabel in swing -


I want to convert my elements into JLab label values, for example, depending on the textfield values, for example if I show my labels in 10, if I entered 10, 12 show my label 10 to 12 which works perfectly, I want to sort it for example if I enter 10 then 6 Labels show labels 6 and 10 that do not work

  Int; (J = 0; j and lt; items; j ++) {if (intelligent persian (labels [ja] .gate text ()) gt; integer.press (utext [1] .gate text ()) break ; For (int a = item; k & gt; j; k -) {labels [k] = labels [k-1]; Label [j] = new jlabel (uttex [1] .gettext ()); Label [J]. Setbound (40 * j, 150, 130, 30); P.add (label [ja]); P.revalidate (); P.repaint (); Item ++; // Label is my array / the number of elements in array array is / / p is panel / uatxt [1] my textfield}}  

Sorry my question is trivial, but I ` Swing in the beginning

Do nothing in graphics, this problem is a logical problem

After reading the fields, sharpen them in an array:

  string text = field .gettext (); ArrayList & LT; Integer & gt; Nums = New Arrestist & lt; Integer & gt; (); Scanner scan = new scanner (text); Whereas (scan.hasNextInt ()) nums.add (scan.nextInt ()); collection. Associate (AM)  

Here you have beautifully sorted in an ArrayList .


No comments:

Post a Comment