W3R3 – Add a Save File Option - doesnt yet update csv.

This commit is contained in:
bobbert committed 2025-02-15 13:44:38 +00:00
1 parent 9e9b958853
commit fed70cf754
2 files changed
+46 -5

No files matched your search

@@ -13,6 +13,42 @@ import java.io.*;
* This is model class may be handy for putting data relevant groups of User Profiles in {many Users]
*/
public class UserGroup {
public String getUser(int row, String Pname, String file) {
String text = "Default Text";
String[] values = null;
try (BufferedReader csvReader = new BufferedReader(new FileReader(file))) {
while (csvReader.ready()) {
String line = csvReader.readLine();
values = line.split(",");
for (int i =0; i < values.length; i=i+4)
{
if ( row == Integer.parseInt(String.valueOf(values[i].charAt(4))) )
{
if (Pname.equals("User Title"))
{
text = values[i+1];
System.out.println("Set radio button text to :" + text);
return text;
}
else if (Pname.equals("User Name")) {
text = values[i+2];
System.out.println("Set radio button text to :" + text);
return text;
}
else if (Pname.equals("User Email")) {
text = values[i+3];
System.out.println("Set radio button text to :" + text);
return text;
}
}
}
}
}
catch (Exception e) {
System.out.println("error with reader");
}
return text;
}
}
@@ -4,6 +4,8 @@
*/
package userprofilebuilder.view;
import userprofilebuilder.model.UserGroup;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
@@ -22,8 +24,6 @@ public class MainViewer {
public int a = 3; // this represents a value that is to declare how many rows are to be made -- to be changed by the amount of lines in csv. ROW COUNT
// start of reader creation
public String Reader(int row, String Pname) {
String text = "Default Text";
String[] values = null;
@@ -62,9 +62,6 @@ public class MainViewer {
return text;
}
// end of reader
private void CreateRow(int count, JPanel jp, String Pname)
{
int row = count+1;
@@ -198,6 +195,14 @@ public class MainViewer {
open.addActionListener(opener);
JMenuItem save = new JMenuItem("Save");
menu.add(save);
ActionListener SaveAction = e -> {
System.out.println("Save attempt made");
};
save.addActionListener(SaveAction);
JMenuItem quit = new JMenuItem("Quit");
menu.add(quit);
ActionListener quitter = e -> {