hello,
i'm making a small calculator program, and i want the display to look like this:
want.jpg
but i'm getting this:
getting.jpg
this is the code i am currently using for the task:
public void actionPerformed(ActionEvent e){
String currText = viewer.getText();
String text = enter.getText();
int len = currText.length();
enter.setText("");
doc.setParagraphAttributes(len,viewer.getText().length(),left,false);
viewer.setText(currText + "\n" + text + "\n");
currText = viewer.getText();
len = currText.length();
try{
text = ""+p.evaluate(text);
} catch (ParserException pe){
text = pe.toString();
}
viewer.setText(currText + text);
doc.setParagraphAttributes(currText.length(),viewer.getText().length(),right,false);
}
this action listener is registered with the textfield (fired by pressing enter) and is the only thing that can trigger it
p is a reference to a parser and does nothing to the format
left and right are instances of simpleattributeset with setalign to ALIGN_LEFT and ALIGN_RIGHT respectively
i cannot figure out how exactly i should fix this, and i could use advice
thanks