java - JButtons appearing and disappearing with mouse -


when add several jbuttons jframe, buttons appear , disappear mouse movements...kinda spooky. ideas? other projects dont have issue, therefore im pretty sure code...but simple im not sure whats wrong!

full code: (i blurred out name)

package explorerplus;  import java.awt.borderlayout; import java.awt.container; import java.awt.toolkit; import java.io.file; import javax.swing.*;  public class explorerplus {  //declarations toolkit t = toolkit.getdefaulttoolkit();  jframe f = new jframe();  public static void main(string[] args) {    swingutilities.invokelater(new runnable() {         public void run(){             explorerplus ep = new explorerplus();         }     }); } private explorerplus(){    // f.super("");     f.setundecorated(false);      f.setsize(t.getscreensize());     f.setdefaultcloseoperation(f.exit_on_close);     container c = null;     c =new jscrollpane(c);     f.setcontentpane(c);     f.setvisible(true);     gothrough(new file("c:/users/*****/pictures/"));     f.repaint();  }   static int spc_count=-1;   int curr_x = 10, curr_y = 10;   void gothrough(file afile) { spc_count++; string spcs = ""; (int = 0; < spc_count; i++)   spcs += " "; if(afile.isfile()){   system.out.println(spcs + "[file] " + afile.getname());   file file = afile;   string s = getext(file) + ".png";   jbutton b = new jbutton(new imageicon(s));   b.settooltiptext(file.getname());   b.setsize(256, 256);   b.setlocation(curr_x, curr_y);   b.setvisible(true);   b.validate();   f.validate();    if(curr_x < f.getwidth() - 270){       curr_x+=270;   }else{   curr_y+=270;   curr_x = 10;   }   f.getcontentpane().add(b);   } else if (afile.isdirectory()) {   system.out.println(spcs + "[dir] " + afile.getname());   file[] listoffiles = afile.listfiles();   if(listoffiles!=null) {     (int = 0; < listoffiles.length; i++)       gothrough(listoffiles[i]);   } else {     system.out.println(spcs + " [access denied]");   } } spc_count--; }    string getext(file f){   if(f.getname().tolowercase().endswith(".jpg")|| f.getname().tolowercase().endswith(".jpeg")){      return "jpeg";  } else if(f.getname().tolowercase().endswith(".png")){      return "png";  }  else if(f.getname().tolowercase().endswith(".html")){      return "html";  }else if(f.getname().tolowercase().endswith(".ini")){      return "ini";  }else{      return "text";  }   }   string allbutext(file f){       string name = f.getname();       return name.replace(getext(f), "");   } } 

i hope did undestand right: wants display new jbutton on jframe. doesn't appear.

if can try use:

f.updateui(); 

after have added button frame.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -