import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class OneRMCalc { static JFrame pr = new JFrame("One Rep Max"); static JTextField weight = new JTextField("Insert Weight"); static JTextField rep = new JTextField("Insert Reps"); public static void submit(){ Main.smallfont(); JButton submit = new JButton("Submit"); submit.setFont(Main.smallfont); submit.setForeground(Main.redish); submit.setBackground(Main.greenish); submit.setBounds(30,100,220,120); pr.add(submit); submit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Main.smallfont(); long weightd; long repd; long repweight; long repweight033; long onerm; pr.setVisible(false); pr.removeAll(); pr.dispose(); String weights = weight.getText(); weightd = Long.parseLong(weights); String reps = rep.getText(); repd = Long.parseLong(reps); repweight = repd * weightd; repweight033 = (long) (repweight*0.033); onerm = repweight033+weightd; JFrame fin = new JFrame("Your One Rep Max"); fin.setSize(350,100); fin.setVisible(true); fin.getContentPane().setBackground(Main.redish); fin.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); int roundedonerm = (int) Math.round(onerm); System.out.println(roundedonerm); JLabel ans = new JLabel("Your One Rep Max is: "+roundedonerm,SwingConstants.CENTER); ans.setFont(Main.smallfont); ans.setVerticalAlignment(SwingConstants.CENTER); ans.setForeground(Main.greenish); ans.setBounds(0, 25, 500, 50); fin.add(ans); fin.repaint(); fin.setVisible(true); } }); } public static void setFrame(){ Main.bigfont(); pr.setSize(300,300); pr.getContentPane().setBackground(Main.redish); pr.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); submit(); weight.setBounds(30, 40, 90, 25); weight.setVisible(true); pr.add(weight); rep.setBounds(155,40,90,25); rep.setVisible(true); pr.add(rep); JLabel header = new JLabel("Enter the Details", SwingConstants.CENTER); header.setFont(Main.bigfont); header.setVerticalAlignment(SwingConstants.TOP); header.setForeground(Main.greenish); pr.add(header); pr.setVisible(true); } }