W4R3 – 'UserProfile' Button Panel

This commit is contained in:
bobbert committed 2025-02-15 16:56:07 +00:00
1 parent 4b65140f17
commit 2f87c1b848
4 files changed
+41 -58

No files matched your search

@@ -13,41 +13,5 @@ import java.io.FileReader;
* This is model class may be handy for putting data relevant to the User Profile in
*/
public class User {
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;
}
}
@@ -76,8 +76,6 @@ public class UserGroup {
}
}
}
catch (Exception e) {
System.out.println("error with reader");
@@ -0,0 +1,35 @@
package userprofilebuilder.model;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
public class UserProfile {
public static void footer(JPanel tab)
{
JPanel page = new JPanel();
JButton displayProfile = new JButton("Display Profile");
ActionListener displayer = e -> {
System.out.println("displayer clicked");
};
displayProfile.addActionListener(displayer);
JButton addProfile = new JButton("Add Profile");
ActionListener adder = e -> {
System.out.println("profile add button clicked");
};
addProfile.addActionListener(adder);
JPanel footer = new JPanel();
footer.add(displayProfile);
footer.add(addProfile);
tab.add(footer);
}
}
@@ -5,6 +5,7 @@
package userprofilebuilder.view;
import userprofilebuilder.model.UserGroup;
import userprofilebuilder.model.UserProfile;
import java.awt.*;
import javax.swing.*;
@@ -173,30 +174,14 @@ public class MainViewer {
}
TotalRows = group.getButtonCount();
JButton displayProfile = new JButton("Display Profile");
ActionListener displayer = e -> {
System.out.println("displayer clicked");
};
displayProfile.addActionListener(displayer);
JButton addProfile = new JButton("Add Profile");
ActionListener adder = e -> {
System.out.println("profile add button clicked");
};
addProfile.addActionListener(adder);
JPanel footer = new JPanel();
footer.add(displayProfile);
footer.add(addProfile);
page.add(footer);
UserProfile.footer(page);
}
public MainViewer() // main viewer window
{
UserProfile userProfile = new UserProfile();
viewer = new JFrame();
viewer.setTitle("User Profile Builder");
viewer.setSize(800,500);
@@ -248,6 +233,7 @@ public class MainViewer {
viewer.add(JT);
JT.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
viewer.setVisible(true);