0

I made a Setting panel, in which I am setting color for Main table cell by pressing set button in setting window. There are two combo box button greater and less. The value greater than the value in combo box will be colored in a particular color and less than in same way. But the colors are not rendered after pressing SET, but it is rendered after minimizing and then maximizing the main window.

Below is actionPerformed() method:

public void actionPerformed(ActionEvent e) {
   if(e.getSource()==btnCancel)
    {
      MainUI1.isShowModel=true;
    //mf.setVisible(true);
      this.dispose();
     }
   if(e.getSource()==btnset)
   {
      // MainUI1.isShowModel=true;
      ColorSettings.setColor();
      validate();
   }
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
adityak
  • 192
  • 1
  • 1
  • 12

1 Answers1

1

Try to use Component.repaint method. Also see this question Java Swing revalidate() vs repaint()

Community
  • 1
  • 1
Mikita Belahlazau
  • 15,326
  • 2
  • 38
  • 43
  • I have tried it but color is set after minimizing or scrolling of main panel table only. – adityak May 27 '12 at 11:59
  • What component do you call `repaint` on? – Mikita Belahlazau May 27 '12 at 12:25
  • @adityak everything are shots to the dark without seeing your code in the [SSCCE](http://sscce.org/) form, otherwise thats your issue and doesn't corresponding with code that you sent here somehow, basically set for Color doesn't required any woodoo as repaint or e.i. in the Swing – mKorbel May 27 '12 at 13:30
  • @NikitaBeloglazov my job is done due to your suggestion. Thanx for your help. – adityak May 28 '12 at 04:26
  • @mKorbel THANX for your valuable suggetions – adityak May 28 '12 at 04:29