Java Mini Project
Java Mini Project
CALCULATOR
DONE BY
1. PREETHI SHREE B
2. PRINCY MAGDALINE
3. PRIYA DHARSHINI R K
4. RAGAVI C
PROBLEM STATEMENT:
To build a calculator using java fx controls and layouts.
JAVAFX:
JavaFX is a Java library and a GUI toolkit designed to
develop and facilitate Rich Internet applications, web
applications, and desktop applications.
CONTROLS AND LAYOUTS:
1.TEXT:
The text node is represented by the class named
Text, which belongs to the package
javafx.scene.text.This class contains several properties to
create text in JavaFX and modify its appearance.
Example:-
2) TEXTFIELD:
TextField class is a part of JavaFX package. It is
a component that allows the user to enter a line of
unformatted text, it does not allow multi-line input it
only allows the user to enter a single line of text.
Constructor of the TextField class :
• TextField(): creates a new TextField with empty text
content
• TextField(String s): creates a new TextField with a
initial text .
TILEPLANE:-
• In the JavaFX application, in order to
set TilePane as a layout, the TilePane
class is used.
• The TilePane layout allows us to
arrange the components in the same
sized tiles according to specified
boundries.
Syntax:
• javafx.scene.layout.TilePane class.
3)BUTTON:-
.4)SetOnAction():-
5)getText():-
You can retrieve the data using the from textField
getText() method.
Data_type variable=object of TextField.gettext();
6)GRIDPANE:-
7)setFont():-
2)SCENE:-
9) SET PADDING
Setpading sets the margin for the child when
contained by grid pane.
EG: buttonBox.setPadding(new Insets(20,0,0,0));
SOURCE CODE:
package
intelij;
\
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.property.*;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.*;
import javafx.stage.*;
import java.util.*;
@Override
public void start(Stage stage) {
TextField screen = createScreen();
TilePane buttons = createButtons();
stage.setTitle("Calc");
stage.initStyle(StageStyle.UTILITY);
stage.setResizable(false);
stage.setScene(new Scene(createLayout(screen, buttons)));
stage.show();
}
if (s.matches("[0-9]")) {
makeNumericButton(s, button);
} else {
final ObjectProperty<Op> triggerOp = determineOperand(s);
if (triggerOp.get() != Op.NOOP) {
makeOperandButton(button, triggerOp);
} else if ("c".equals(s)) {
makeClearButton(button);
} else if ("=".equals(s)) {
makeEqualsButton(button);
}
}
return button;
}