The HTML Validator is a simple Java Swing application that allows users to input a text and validate if the parentheses (and other related characters) are balanced.
- Input Text Area: Allows users to input text containing HTML code or any text with parentheses.
- Validation Button: Clicking the "Validate" button checks whether the parentheses in the input are balanced or not.
- Result Text Area: Displays the result of the validation process - whether the input has balanced parentheses or not.
- Enter the text containing HTML code or any text with parentheses in the top text area.
- Click the "Validate" button to check if the parentheses are balanced.
- The result will be displayed in the bottom text area.
The validation process involves extracting only the parentheses from the input text and checking if they are balanced using a stack data structure.
- HTMLValidator: The main class that extends
JFrameand creates the GUI components. - onlyParentheses: A method that extracts only parentheses from the input text.
- isValid: A method that checks whether the extracted parentheses are balanced or not using a stack.
- Java Swing library for GUI components.
- Compile the Java file:
javac HTMLValidator.java - Run the compiled class:
java HTMLValidator