Gurtej Grewal

+ Follow
since Apr 28, 2021
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gurtej Grewal

Im setting up a small Login/Signup pages, i have this button that is meant to return the user to the option screen where they can pick wether to login or signup, the button worked fine on 'page 2' however when i added the same button onto page 3, it stopped working on page 2 and worked on page 3. whats the reason for this? do i have to recreate the same button with the same function everytime i want to use it on a different page? View Line 18 and 13 for the back buttons

1 day ago
Update: The Login And Signup Buttons were being added to this. instead of the panelOption, Works Good Now
1 day ago
So here i have 3 pages.
Page1: Ask the user if they want to login or sign up
Page 2 and 3: Signup page and Login page

The program starts with the Login and Signup Option, however when either one is clicked, instead of switching pages, it displays the label beside the original page.

Note*I know the screen is larger than it needs to be, the background colour wasnt working when i frame.pack(), ill fix that when i can get the pages working

Quick side Question on Line 83 of Panel Class

Main Class

Frame Class

Panel Class

1 day ago
Im Starting to move from text-based programs to graphics using GUI's, I've been watching some course to familiarize myself with the basics. Tutorial:
. So on any GUI I would see buttons, menus, progress bars, etc placed at specific locations. My Question is, is it best to set bounds for each component or to use several panels as containers for different parts. If bounds is the best way to go, are there any simple online softwares to help get the size/location of components(EX: Telling whatever software the screen size, drawing different boxes onto it and receiving bounds of each part as drawn). If Panels are better, should i be using several panels to organize each components/group of components or is there a better Layout Manager to assist with that?
3 days ago
yea thats why i didnt want to use the exact same thing but wanted to change it to my needs.
1 week ago

fred rosenberger wrote:you want to write 13 methods - one method for each of the twelve, and then one method that calls the other twelve.  

coming back to this, if i have many small methods and i need to call them into eachother or have them all put together into another method, is it correct to call methodName();? This may sound simple but i remember being told that this was incorrect for some reason and it confused me for the longest time.
1 week ago
This is where i found the original:

I know theres a lot here that i dont understand, normally i wouldnt get into anything new like hashmaps right now at all, but because of school we are just rushed into alot. Im hoping to go through MOOC when schools over and go through everything carefully instead of learning by just implementing these things into my code.

1.I know the JavaDoc is good place to learn different methods and more but due to all the information it seems hard to find what im looking for, whats the best way to navigate sites like the javaDoc?

2. What do you mean by my indentation isnt consistent? From what i see in my code i have anything thats surrounded by either a class, method, if statement, for loop, etc indented to show that it is inside something else, is this incorrect?

3.Thanks i often seem to forget that 'get' in naming is something different in java compared to regular english. Ill keep this in mind from now on.

1 week ago
I believe this should work now
1 week ago
Im told the part checking if max is equal to the number found is always false and so nothing happens when the method is run, how should i fix this loop?
1 week ago
So from what i understand im calling
for (Map.Entry<String, int[]> entry : map.entrySet())
and within this loop im finding the max, the im using the loop again
for (Map.Entry<String, int[]> entry1 : map.entrySet())
and if the values of this loop equal the value of max i print the key?
1 week ago
This is just an example from google of finding the max integer, i didnt do anything to it, only reason i added it was to say this method wont work, what else can i do
1 week ago
so i have a hashmap with a String key and array values, how would i search through the first indexes of each array to find the largest number? I tried but this hasnt worked with arrays.
1 week ago
My Question is as stated in the subject, i often find myself repeating certain types of mistakes(like over complicating code trying to fit new things i learn) or coding in ways that are not the 'standard practice'. Id like to know what are the general things i should avoid doing and what should i keep in mind when starting a new program? Im 18 going to uni for compsci so im hoping to make a career out of programming and dont want to be hung up on these mistakes.
1 week ago
I have this code that is supposed to take input from the user and save it as a List, this List is then used in a Hashmap with the persons name as the Key and the information of the person in the List. When this is printed onto the text file the expected results from;
Input 1:
Name: Bob; item1: 4, item2: 1; etc...

Input 2: Robin; item1: 1, item2: 6; etc...

Expected Results:
Bob:[4 1 34 1 3 6 (2021/06/02 01:02:35)]
Robin:[1 2 34 1 3 6 (2021/06/02 01:02:35)]

Current Results:
Bob:[4 1 34 1 3 6 (2021/06/02 01:02:35)]

Bob:[4 1 34 1 3 6 (2021/06/02 01:02:35), 1 2 34 1 3 6  (2021/06/02 01:02:46)]

Robin:[4 1 34 1 3 6 (2021/06/02 01:02:35), 1 2 34 1 3 6  (2021/06/02 01:02:46)]

Why is this happening?

Main Class

Reader Class
1 week ago
I found this code on stackover flow and i hope to use it for a simple homework assignment but im a little confused on what the index != -1 means and why it works

From what i understand is that when java searches for a string in a file and it does not exist, (or perhaps in an array even) the index is considered -1, so as long as it is not -1 it would mean it exists. Not sure if im looking at this correctly or not.
2 weeks ago