Untitled

mail@pastecode.io avatar
unknown
plain_text
24 days ago
2.0 kB
2
Indexable
Never
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class AdminFunctionsGUI {

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> createAndShowGUI());
    }

    private static void createAndShowGUI() {
        JFrame frame = new JFrame("Admin Functions");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 200);

        JPanel panel = new JPanel(new GridLayout(3, 4, 10, 10)); // 3 rows, 4 columns

        // Buttons
        JButton viewBooksButton = new JButton("View Books");
        JButton viewUsersButton = new JButton("View Users");
        JButton viewIssuedBooksButton = new JButton("View Issued Books");
        JButton issueBookButton = new JButton("Issue Book");
        JButton addUserButton = new JButton("Add User");
        JButton addBookButton = new JButton("Add Book");
        JButton returnBookButton = new JButton("Return Book");
        JButton createResetButton = new JButton("Create/Reset");

        // Add buttons to the panel
        panel.add(viewBooksButton);
        panel.add(viewUsersButton);
        panel.add(viewIssuedBooksButton);
        panel.add(issueBookButton);
        panel.add(addUserButton);
        panel.add(addBookButton);
        panel.add(returnBookButton);
        panel.add(createResetButton);

        frame.getContentPane().add(panel);

        // Add action listeners to the buttons (replace with your actual logic)
        viewBooksButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // Handle View Books button click
                System.out.println("View Books button clicked");
            }
        });
        // Add similar action listeners for other buttons

        frame.setVisible(true);
        frame.setResizable(false);  
        frame.setLocationRelativeTo(null);
    }
}
Leave a Comment