d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Someone To Debug My Java Code > Written In Javafx
Prev12
Add Reply New Topic New Poll
Member
Posts: 619
Joined: Jan 30 2006
Gold: 99.52
Nov 28 2018 06:32pm
You are defining a TextField in the createScreen- Function but you never actually print anything on there. All you do is push the values onto a stack.

There is a lot of things wrong with this code, but to get you a step forward:

Define the TextField as a class field like this:

Code
// Stack
private Stack<String> stackValue = new Stack<>();
// Current value entered
private double valueHolderCurrent = 0;
// Current value on stack
private double valueHolderOnStack = 0;
// Values added
private double valuesAdded = 0;

private TextField screen;


Assign the screen field to the TextField you create in the createScreen-Function:

Code
private TextField createScreen() {
screen = new TextField();
screen.setStyle("-fx-background-color: silver;");
screen.setAlignment(Pos.CENTER_RIGHT);
screen.setEditable(false);
new ReadOnlyObjectWrapper<>("");
return screen;
}


This is the point where you code confuses me, but i dont want to take away too much of your learning process.

So to now fill the field with the number, you have to use this:

Code
screen.setText(number);


This should be done in the ActionEvent of the Buttons.

This is by no means good practice, but should guide you in the right direction of what you need to do.
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll