Greetings! New to this forum, first time posting. =)
I'm currently trying to make a log-in or check-in system, it's meant to be able to allow users to log in, log out, and for there to be logs of the date and time the users did this. Issue being that I have never made anything like it before so it's a nice little project where I try to learn as much as possible as I go along.
Now the current issue that I am having is that I'm terrible with all forms of coding which involves sending data from one class to the other, and that is exactly the problem I am having right now. I have a mainframe.java class which contains all of the GUI, basic JFrame with a couple of JButtons, some text and the like.
When I press the button "Add Member" currently a JOptionPane.showInputDialog shows up, and I can type in the name of the user. However, this is where I really don't know how to proceed, I have a Member.java class I want to use for keeping track of all of the separate members/users, but I do not know how to send over the data, store it properly, and then call for the respective user whenever I need to refer to it (for example when he/she logs out).
This is the code for when a button is pushed, and it checks that Add Member is the right one:
public void actionPerformed(ActionEvent e) { int i = 0; int i2 = 1; boolean cancel = false; if(e.getSource() == AMB) { while(cancel == false) { if(members[i] == "") { i2 = i+1; //***This is where I want to send the information to the members class to be stored for overall usage of the new user. //Members.class name = new class(arguments); = JOptionPane.showInputDialog(null, "Adding member:"); This is a failure of an attempt of me trying to at the very least send over the name... if(members[i] == null) { members[i] = ""; //In case no name is written, this makes sure that the array slot stays empty for reuse } cancel = true; }
(I skipped the rest because my post was denied when trying to post too much code, so I only posted the most essential bit and if there is anything else in the code that you would like me to post for further clarification feel free to ask.)
And this is the Members.java class:
package LoginSystem; public class Members { String name; int lastLoggedIn; public Members (String Name, int logIn) { lastLoggedIn = logIn; name = Name; } }
Very basic so far since I don't really know how to flesh it out.
I'm sorry that I can't post much of what I've tried, but that's mostly because I have no idea of what to try or where to find information of what I could try. I have tried to search around for answers but to no success. =/
Any help, be it tips, pointers or just general advice in how to proceed would be greatly appreciated!
Kind regards, Lora.