# Anybody have looking at multiple java files; I have a fix for this but I can't get it to work on mac

**URL:** <https://discourse.processing.org/t/anybody-have-looking-at-multiple-java-files-i-have-a-fix-for-this-but-i-cant-get-it-to-work-on-mac/21545>\
**Category:** Libraries\
**Created:** [June 4, 2020, 3:39am UTC](https://discourse.processing.org/t/anybody-have-looking-at-multiple-java-files-i-have-a-fix-for-this-but-i-cant-get-it-to-work-on-mac/21545 "2020-06-04T03:39:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntiViral\_Builder](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@AntiViral\_Builder](https://discourse.processing.org/u/AntiViral_Builder)\
**Post date:** [June 4, 2020, 3:39am UTC](https://discourse.processing.org/t/anybody-have-looking-at-multiple-java-files-i-have-a-fix-for-this-but-i-cant-get-it-to-work-on-mac/21545/1 "2020-06-04T03:39:05Z")

</div>

I filnally got this done. Remember that it is made for mac so with windows you need C:\ as a root path and to add ‘’ to the path which is ‘\’ . it will not start in the root path. it might take a while to display the file name because it uses a timer for the routine.

import g4p\_controls.\*;  
GButton btnClose,btnRun,btnFind,btnDone,btnTrim,btnDef;  
GWindow window;  
GWindow windowControl;

//GTextField txf1;  
GTimer timer;  
int wcnt;  
int oldy;  
int oldy1;  
int savx;  
int savy;  
int selec;  
int selec1;  
int scrpos;  
int scrpos1;  
int dispcnt;  
int scrlen;  
int scrlen1;  
boolean moving;  
boolean moving1;  
Boolean scanning;  
Boolean nowind;  
boolean nopath;  
boolean filesdone;  
boolean nback;  
boolean patherr;  
boolean inroot;  
boolean meth;  
boolean ptype;  
String path;  
String[] dnams;  
String dpath;  
String rootpath;  
String[] filepaths;  
String spefold;  
String fndpath;  
PFont font;  
PFont font1;  
PFont font2;  
int begx = 25;  
int topy = 25;  
int filnum;  
int dirmax;  
int ordnum;  
int jcnt;  
int hun;  
int dirnum[];  
int filscnt[];  
int dirscnt[];  
int filnums[];  
byte[] outbyte;  
byte[] inbyte;  
boolean[] filsdone2 = new boolean[10000];  
boolean filsdone;  
int dirlev;  
int dival;  
int totsize;  
int sizecnt;  
int rootnumb;  
String chospath;  
String[] afils;  
String[] adirs;  
String[] afilp;  
String[] adirp;  
String[] fpath = new String[1000];  
boolean donesig;  
int filec;  
int dirc;  
void setup(){  
String[] lines = loadStrings(“default.txt”);  
if (lines == null) {  
chospath = “/”;  
} else {  
chospath = lines[0];  
}

donesig=false;  
rootpath="/";  
chospath="";  
moving = false;  
moving1 = false;  
scrpos=0;  
scrpos1=0;  
selec = -1;  
selec1 = -1;  
dirnum = new int[1000];  
filscnt = new int[1000];  
dirscnt = new int[1000];  
filnums = new int[1000];  
for(int i=0;i\<1000;i++) dirnum[i] = 0;  
for(int i=0;i\<1000;i++) filscnt[i]=0;  
filsdone = false;  
dirlev=0;  
scanning = false;  
nowind = true;  
nopath=true;  
size(512,256);  
background(0, 0, 0);  
createConfigControls();  
font = loadFont(“ArialNarrow.vlw”);

font1 = loadFont(“CourierNewPS-BoldMT.vlw”);  
font2 = loadFont(“Arial-Black.vlw”);  
loop();  
timer = new GTimer(this, this, “update”, 100);  
[//timer.setInterval](https://timer.setInterval)(500);  
timer.start();

}

void draw(){  
stroke(0,0,0);  
fill(0,0,0);  
rect(0,0,width,height);  
stroke(255,255,255);  
fill(255,255,255);  
rect(0,0,512,64);  
textFont(font);  
textSize(20);  
fill(0,0,0);  
text(rootpath,0,16);

```
if (scanning) {
  text(dpath,0,48);
 
}

```

fill(255,255,255);  
if (donesig) text(“Done.”,0,128);

}  
void editDraw(PApplet app,GWinData data) {

app.background(0, 0,0);

```
app.textAlign(LEFT);
app.stroke(255, 255, 255);
app.fill(255, 255, 255);
//rect(width - 100,5,100,50);
app.fill(0, 0, 0);
app.textFont(font, 12);
//text(str(savx - begx),width - 100,20);
//text(str(savy - topy),width - 100,35);
app.textFont(font1);
app.textAlign(LEFT);
app.fill(0, 0, 127);
app.stroke(0, 0, 127);
app.rect(0,0,app.width,app.height);
app.fill(255, 255, 255);
app.stroke(255, 255, 255);
app.rect(begx, topy + 30, 200, 200);
app.rect(begx + 240, topy + 30, 200, 200);
app.rect(begx, topy, 469, 20);
//app.rect(begx + 475, topy, 67, 29);
if (dispcnt>0) app.rect(begx + 475, topy + 39, 67, 29);

app.fill(0, 0, 0);
app.stroke(0, 0, 0);
app.rect(begx + 454, topy + 9, 10, 2);
app.fill(0, 0, 255);
app.stroke(0, 0, 255);
app.rect(begx + 445, topy, 4, 20);
app.fill(255, 0, 0);
app.stroke(255, 0, 0);
app.textSize(12);
app.text(chospath, begx + 5, topy + 15);

int aloc = floor(dirc * scrpos/174);
int aloc1 = floor(filec * scrpos1/174);
for (int i = 0; i < 12; i++) if (i+aloc<dirc) {
  app.text(mytrim(adirs[i + aloc], 22), begx + 0, topy + 45 + 16 * i);
  if (i == selec)
  {
    app.rect(begx + 0, topy + 30 + selec * 16, 200, 15);
    app.fill(255, 255, 255);
    app.text(mytrim(adirs[i + aloc], 22), begx + 0, topy + 45 + 16 * i);
    app.fill(255, 0, 0);
  }
}

for (int i = 0; i < 12; i++) if (i+aloc1<filec) {
  app.text(mytrim(afils[i + aloc1], 22), begx + 245, topy + 45 + 16 * i);
  if (i == selec1)
  {
    app.rect(begx + 240, topy + 45 + selec1 * 16, 200, 16);
    app.fill(255, 255, 255);
    app.text(mytrim(afils[i + aloc1], 22), begx + 245, topy + 45 + 16 * i);
    app.fill(255, 0, 0);
  }
}

app.stroke(127, 127, 127);
app.fill(0, 0, 0);
app.rect(begx + 440, topy + 30, 29, 200);
app.rect(begx + 441, topy + 31, 27, 198);
app.rect(begx + 200, topy + 30, 29, 200);
app.rect(begx + 201, topy + 31, 27, 198);

app.fill(127, 127, 127);
app.rect(begx + 203, topy + 33 + scrpos, 23, scrlen);
app.rect(begx + 443, topy + 33 + scrpos1, 23, scrlen1);

```

}  
void update(GTimer timer) {  
if (scanning) incpath2();  
}  
void createConfigControls(){  
//txf1 = new GTextField(this, 10, 10, 200, 20);  
[//txf1.setPromptText](https://txf1.setPromptText)("");  
btnClose = new GButton(this, width - 32 , 8, 24, 24, “x”);  
btnRun = new GButton(this, 16 , height - 32, 128, 24, “Start”);  
btnFind = new GButton(this, 158 , height - 32, 128, 24, “Get path”);  
StyledString ss;  
ss = new StyledString(“X”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnClose.setStyledText(ss);  
ss = new StyledString(“Start”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnRun.setStyledText(ss);  
ss = new StyledString(“Get path”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnFind.setStyledText(ss);  
}  
public void createWindow(int type) {  
if (nowind){  
chospath = “/”;  
//String[] winnames={“Scan”,“Debug”,“Edit”,“Compile”};  
windowControl = GWindow.getWindow(this,“Get path”, 100, 100, 520, 300, JAVA2D);  
PApplet app = windowControl;  
//app = GWindow.getWindow(this, “Get path.”, 70, 160, 600, 600, JAVA2D);  
windowControl.addDrawHandler(this, “editDraw”);  
windowControl.addMouseHandler(this, “windowMouse”);  
btnDone = new GButton(app, 16 , app.height - 32, 128, 24, “Done”);  
btnTrim = new GButton(app,158,app.height - 32,128,24,“Trim Path”);  
btnDef = new GButton(app,294,app.height - 32,128,24,“Make Default”);  
StyledString ss;  
ss = new StyledString(“Done”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnDone.setStyledText(ss);  
ss = new StyledString(“Trim Path”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnTrim.setStyledText(ss);  
ss = new StyledString(“Make Default”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnDef.setStyledText(ss);  
nowind = false;  
ptype = false;  
getnames();  
}  
}  
public void handleButtonEvents(GButton button, GEvent event) {  
if (event == GEvent.CLICKED) {  
if (button == btnClose) exit();  
if (button == btnRun) scanstart();  
if (button == btnFind) createWindow(0);;  
if (button == btnDone && chospath!=""){  
nowind=true;  
windowControl.setVisible(!windowControl.isVisible());  
rootpath = chospath;  
}  
if (button == btnTrim){  
trimpat();  
}  
if (button == btnDef) {  
savdef();  
}  
}  
}  
void incpath2(){  
String tpath;

if (filsdone){  
if (dirnum[dirlev] \> dirc - 1){  
if (dirlev == 1){  
for(int i = 1;i \< dirmax;i++){  
dirnum[dirlev] = 0;  
}  
dirmax=0;  
}  
if (dirlev \> 0) dirlev–;  
dirnum[dirlev]++;  
if (dirnum[0] \> rootnumb-1) {  
scanning=false;  
savres();  
}  
}else{  
dirlev++;  
if (dirlev \> dirmax) dirmax=dirlev;  
filsdone=false;  
dirnum[dirlev] = 0;  
filscnt[dirlev] = 0;

```
}

tpath=getpnam();
if (tpath != "E") path = tpath;
getnames();

```

}else {  
if (filscnt[dirlev]\<jcnt){  
fpath[hun] = filepaths[filscnt[dirlev]];

```
inbyte = loadBytes(filepaths[filscnt[dirlev]]);
totsize+=inbyte.length; 

dpath = dnams[filscnt[dirlev]];
hun++;
filscnt[dirlev]++;
}else{

  filsdone = true;

```

}

```
 }
 wcnt++;
 }
 void getnames(){
   File[] fil;
   if (ptype){
fil = listFiles(path);
   }else{
    fil = listFiles(chospath);
   }
   if (fil == null){
     dirc = 0;
     filec = 0;
     jcnt = 0;
     dirscnt[dirlev] = dirc;
     filnums[dirlev] =jcnt;
   }else{

```

String[] filen = new String[fil.length];  
String[] dirn = new String[fil.length];  
String[] filep = new String[fil.length];  
String[] dirp = new String[fil.length];  
filec = 0;  
dirc= 0;  
jcnt=0;  
sizecnt=0;  
for (int i=0; i\<fil.length; i++) {  
if (fil[i] != null){  
if (fil[i].isDirectory()) {  
dirn[dirc] = fil[i].getName();  
dirp[dirc] = fil[i].getAbsolutePath();  
dirc++;  
} else  
{  
filen[filec] = fil[i].getName();  
if (compare(fil[i].getName()) && ptype) jcnt++;

```
  filep[filec] = fil[i].getAbsolutePath();
  filec++;
}

```

}  
}

dirscnt[dirlev] = dirc;  
filnums[dirlev] =filec;  
int ghd=0;  
if (nopath) rootnumb = dirc;  
nopath=false;  
if (ptype){  
filepaths = new String[jcnt];  
dnams = new String[jcnt];  
}  
afils = new String[filec];  
adirs = new String[dirc];  
afilp = new String[filec];  
adirp = new String[dirc];  
for (int i=0; i \< filec; i++) afils[i] = filen[i];  
for (int i=0; i \< dirc; i++) adirs[i] = dirn[i];  
for (int i=0; i \< filec; i++){  
afilp[i] = filep[i];  
if (compare(afils[i]) && ptype){  
filepaths[ghd] = filep[i];  
dnams[ghd] = afils[i];  
ghd++;  
}  
}  
for (int i=0; i \< dirc; i++) adirp[i] = dirp[i];

```
 }
 if (!ptype){
   scrlen = 194 * ((dirc)/20);
 if (scrlen > 194) scrlen = 194;
 if (scrlen < 25) scrlen = 25;
 }
 }

```

void scanstart(){  
if (!scanning && chospath !="/"){  
wcnt=0;  
dirlev=0;  
totsize = 0;  
donesig=false;  
scanning = true;  
filsdone=false;  
nback=true;  
inroot=false;  
rootpath = chospath + “/”;  
path = rootpath;  
dpath = “”;  
dirmax=0;  
fndpath="";  
ptype = true;  
getnames();  
meth = false;  
scanning = true;  
incpath2();  
}  
}  
void savres(){  
int cnt=0;  
outbyte = new byte[totsize];  
for (int j = 0; j\< hun;j++){  
inbyte = loadBytes(fpath[j]);  
for (int i = 0;i\<inbyte.length;i++) outbyte[cnt+i] = inbyte[i];  
cnt+=inbyte.length;  
}  
saveBytes(rootpath+“javadocs.txt”,outbyte);  
donesig=true;  
}

void keyPressed(){  
if (key \> 31 && key \< 127) rootpath+=key;  
if (key == 8){  
String temp="";  
for(int i=0;i\<rootpath.length() - 1;i++) temp +=rootpath.charAt(i);  
rootpath = temp;  
}  
}  
boolean compare(String inval){  
boolean mres=true;  
boolean mres1=true;  
String mystr=" avaj.";  
for (int i=1;i\<5 && i \< inval.length();i++) if (inval.charAt(inval.length()-i) != mystr.charAt(i)) mres=false;  
mystr = " ssalc.";  
for (int i=1;i\<6 && i \< inval.length();i++) if (inval.charAt(inval.length()-i) != mystr.charAt(i)) mres1=false;  
return mres;  
}

String getpnam(){  
String retv = rootpath + “/”;  
String tpath = rootpath + “/”;  
File[] fil;  
boolean nfound=true;  
boolean err = false;  
int cnt=0;

for (int i=0;i \< dirlev && !err;i++) {  
fil = listFiles(tpath);  
if (fil == null) err=true;  
cnt=0;  
nfound = true;  
for (int j=0;j \< fil.length && nfound;j++){  
if (fil[j].isDirectory()) {  
if (cnt == dirnum[i]){  
retv+= fil[j].getName() + ‘/’;  
tpath+= fil[j].getName() + ‘/’;  
if (fil[j].getName() == spefold) fndpath=retv;  
nfound = false;  
}  
cnt++;  
}

}  
dirscnt[dirlev]=cnt;  
if (nfound && i \< dirlev - 1) err=true;  
}  
if (err) retv = “E”;  
return retv;  
}  
void trimpat() {  
// char c1 = str.charAt(0);  
if (chospath != “/”) {  
int plasf=0;  
boolean nfound = true;  
String temp ="";  
for (int i = chospath.length()-2; nfound && i\>1; i–) {  
if (chospath.charAt(i) == ‘/’) {  
nfound = false;  
plasf = i;  
}  
}  
for (int i = 0; i \< plasf; i++) temp = temp + (chospath.charAt(i));  
chospath = temp;  
ptype = false;  
getnames();  
}  
}  
void savdef() {  
String[] temp = new String[1];  
temp[0] = chospath;  
saveStrings(“default.txt”, temp);  
}  
String mytrim(String ins, int len) {  
String rets = “”;  
for (int i = 0; i \< len && i \< ins.length(); i++) rets = rets + ins.charAt(i);  
return rets;  
}  
public void windowMouse(PApplet appc, GWinData data, MouseEvent event) {  
savx = appc.mouseX-begx;  
savy = appc.mouseY - topy;  
switch(event.getAction()) {  
}  
if (event.getAction() == MouseEvent.PRESS){  
//if (appc.mouseX \> begx + 500 && appc.mouseX \< begx + 566 && appc.mouseY \> topy - 1 && appc.mouseY \< topy + 30) savdef();  
if (appc.mouseX \> begx-1 && appc.mouseX \< begx + 201 && appc.mouseY \> topy + 29 && appc.mouseY\< topy + 231) {  
selec = (appc.mouseY - topy - 33 )/ 16;  
int aloc = floor(dirc \* scrpos/174);  
if (selec + aloc\<dirc) {  
chospath = adirp[selec + aloc];  
getnames();  
} else {  
selec = - 1;  
}  
}

```
//if (appc.mouseY > topy + 5 && appc.mouseY < topy + 25 && appc.mouseX > begx + 474 && appc.mouseX < begx + 496) trimpat();

if (appc.mouseX > begx + 264 && appc.mouseX < begx + 466 && appc.mouseY > topy + 33 && appc.mouseY< topy + 228) {
  selec1 = (appc.mouseY - topy - 33 )/ 16;
  int aloc1 = floor(filec * scrpos1/174);
  
      //fname = afils[selec1 + aloc1];
      //chospath = afilp[selec1 + aloc1];

```

}

```
if (appc.mouseX > begx + 203 && appc.mouseX < begx + 230 && appc.mouseY > topy + 33 && appc.mouseY < topy + 231)
{
  oldy = appc.mouseY - topy - 33;
  moving = true;
}
if (appc.mouseX > begx + 464 && appc.mouseX < begx + 494 && appc.mouseY > topy + 33 && appc.mouseY < topy + 231)
{
  oldy1 = appc.mouseY - topy - 33;
  moving1 = true;
}

```

}  
if (event.getAction() == MouseEvent.MOVE){  
if (appc.mouseX \> begx + 203 && appc.mouseX \< begx + 230 && appc.mouseY \> topy + 33 && appc.mouseY \< topy + 231)  
{

```
  if (moving) {
  scrpos+= appc.mouseY - oldy - topy - 33;
  if (scrpos < 0 || scrpos + scrlen > 196) {
    if (scrpos < 0) scrpos = 0;
    if (scrpos + scrlen > 196) scrpos = 194 - scrlen;
  }
}
}else{
moving = false;
}

```

}

if (event.getAction() == MouseEvent.RELEASE){  
if (true) {  
if (moving) {  
scrpos+= appc.mouseY - oldy - topy - 33;  
if (scrpos \< 0 || scrpos + scrlen \> 196) {  
if (scrpos \< 0) scrpos = 0;  
if (scrpos + scrlen \> 196) scrpos = 194 - scrlen;  
}  
}  
if (moving1) {  
scrpos1+= appc.mouseY - oldy1 - topy - 33;  
if (scrpos1 \< 0 || scrpos1 + scrlen1 \> 196) {  
if (scrpos1 \< 0) scrpos1 = 0;  
if (scrpos1 + scrlen1 \> 196) scrpos1 = 194 - scrlen1;  
}  
}

```
moving = false;
moving1 = false;
}
}

```

}import g4p\_controls.\*;  
GButton btnClose,btnRun,btnFind,btnDone,btnTrim,btnDef;  
GWindow window;  
GWindow windowControl;

//GTextField txf1;  
GTimer timer;  
int wcnt;  
int oldy;  
int oldy1;  
int savx;  
int savy;  
int selec;  
int selec1;  
int scrpos;  
int scrpos1;  
int dispcnt;  
int scrlen;  
int scrlen1;  
boolean moving;  
boolean moving1;  
Boolean scanning;  
Boolean nowind;  
boolean nopath;  
boolean filesdone;  
boolean nback;  
boolean patherr;  
boolean inroot;  
boolean meth;  
boolean ptype;  
String path;  
String[] dnams;  
String dpath;  
String rootpath;  
String[] filepaths;  
String spefold;  
String fndpath;  
PFont font;  
PFont font1;  
PFont font2;  
int begx = 25;  
int topy = 25;  
int filnum;  
int dirmax;  
int ordnum;  
int jcnt;  
int hun;  
int dirnum[];  
int filscnt[];  
int dirscnt[];  
int filnums[];  
byte[] outbyte;  
byte[] inbyte;  
boolean[] filsdone2 = new boolean[10000];  
boolean filsdone;  
int dirlev;  
int dival;  
int totsize;  
int sizecnt;  
int rootnumb;  
String chospath;  
String[] afils;  
String[] adirs;  
String[] afilp;  
String[] adirp;  
String[] fpath = new String[1000];  
boolean donesig;  
int filec;  
int dirc;  
void setup(){  
String[] lines = loadStrings(“default.txt”);  
if (lines == null) {  
chospath = “/”;  
} else {  
chospath = lines[0];  
}

donesig=false;  
rootpath="/";  
chospath="";  
moving = false;  
moving1 = false;  
scrpos=0;  
scrpos1=0;  
selec = -1;  
selec1 = -1;  
dirnum = new int[1000];  
filscnt = new int[1000];  
dirscnt = new int[1000];  
filnums = new int[1000];  
for(int i=0;i\<1000;i++) dirnum[i] = 0;  
for(int i=0;i\<1000;i++) filscnt[i]=0;  
filsdone = false;  
dirlev=0;  
scanning = false;  
nowind = true;  
nopath=true;  
size(512,256);  
background(0, 0, 0);  
createConfigControls();  
font = loadFont(“ArialNarrow.vlw”);

font1 = loadFont(“CourierNewPS-BoldMT.vlw”);  
font2 = loadFont(“Arial-Black.vlw”);  
loop();  
timer = new GTimer(this, this, “update”, 100);  
[//timer.setInterval](https://timer.setInterval)(500);  
timer.start();

}

void draw(){  
stroke(0,0,0);  
fill(0,0,0);  
rect(0,0,width,height);  
stroke(255,255,255);  
fill(255,255,255);  
rect(0,0,512,64);  
textFont(font);  
textSize(20);  
fill(0,0,0);  
text(rootpath,0,16);

```
if (scanning) {
  text(dpath,0,48);
 
}

```

fill(255,255,255);  
if (donesig) text(“Done.”,0,128);

}  
void editDraw(PApplet app,GWinData data) {

app.background(0, 0,0);

```
app.textAlign(LEFT);
app.stroke(255, 255, 255);
app.fill(255, 255, 255);
//rect(width - 100,5,100,50);
app.fill(0, 0, 0);
app.textFont(font, 12);
//text(str(savx - begx),width - 100,20);
//text(str(savy - topy),width - 100,35);
app.textFont(font1);
app.textAlign(LEFT);
app.fill(0, 0, 127);
app.stroke(0, 0, 127);
app.rect(0,0,app.width,app.height);
app.fill(255, 255, 255);
app.stroke(255, 255, 255);
app.rect(begx, topy + 30, 200, 200);
app.rect(begx + 240, topy + 30, 200, 200);
app.rect(begx, topy, 469, 20);
//app.rect(begx + 475, topy, 67, 29);
if (dispcnt>0) app.rect(begx + 475, topy + 39, 67, 29);

app.fill(0, 0, 0);
app.stroke(0, 0, 0);
app.rect(begx + 454, topy + 9, 10, 2);
app.fill(0, 0, 255);
app.stroke(0, 0, 255);
app.rect(begx + 445, topy, 4, 20);
app.fill(255, 0, 0);
app.stroke(255, 0, 0);
app.textSize(12);
app.text(chospath, begx + 5, topy + 15);

int aloc = floor(dirc * scrpos/174);
int aloc1 = floor(filec * scrpos1/174);
for (int i = 0; i < 12; i++) if (i+aloc<dirc) {
  app.text(mytrim(adirs[i + aloc], 22), begx + 0, topy + 45 + 16 * i);
  if (i == selec)
  {
    app.rect(begx + 0, topy + 30 + selec * 16, 200, 15);
    app.fill(255, 255, 255);
    app.text(mytrim(adirs[i + aloc], 22), begx + 0, topy + 45 + 16 * i);
    app.fill(255, 0, 0);
  }
}

for (int i = 0; i < 12; i++) if (i+aloc1<filec) {
  app.text(mytrim(afils[i + aloc1], 22), begx + 245, topy + 45 + 16 * i);
  if (i == selec1)
  {
    app.rect(begx + 240, topy + 45 + selec1 * 16, 200, 16);
    app.fill(255, 255, 255);
    app.text(mytrim(afils[i + aloc1], 22), begx + 245, topy + 45 + 16 * i);
    app.fill(255, 0, 0);
  }
}

app.stroke(127, 127, 127);
app.fill(0, 0, 0);
app.rect(begx + 440, topy + 30, 29, 200);
app.rect(begx + 441, topy + 31, 27, 198);
app.rect(begx + 200, topy + 30, 29, 200);
app.rect(begx + 201, topy + 31, 27, 198);

app.fill(127, 127, 127);
app.rect(begx + 203, topy + 33 + scrpos, 23, scrlen);
app.rect(begx + 443, topy + 33 + scrpos1, 23, scrlen1);

```

}  
void update(GTimer timer) {  
if (scanning) incpath2();  
}  
void createConfigControls(){  
//txf1 = new GTextField(this, 10, 10, 200, 20);  
[//txf1.setPromptText](https://txf1.setPromptText)("");  
btnClose = new GButton(this, width - 32 , 8, 24, 24, “x”);  
btnRun = new GButton(this, 16 , height - 32, 128, 24, “Start”);  
btnFind = new GButton(this, 158 , height - 32, 128, 24, “Get path”);  
StyledString ss;  
ss = new StyledString(“X”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnClose.setStyledText(ss);  
ss = new StyledString(“Start”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnRun.setStyledText(ss);  
ss = new StyledString(“Get path”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnFind.setStyledText(ss);  
}  
public void createWindow(int type) {  
if (nowind){  
chospath = “/”;  
//String[] winnames={“Scan”,“Debug”,“Edit”,“Compile”};  
windowControl = GWindow.getWindow(this,“Get path”, 100, 100, 520, 300, JAVA2D);  
PApplet app = windowControl;  
//app = GWindow.getWindow(this, “Get path.”, 70, 160, 600, 600, JAVA2D);  
windowControl.addDrawHandler(this, “editDraw”);  
windowControl.addMouseHandler(this, “windowMouse”);  
btnDone = new GButton(app, 16 , app.height - 32, 128, 24, “Done”);  
btnTrim = new GButton(app,158,app.height - 32,128,24,“Trim Path”);  
btnDef = new GButton(app,294,app.height - 32,128,24,“Make Default”);  
StyledString ss;  
ss = new StyledString(“Done”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnDone.setStyledText(ss);  
ss = new StyledString(“Trim Path”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnTrim.setStyledText(ss);  
ss = new StyledString(“Make Default”);  
ss.addAttribute(G4P.WEIGHT, G4P.WEIGHT\_BOLD);  
btnDef.setStyledText(ss);  
nowind = false;  
ptype = false;  
getnames();  
}  
}  
public void handleButtonEvents(GButton button, GEvent event) {  
if (event == GEvent.CLICKED) {  
if (button == btnClose) exit();  
if (button == btnRun) scanstart();  
if (button == btnFind) createWindow(0);;  
if (button == btnDone && chospath!=""){  
nowind=true;  
windowControl.setVisible(!windowControl.isVisible());  
rootpath = chospath;  
}  
if (button == btnTrim){  
trimpat();  
}  
if (button == btnDef) {  
savdef();  
}  
}  
}  
void incpath2(){  
String tpath;

if (filsdone){  
if (dirnum[dirlev] \> dirc - 1){  
if (dirlev == 1){  
for(int i = 1;i \< dirmax;i++){  
dirnum[dirlev] = 0;  
}  
dirmax=0;  
}  
if (dirlev \> 0) dirlev–;  
dirnum[dirlev]++;  
if (dirnum[0] \> rootnumb-1) {  
scanning=false;  
savres();  
}  
}else{  
dirlev++;  
if (dirlev \> dirmax) dirmax=dirlev;  
filsdone=false;  
dirnum[dirlev] = 0;  
filscnt[dirlev] = 0;

```
}

tpath=getpnam();
if (tpath != "E") path = tpath;
getnames();

```

}else {  
if (filscnt[dirlev]\<jcnt){  
fpath[hun] = filepaths[filscnt[dirlev]];

```
inbyte = loadBytes(filepaths[filscnt[dirlev]]);
totsize+=inbyte.length; 

dpath = dnams[filscnt[dirlev]];
hun++;
filscnt[dirlev]++;
}else{

  filsdone = true;

```

}

```
 }
 wcnt++;
 }
 void getnames(){
   File[] fil;
   if (ptype){
fil = listFiles(path);
   }else{
    fil = listFiles(chospath);
   }
   if (fil == null){
     dirc = 0;
     filec = 0;
     jcnt = 0;
     dirscnt[dirlev] = dirc;
     filnums[dirlev] =jcnt;
   }else{

```

String[] filen = new String[fil.length];  
String[] dirn = new String[fil.length];  
String[] filep = new String[fil.length];  
String[] dirp = new String[fil.length];  
filec = 0;  
dirc= 0;  
jcnt=0;  
sizecnt=0;  
for (int i=0; i\<fil.length; i++) {  
if (fil[i] != null){  
if (fil[i].isDirectory()) {  
dirn[dirc] = fil[i].getName();  
dirp[dirc] = fil[i].getAbsolutePath();  
dirc++;  
} else  
{  
filen[filec] = fil[i].getName();  
if (compare(fil[i].getName()) && ptype) jcnt++;

```
  filep[filec] = fil[i].getAbsolutePath();
  filec++;
}

```

}  
}

dirscnt[dirlev] = dirc;  
filnums[dirlev] =filec;  
int ghd=0;  
if (nopath) rootnumb = dirc;  
nopath=false;  
if (ptype){  
filepaths = new String[jcnt];  
dnams = new String[jcnt];  
}  
afils = new String[filec];  
adirs = new String[dirc];  
afilp = new String[filec];  
adirp = new String[dirc];  
for (int i=0; i \< filec; i++) afils[i] = filen[i];  
for (int i=0; i \< dirc; i++) adirs[i] = dirn[i];  
for (int i=0; i \< filec; i++){  
afilp[i] = filep[i];  
if (compare(afils[i]) && ptype){  
filepaths[ghd] = filep[i];  
dnams[ghd] = afils[i];  
ghd++;  
}  
}  
for (int i=0; i \< dirc; i++) adirp[i] = dirp[i];

```
 }
 if (!ptype){
   scrlen = 194 * ((dirc)/20);
 if (scrlen > 194) scrlen = 194;
 if (scrlen < 25) scrlen = 25;
 }
 }

```

void scanstart(){  
if (!scanning && chospath !="/"){  
wcnt=0;  
dirlev=0;  
totsize = 0;  
donesig=false;  
scanning = true;  
filsdone=false;  
nback=true;  
inroot=false;  
rootpath = chospath + “/”;  
path = rootpath;  
dpath = “”;  
dirmax=0;  
fndpath="";  
ptype = true;  
getnames();  
meth = false;  
scanning = true;  
incpath2();  
}  
}  
void savres(){  
int cnt=0;  
outbyte = new byte[totsize];  
for (int j = 0; j\< hun;j++){  
inbyte = loadBytes(fpath[j]);  
for (int i = 0;i\<inbyte.length;i++) outbyte[cnt+i] = inbyte[i];  
cnt+=inbyte.length;  
}  
saveBytes(rootpath+“javadocs.txt”,outbyte);  
donesig=true;  
}

void keyPressed(){  
if (key \> 31 && key \< 127) rootpath+=key;  
if (key == 8){  
String temp="";  
for(int i=0;i\<rootpath.length() - 1;i++) temp +=rootpath.charAt(i);  
rootpath = temp;  
}  
}  
boolean compare(String inval){  
boolean mres=true;  
boolean mres1=true;  
String mystr=" avaj.";  
for (int i=1;i\<5 && i \< inval.length();i++) if (inval.charAt(inval.length()-i) != mystr.charAt(i)) mres=false;  
mystr = " ssalc.";  
for (int i=1;i\<6 && i \< inval.length();i++) if (inval.charAt(inval.length()-i) != mystr.charAt(i)) mres1=false;  
return mres;  
}

String getpnam(){  
String retv = rootpath + “/”;  
String tpath = rootpath + “/”;  
File[] fil;  
boolean nfound=true;  
boolean err = false;  
int cnt=0;

for (int i=0;i \< dirlev && !err;i++) {  
fil = listFiles(tpath);  
if (fil == null) err=true;  
cnt=0;  
nfound = true;  
for (int j=0;j \< fil.length && nfound;j++){  
if (fil[j].isDirectory()) {  
if (cnt == dirnum[i]){  
retv+= fil[j].getName() + ‘/’;  
tpath+= fil[j].getName() + ‘/’;  
if (fil[j].getName() == spefold) fndpath=retv;  
nfound = false;  
}  
cnt++;  
}

}  
dirscnt[dirlev]=cnt;  
if (nfound && i \< dirlev - 1) err=true;  
}  
if (err) retv = “E”;  
return retv;  
}  
void trimpat() {  
// char c1 = str.charAt(0);  
if (chospath != “/”) {  
int plasf=0;  
boolean nfound = true;  
String temp ="";  
for (int i = chospath.length()-2; nfound && i\>1; i–) {  
if (chospath.charAt(i) == ‘/’) {  
nfound = false;  
plasf = i;  
}  
}  
for (int i = 0; i \< plasf; i++) temp = temp + (chospath.charAt(i));  
chospath = temp;  
ptype = false;  
getnames();  
}  
}  
void savdef() {  
String[] temp = new String[1];  
temp[0] = chospath;  
saveStrings(“default.txt”, temp);  
}  
String mytrim(String ins, int len) {  
String rets = “”;  
for (int i = 0; i \< len && i \< ins.length(); i++) rets = rets + ins.charAt(i);  
return rets;  
}  
public void windowMouse(PApplet appc, GWinData data, MouseEvent event) {  
savx = appc.mouseX-begx;  
savy = appc.mouseY - topy;  
switch(event.getAction()) {  
}  
if (event.getAction() == MouseEvent.PRESS){  
//if (appc.mouseX \> begx + 500 && appc.mouseX \< begx + 566 && appc.mouseY \> topy - 1 && appc.mouseY \< topy + 30) savdef();  
if (appc.mouseX \> begx-1 && appc.mouseX \< begx + 201 && appc.mouseY \> topy + 29 && appc.mouseY\< topy + 231) {  
selec = (appc.mouseY - topy - 33 )/ 16;  
int aloc = floor(dirc \* scrpos/174);  
if (selec + aloc\<dirc) {  
chospath = adirp[selec + aloc];  
getnames();  
} else {  
selec = - 1;  
}  
}

```
//if (appc.mouseY > topy + 5 && appc.mouseY < topy + 25 && appc.mouseX > begx + 474 && appc.mouseX < begx + 496) trimpat();

if (appc.mouseX > begx + 264 && appc.mouseX < begx + 466 && appc.mouseY > topy + 33 && appc.mouseY< topy + 228) {
  selec1 = (appc.mouseY - topy - 33 )/ 16;
  int aloc1 = floor(filec * scrpos1/174);
  
      //fname = afils[selec1 + aloc1];
      //chospath = afilp[selec1 + aloc1];

```

}

```
if (appc.mouseX > begx + 203 && appc.mouseX < begx + 230 && appc.mouseY > topy + 33 && appc.mouseY < topy + 231)
{
  oldy = appc.mouseY - topy - 33;
  moving = true;
}
if (appc.mouseX > begx + 464 && appc.mouseX < begx + 494 && appc.mouseY > topy + 33 && appc.mouseY < topy + 231)
{
  oldy1 = appc.mouseY - topy - 33;
  moving1 = true;
}

```

}  
if (event.getAction() == MouseEvent.MOVE){  
if (appc.mouseX \> begx + 203 && appc.mouseX \< begx + 230 && appc.mouseY \> topy + 33 && appc.mouseY \< topy + 231)  
{

```
  if (moving) {
  scrpos+= appc.mouseY - oldy - topy - 33;
  if (scrpos < 0 || scrpos + scrlen > 196) {
    if (scrpos < 0) scrpos = 0;
    if (scrpos + scrlen > 196) scrpos = 194 - scrlen;
  }
}
}else{
moving = false;
}

```

}

if (event.getAction() == MouseEvent.RELEASE){  
if (true) {  
if (moving) {  
scrpos+= appc.mouseY - oldy - topy - 33;  
if (scrpos \< 0 || scrpos + scrlen \> 196) {  
if (scrpos \< 0) scrpos = 0;  
if (scrpos + scrlen \> 196) scrpos = 194 - scrlen;  
}  
}  
if (moving1) {  
scrpos1+= appc.mouseY - oldy1 - topy - 33;  
if (scrpos1 \< 0 || scrpos1 + scrlen1 \> 196) {  
if (scrpos1 \< 0) scrpos1 = 0;  
if (scrpos1 + scrlen1 \> 196) scrpos1 = 194 - scrlen1;  
}  
}

```
moving = false;
moving1 = false;
}
}

```

}

---

<div class="post-metadata">

**Author:** ![mgood7123](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Post date:** [June 4, 2020, 6:29am UTC](https://discourse.processing.org/t/anybody-have-looking-at-multiple-java-files-i-have-a-fix-for-this-but-i-cant-get-it-to-work-on-mac/21545/2 "2020-06-04T06:29:02Z")

</div>

please surround your code in ``````

for example

```  
dirscnt[dirlev]=cnt;  
if (nfound && i \< dirlev - 1) err=true;  
}  
if (err) retv = “E”;  
return retv;  
}  
```

becomes

```auto
        dirscnt[dirlev]=cnt;
        if (nfound && i < dirlev - 1) err=true;
    }
    if (err) retv = “E”;
    return retv;
}

```

---

<div class="post-metadata">

**Author:** ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)\
**Post date:** [June 4, 2020, 9:01am UTC](https://discourse.processing.org/t/anybody-have-looking-at-multiple-java-files-i-have-a-fix-for-this-but-i-cant-get-it-to-work-on-mac/21545/3 "2020-06-04T09:01:29Z")

</div>

Hi,

Windows (’/’) and mac (’’) use different character on the path. It called file separator. You can use `FileSystem.getSeparator()` to get character that system uses.

```auto
retv+= fil[j].getName() ‘/’;
tpath+= fil[j].getName() + ‘/’;

```

So instead of hardcoding it like above use that function to get right separator.
