Easy Employee ID and Name Badge Generator

Braden Evans

Software Engineer
Java

Create employee badges with corresponding colors and levels with an interactive graphic user interface

public Main() {
        super("Employee Badge Generator");

        setLayout(new BorderLayout());

        JPanel topPanel = new JPanel(new FlowLayout());
        numBadgesLabel = new JLabel("How many badges? Up to five:");
        topPanel.add(numBadgesLabel);
        numBadgesField = new JTextField(5);
        topPanel.add(numBadgesField);
        generateButton = new JButton("Generate Badges");
        generateButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int numBadges = Integer.parseInt(numBadgesField.getText());
                if (numBadges > 0 && numBadges <= 5) {
                    createBadgeTabs(numBadges);
                    topPanel.setVisible(false); // Hide badge number selection fields
                } else {
                    JOptionPane.showMessageDialog(Main.this, "Invalid number of badges. Please enter a number between 1 and 5.");
                }
            }
        });
        topPanel.add(generateButton);
        add(topPanel, BorderLayout.NORTH);

        tabbedPane = new JTabbedPane();
        add(tabbedPane, BorderLayout.CENTER);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(600, 400);
        setLocationRelativeTo(null);
        setVisible(true);
    }
Partner With Braden
View Services

More Projects by Braden