r/processing • • 9d ago

Beginner help request What do i need to write to have an interactable window

I have an assignment where I want to have like a mini windows computer. I wanna know how I can 'open up new apps', like click on an icon on the 'desktop' and have it open up a new 'tab'. I want to have my main window, open up into a file explorer, and then have different files in the file explorer that open up into different things. but im not sure how to do it. does anyone have any ideas?

3 Upvotes

7 comments sorted by

1

u/LeibnizoverNewton 8d ago

Hello, I'm not an expert when it comes to processing. However, I will say that each the processing IDE is primarily intended to be used in Java mode in which it creates an instance of the PApplet class upon the creation of each sketch. You should try using the Processing extension in VSCode and then create a PApplet using the Processing library and then use Swing from Java's built in JDK (Java Development Kit) to create windows, buttons, and other software application components.

2

u/tuto42 9d ago

That looks a little ambitious, maybe you could start by doing only one of those things first ?

If you want to get good help here I think it will go better if you ask about something more specific, more basic.

But you lucky Im bored out of my mind in an hospital bed so here are some pointers about your specific case :

When creating large software the trick is to break the big problem in many small ones then resolving them individually and then trying to make them work together later.

I was personnaly never able to open multiple windows from the same program with processing alone, at least not in an usefull way, you will have to keep everything in one window.

main window open up into a file explorer :

For this you will need first to learn a proper GUI library, I used ControlP5 a lot and its really good, it has everything you will need. Add the lib to your code and start making small widget and button to test it. Once you feel more confident you will start making your explorer UI design.

have different files in the file explorer :

If you want to create new "file" object inside your explorer and to find them again after restarting your soft you will need to learn about how to store and retrieve data to / from your PC harddrive. You should take a look at the methods offered by processing to read and write to a file. If your objects are complexe I recommend json its powerfull and relatively easy to use.

They open up into different things :

I think you should start by focusing on one thing only, maybe a basic text editor ? If you try to do too many tools at the same time you will most likely get burnout before achieving anything significant.

If you want to ask for help here again later you are always free to do so but please take a little bit more time to explain your needs and what you dont understands, us old farts like long and well written text so we will be more inclined toward helping you if you do so ;)

And lastly, good luck. Programing is hard in itself and your project is really not the simplest.

Tuto out

2

u/IndicationInitial143 9d ago

sorry about not being to explain it well, i only started learning like a week ago and my teacher made it sound like it would be easy enough. I guess ill change it since it seems so hard. Would it be easier to have every button i wanna press on the like desktop, just when you open up the code? and make it so that each icon you press it just opens up something new, like 1 button or app opens up a picture, another opens up a different photo, and maybe another one opens up a extremely redementary like etchasketch thing (i wanted to use the code that just adds shapes constantly and doesnt change the background so it basically 'draws' wherever your mouse goes) I'm still not sure how possible what im wanting sounds, im just trying to find soemthing to do thats interactable in some way.

1

u/tuto42 9d ago edited 9d ago

Dont be sorry, you here to learn.

"I guess ill change it since it seems so hard" : did your teacher validate your project ? I think he would be better placed to help you define the scope of your project, I am not sure I understand your assignment so maybe I am out of line.

"Would it be easier to have every button i wanna press on the like desktop, just when you open up the code?" : this is a good idee for a start, try displaying some button and have them control the value of an int, then use this int to switch whats drawn in a " workspace " zone of your screen. With some tinkering you could have something like a set of tabs. You will define your ControlP5 Button in your setup() function and the switch case will be in your draw function.

" 1 button or app opens up a picture, another opens up a different photo, " : you will get to this later, start by switching simply between basic text / shape, you will change it to something else later. Remember : one small problem at a time, only when its done you go to the next.

" extremely redementary like etchasketch thing (i wanted to use the code that just adds shapes constantly and doesnt change the background so it basically 'draws' wherever your mouse goes) " : Hoho This is a really good thing to try, I will be honest it will not work, at least not right away, but I think you will learn more by trying this yourself so I will not say more :)

" I'm still not sure how possible what im wanting sounds " : Then test things ! The marvellous thing about programming is that you can make as many stupid mistake as you want, nobody will know ! get to it and test shit, you will learn waay more that way and quicker. Some dude said this one day : " build shit quick, break them faster, repeat "

Go grab the ControlP5 lib and add some buttons, try to make them switch between some texts, add a little shape here and there... You will find the rest by yourself. Just start coding. :)

2

u/IndicationInitial143 9d ago

Thank you so much. My teacher did say my idea was good, but he didn't give me super good direction on what code to use or how to achieve it; I think it might've confused him too. I'm bouncing between doing this idea or just trying to replicate a preexisting game like Flappy Bird, the Google dinosaur game, or Snake for my project. (though idk if that would be any easier) He mostly just said it needed to keep someone's attention for more than a minute, which is so broad, and that's why I'm struggling. I'll definitely try some of these out tho, thank you for your insight! I'll get to coding! c:

1

u/tuto42 9d ago

My pleasure, always happy to speak about thoses things you know !

Maybe validate with your teacher if you can use external lib, with the way he said it I see what he want and maybe he will want you to keep to basic code for now. In this case doing a snake is always a good idee. Be aware that the algorithm is really not that simple, but he will probably be impressed.

Edit : and if its not working flappy bird is dumb easy to do ;)

"I'm bouncing between doing this idea or... " : do both ! :)

1

u/R_GiskardOlivaw 7d ago

Hello, I'm not a student anymore but it was also difficult to me to write regular desktop apps with Processing. That's the main reason I made this library:

https://github.com/cdpoloz/cpz-mvvm-processing-controls

You can use it in your project and have controls equivalent to the ones that come with Swing (not all of them) but you can give them a custom style. Personally I don't like Swing because for me it seems old fashioned. There are some basic examples that you can easily modify according to your needs. Just a detail, I use this library within IntelliJ not the Processing IDE. If the documentation is not enough for you feel free to message me with your questions, good luck and keep coding!