Home > Mobile >  JButtons only appear when mouse hover over them
JButtons only appear when mouse hover over them

Time:04-10

I have a problem(could be more than one..) with my project. JButton components only show up when I hover the mouse over them.

My project, basically, is taking data from MySQL and setting it on buttons.

For example:

  • 'Aaa', 1000, 'alphabet' on jbutton[0]
  • 'Bbb', 50, 'alphabet2' on jbutton[1]

and so on...

Buttons are on JPanel which is in a JScrollPane. (I did this on purpose as data can not be fit in one panel without scroll and when I click the the button, a new window relating to the info on the clicked button have to pop up)

And I added an ActionListener on another button set which are 'category' buttons(chicken, pizza) to put data on the buttons I mentioned above. When the category button is clicked, data according to the category is extracted and set on buttons one by one.

I searched many times to solve the problem but couldn't find the answer. Just assuming, it happened because I used setLayout(null) all over, or because buttons are added after the main frame is set visible.

It's good to solve the problem but I, more importantly, want to know the reason why.. (haven't been able to sleep for 3 days .. dying to know the reason

  • Related