Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9250143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:22:38+00:00 2026-06-18T10:22:38+00:00

My problem is that the JSpinner (named spinnerCantidadPuntas in the code) is sometimes not

  • 0

My problem is that the JSpinner (named spinnerCantidadPuntas in the code) is sometimes not showing at all, or just buggy. when i run the project (F6) its almost guaranteed to not show properly, when i debug it (CTRL+F5) it displays properly most of the time. i cannot the figure out why. heres the details on what im using:

Product Version: NetBeans IDE 7.2.1 (Build 201210100934)
Java: 1.7.0_11; Java HotSpot(TM) Client VM 23.6-b04
System: Windows 7 version 6.1 running on x86; Cp1252; es_VE (nb)

I made a project, im listing the content of all classes here

    package estrella;
    public class Main {
        public static void main(String[] args) {
            Interfaz f=new Interfaz();
        }
    }



    package estrella;
    import java.awt.Color;
    import java.awt.Container;
    import java.util.Hashtable;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JSlider;
    import javax.swing.JSpinner;
    import javax.swing.SpinnerNumberModel;
    public class Interfaz extends JFrame {

        Container c;

        AreaDeDibujos lienzo;

        JLabel lInfo,lCantidadPuntas,lTamanioEstrella,lLargoPuntas;
        JSpinner spinnerCantidadPuntas;
        JSlider sliderTamanioEstrella,sliderLargoPuntas;

        public Interfaz(){

            setTitle("Ejemplo <<Dibujo de primitivas y poligonos>> Version 1.0 (05/02/2013)");
            setSize(1024,720);
            setResizable(false);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setLocationRelativeTo(null);
            setVisible(true);

            c=getContentPane();
            c.setBackground(new Color(240,250,245));
            c.setLayout(null);

            /*lienzo=new AreaDeDibujos();
            lienzo.setBounds(25,25,800,600);

            c.add(lienzo);*/

            lInfo=new JLabel("Por favor, seleccione los parametros de la estrella a dibujar:");
            lInfo.setBounds(10,10,350,20);
            c.add(lInfo);

            lCantidadPuntas=new JLabel("Numero de puntas de la estrella: ");
            lCantidadPuntas.setBounds(10,35,350,20);
            c.add(lCantidadPuntas);
            spinnerCantidadPuntas=new JSpinner(new SpinnerNumberModel(7, //valor inicial
                                                              Estrella.MINIMO_PUNTAS, //valor minimo
                                                              Estrella.MAXIMO_PUNTAS, //valor maximo
                                                              1 // incremento/decremento (paso)
                                                             )
                                       );
            spinnerCantidadPuntas.setBounds(10,55,120,20);
            c.add(spinnerCantidadPuntas);

            lTamanioEstrella=new JLabel("Tamaño de la estrella (pixeles): ");
            lTamanioEstrella.setBounds(10,80,350,20);
            c.add(lTamanioEstrella);
            sliderTamanioEstrella=new JSlider( 
                                     JSlider.HORIZONTAL,
                                     AreaDeDibujos.TAMANIO_ESTRELLA_MINIMO,
                                     AreaDeDibujos.TAMANIO_ESTRELLA_MAXIMO,
                                     (int)(AreaDeDibujos.TAMANIO_ESTRELLA_MAXIMO/2)
                                     );
            Hashtable etiquetasDelSlider1 = new Hashtable();
            int i,cantidadDeRayas,rango,paso,minimo,maximo,valorDeLaRaya;
            minimo=AreaDeDibujos.TAMANIO_ESTRELLA_MINIMO;
            maximo=AreaDeDibujos.TAMANIO_ESTRELLA_MAXIMO;
            rango=maximo-minimo;
            cantidadDeRayas=10;
            paso=rango/cantidadDeRayas;
            for(i=0;i<=cantidadDeRayas;i++){
                valorDeLaRaya=minimo+paso*i;
                etiquetasDelSlider1.put(new Integer (valorDeLaRaya), new JLabel(""+valorDeLaRaya));
    }
            sliderTamanioEstrella.setLabelTable( etiquetasDelSlider1 );
            sliderTamanioEstrella.setPaintLabels(true);
            sliderTamanioEstrella.setMajorTickSpacing(10);
            sliderTamanioEstrella.setPaintTicks(true);
            sliderTamanioEstrella.setBounds(10,100,350,60);
            c.add(sliderTamanioEstrella);
        }

    }

    package estrella;
    public class Estrella {
        public static final int MINIMO_PUNTAS=3,MAXIMO_PUNTAS=10;
    }

    package estrella;
    public class GestorDeEventos {   
    }

    package estrella;
    import javax.swing.JComponent;
    public class AreaDeDibujos extends JComponent {
        public static final int TAMANIO_ESTRELLA_MINIMO=50,TAMANIO_ESTRELLA_MAXIMO=400;
    }

i didnt bother add a Jar file because i know ppl will not want to download nor run it thinking its a virus

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:22:40+00:00Added an answer on June 18, 2026 at 10:22 am

    “My problem is that the JSpinner”, actually, it’s the lack of a proper layout manager…

    Using a null layout manager means that any time you invalidate the container (by adding something to it), the container isn’t updating itself in a way that the repaint manager will identify.

    Move setVisible(true); to the end of the constructor.

    If you were using a layout manager, you would be able to revalidate/repaint instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Strange problem that just starting to happen on a SL/WCF RIA Services project that
I have problem that in my MVC 3 project, the logon view do not
Seems to be a problem that many people have, but all the answers I
I have this classic problem that seems impossible to solve for me. I just
One problem that I have frequently run into lately is the problem of my
There is a common problem that F# does not natively support infix-style use of
The problem that I'm having with it, is that it tracks all the events
The problem that I'm having is when running my android app, if I run
My problem is that I am trying to run a problem that I coded
I recently face a problem that my code working from root but when i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.