Question
Seeking help with a code -GUI java, basics import java.awt.*; import java.awt.color.*; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JFrame; import
Seeking help with a code -GUI java, basics
import java.awt.*;
import java.awt.color.*;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
public class Proj1_Final_GUI_Infix extends JFrame implements ActionListener{
//private static Object frame;
private JButton evaluate;
private JLabel infixLabel = new JLabel("Enter Infix Expression");
private JLabel resultLabel = new JLabel("Result:");
private JTextArea inputArea ;
private JTextArea outputArea;
public Proj1_Final_GUI_Infix(){
inputArea = new JTextArea(1, 15);
inputArea.setMargin(new Insets(1,1,1,1));
inputArea.setEditable(true);
inputArea.setBackground(Color.BLUE);
inputArea.setEditable(true);
outputArea = new JTextArea(1 ,15);
outputArea.setMargin(new Insets(1,1,1,1));
outputArea.setEditable(false);
outputArea.setMargin(new Insets(1, 1, 1, 1));
outputArea.setEditable(false);
outputArea.setBackground(Color.BLUE);
//look for evaluation button
//this.infixLabel = new JLabel("Enter Infix expression");
}
@SuppressWarnings("PackageVisibleField")
Proj1_Final_GUI_Infix prob =new Proj1_Final_GUI_Infix() {
if(e.getSource== evaluate expression);
outputArea.setText("");
public void actionPerformed(ActionEvent e) {
String e= String inputArea.getText();
outputappend(probInfix(expression));
}else {
throw new UnsupportedOperationException("Not supported yet.");
//To change body of
//generated methods, choose Tools | Templates.
}
}
setEvaluate(new JButton("Evaluate"));
getEvaluate().addActionListener((ActionListener) this);
//input Area
Panel expression= new Panel();
expression.add(getInfixLabel());
expression.add(inputArea);
//results area
Panel resultsPanel = new Panel();
resultsPanel.add(resultLabel);
resultsPanel.add(outputArea);
}*/
}
public static void openGUI();
JFrame= new JFrame("Infix Expression Evaluator");
JFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);
//JFrame.add(new proj1_Final_GUI());
JFrame.setLocationRelativeTo(null);
JFrame.pack();
//frame.setSize(200, 100);
JFrame.setVisible(true);
JFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
OpenGUI()
}End
@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public class InfixProj1 {
@SuppressWarnings({"rawtypes", "unchecked"})
public String Infix(String express) {
StringTokenizer tokens = new StringTokenizer(express, operator, true);
while (tokens.hasMoreTokens()) {
String tkn = tokens.nextToken();
if (operator.IndexOf(tokens) < 0);
Stack valueStack;
valueStack.push(tokens);
}if (operator.push(tokens));
//Resolve Operations
//java.util.Stack valueStack;
}else{
resolve(valueStack,operator);
}final
}
private void push(StringTokenizer tokens) {
// TODO Auto-generated method stub
}
public int getPriority(String op){
if (op.equals("(")|| op.equals(")")) {
return 0;
} else if(op.equals("*")|| op.equals("/")) {
return 2;
} else if(op.equals("=")) {
return 3;
}
return Integer.MIN_VALUE;
}
@SuppressWarnings("unchecked")
public void resolve(Stack Values,Stack operators){
while(operators.size()>=2){
String first=(String)operators.pop();
String second=(String)operators.pop();
if(getPriority(first) operators.push(second); operators.push(first); return; } else{ String firstValue=(String)Values.pop(); String secondValue=(String)Values.pop(); Values.push(getResults(secondValue,second,firstValue)); operators.push(first); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started