Open links in new tab
  1. Below is a simple implementation of a voting system in Java using Swing for the GUI. This system allows users to vote for one of three parties and displays the results.

    import javax.swing.*;

    public class VotingSystem extends JFrame {
    private static int partyA = 0;
    private static int partyB = 0;
    private static int partyC = 0;

    public VotingSystem() {
    initComponents();
    }

    private void initComponents() {
    JLabel titleLabel = new JLabel("Online Voting System");
    titleLabel.setFont(new java.awt.Font("Tahoma", 1, 24));

    JLabel nameLabel = new JLabel("Enter Name:");
    JTextField nameField = new JTextField();

    JLabel phoneLabel = new JLabel("Enter Phone:");
    JTextField phoneField = new JTextField();

    JRadioButton partyARadio = new JRadioButton("Party A");
    JRadioButton partyBRadio = new JRadioButton("Party B");
    JRadioButton partyCRadio = new JRadioButton("Party C");

    ButtonGroup group = new ButtonGroup();
    group.add(partyARadio);
    group.add(partyBRadio);
    group.add(partyCRadio);

    JButton submitButton = new JButton("Submit Vote");
    JButton resultButton = new JButton("Check Results");

    submitButton.addActionListener(evt -> {
    if (partyARadio.isSelected()) {
    partyA++;
    } else if (partyBRadio.isSelected()) {
    partyB++;
    } else if (partyCRadio.isSelected()) {
    partyC++;
    } else {
    JOptionPane.showMessageDialog(this, "Please select a party!");
    return;
    }
    JOptionPane.showMessageDialog(this, "Vote submitted successfully!");
    nameField.setText("");
    phoneField.setText("");
    group.clearSelection();
    });

    resultButton.addActionListener(evt -> {
    String resultMessage = String.format(
    "Party A: %d votes\nParty B: %d votes\nParty C: %d votes\n",
    partyA, partyB, partyC
    );
    JOptionPane.showMessageDialog(this, resultMessage);
    });

    setLayout(new java.awt.GridLayout(8, 2));
    add(titleLabel);
    add(new JLabel());
    add(nameLabel);
    add(nameField);
    add(phoneLabel);
    add(phoneField);
    add(new JLabel("Select Party:"));
    add(new JLabel());
    add(partyARadio);
    add(partyBRadio);
    add(partyCRadio);
    add(new JLabel());
    add(submitButton);
    add(resultButton);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    }

    public static void main(String[] args) {
    java.awt.EventQueue.invokeLater(() -> new VotingSystem().setVisible(true));
    }
    }
    Copied!
  1. voting-system · GitHub Topics · GitHub

    Jul 26, 2024 · This repository contains the source code for a simple voting system developed in Java using the Spring Boot framework. The system allows users to …

  2. Online voting System project in java with source code and …

    Mar 26, 2022 · This project is designed to automate the voting system. where multiple parties or teams can be involved in choosing the leader. The complete …

  3. Java Simple Voting System Project - w3resource

    Sep 16, 2025 · Learn to create a simple voting system in Java with two solutions. Includes commented code examples and explanations for better understanding.

  4. Online Voting System Using Java With Source Code

    • See More

    This project is an excellent example of how programming can be used to create a practical and secure voting system for organizations, communities, or small-scale elections.

  5. Online Voting System using Java Swing - CodeSpeedy

    Learn how to build a simple online voting system in Java using Swing. We can use Jframe as this is a GUI application.

  6. Building a Voting System in Java: A Comprehensive Guide

    Learn how to build a secure and efficient voting system in Java using OOP principles. Step-by-step tutorial with code examples and best practices.

  7. Simple Voting System In Java With Source Code

    -To download the simple voting system project for free (Scroll Down) The Simple voting system is a java project that maintains the official records of polling result.

  8. Managing a Voting System using Java | CodeSignal Learn

    The lesson focuses on maintaining backward compatibility while incorporating new functionality, providing step-by-step Java code examples for each enhancement.

  9. Voting Management System using Java Swing Free code

    The Voting Management System is a Windows-based application developed using Java Swing for the frontend and PostgreSQL as the backend. This system is …

  10. GitHub - aryanrajrcotba/Online-Voting-System: A Java-based voting …

    Developed using Java Swing for the graphical user interface (GUI) and MySQL for backend database management, this application handles essential voting functionalities including user authentication, …

  11. People also ask
    Loading
    Unable to load answer