#gui issue in java swing
1 messages Ā· Page 1 of 1 (latest)
<@&987246487241105418> please have a look, thanks.
I uploaded your attachments as Gist.
might help to mention where and what method as its not 'small' code
uhh its the login method and the authenticate method that im having issues with when i uhh change the field to id instead of username
team work or gpt ?
if u want the other classes i can post them
nah just me nd a friend lol
i asked chatgpt and it barely made 50 lines of some nonsense
got the account class aswell ?
gimme a sec
Please use this format for posting code:
```java
// Example java program
int value = 5;
System.out.println(value);
```
Which results in:
// Example java program
int value = 5;
System.out.println(value);
For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.
public class Account {
private String name;
private int id;
private int password;
public Account(String name, int id, int password) {
this.name = name;
this.id = id;
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPassword() {
return password;
}
public void setPassword(int password) {
this.password = password;
}
@Override
public String toString() {
return name + " (ID: " + id + ")";
}
}```
well u got a getId so use that
i tried to but the authenticate method isnt accepting it somehow
gimme a sec to show u
account.getId(Integer.parseInt( ..... should do it , same as your password
yeye my bad
.equals(id) id isn't a variable
now parse the text to int
gimme a sec
same as u did with the passwprd
to try
Wait your password can only be a number?
ye the prof doesnt mind
i asked him
then maybe change the variable to passcode
ye lol
also 1 tiny thing u might want to reflect on. On your system, everyone has admin rights by default ?
normally its the inverse. Only a few get admin rights and the rest are normal users
did i do it wrong?
the system has two users employees and an admin if u log in as an employee u get a diff java frame so technically u have the perms but nowhere to use them
your feeding in username, password
so either refactor those to match, or match the variables
i just noticed im sorry
that's like giving a murderous criminal a knife but not putting any humans near them to use it on. The moment a human gets in it's range all hell breaks loose
You should also clean up your class a bit, there's a lot going in one class. It has a very strong openAI vibe.
and if u seen exeptions, use them instead of return null
well the lazy friend gave me almost all the work lol
ill try to clean up
my very question :p
the lazy friend did do the effort to open a browser to generate some code š
Group project = shared responsibility.
pointers keep coming, line 172 on the gist ( for lab lab : labs ... ), servers no point
unless your filling all your labs with null, u do not need the check
( and not to mention its double but that might be a c&p error )
Objects default to null if not initialized
shoudlnt be in the collection then if its nothing
unless your doing 1 wacky assigment where u have to mix arrays and lists, refactor your code
I'd also reconsider the way you store your output, that's really not a convenient manner.
(These are not points to put the code down, but to improve on your skills )
ye lol its still not finished im trying as fast as i can but most probs i search for are hard to implement into the code bc of the methods i imported from my frind i might just remove them and tell the prof to seperate us but thats too much of a headache+drama
u can ask your friend to revise them š
i genuinely dont get it whats wrong(bear in my mind this is on me as i volunteered for an extracurricular be4 even finishing java 200 course)
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new ReservationSystemGUI();
}
});```
you can rewrite this as
```java
SwingUtilities.invokeLater(() -> new ReservationSystemGUI());
i think hes using copilot
any eror i ask him abt in his methods
doesnt matter how he / she generated it
he sends completely diff ones
you don't need to parseInt an int
in fact you can't
it fa285 who suggested that unless i understood them wrong
dont try to go to fast
your guessing as bad as your teammate
your method has 2 variables, both STRING
so u need to check on your account.getId a parsed version of one of those strings
so its like K said. Your on the correct path, but u do not need to parse the Account's return type, only the variable coming from String type
so ( but in code ) account.getId() is equal to the converted text of id
check it a few times more to be certain, but in some cases that might work
man the prof said the requirement is finishing java 201 & i havent finished 200 yet i shouldve probs listened to him
i need to train more and probably kick my teammate
no need to kick
enlighten him / her , like Simon mentiond, its a shared responsabilty
both either fail or pass
did you change getId() to return a string?
yes
ok
thank u for telling me
ill try to talk to him tmrw
also tell him, that u asked advice here and that everyone saw that the code was generated š
so your prof will aswell
also another friend said im stupid for not using netbeans' gui form designer and that i wasted time coding by hand
oh ye im telling them both i dont want any slander on my name 
not stupid, but there is a point there. Code a gui by hand a few times. Then make life easier
most people have migrated to javaFx and the answer will depend on what gui it has to be
couple simple popups, most likely by hand
anything that needs to look 'alright' and more , with editors as they are faster, easier to see what your doing ( remember the term WYSIWYG ? ) )
that makes sense ye
thank u both @pliant oyster @errant narwhal i hope i didnt waste ur time by taking a proj i was suited for fully
u didnt, and your doing it anyhow, so u ARE suited
np, I was literally sitting in my chair waiting for things to help out with
is there a way to display it visually or will i have to restructure it completely to be accepted by netbeans
the inbuild netbeans editor use some sort of form to create it so from 0. U can however tie in your methods once its created