A JAVA program to find Fibanocci/cuberoot/square root/palindrome/factorial/odd-even/prime
A JAVA program to find Fibanocci/cuberoot/square root/palindrome/factorial/odd-even/prime.
Packages used:
1. java.io.* : Provides for system input and output through data
streams, serialization and the file system.
2. javax.swing.* :
Provides a set of "lightweight" (all-Java language) components that,
to the maximum degree possible, work the same on all platforms.
3. java.awt.* :
Contains all of the classes for creating user interfaces and for painting
graphics and images.
4. java.awt.event.* : Provides interfaces and classes for dealing with
different types of events fired by AWT components
5. java.math.* :
Provides classes for performing arbitrary-precision integer arithmetic
(BigInteger) and arbitrary-precision decimal arithmetic
Classes
used:
·
JFrame : Provides classes for performing
arbitrary-precision integer arithmetic (BigInteger) and arbitrary-precision
decimal arithmetic
·
Container : A generic Abstract Window Toolkit(AWT)
container object is a component that can contain other AWT components.
Components added to a container are tracked in a list
·
JLabel : A display area for a short text string or an
image, or both
·
JButton : An implementation of a
"push" button.
·
JTextField
:
Logical
flow of the program: JTextField
is a
lightweight component that allows the editing of a single line of text.
·
A class
inheriting JFrame and implementing ActionListener is created.
·
Container
holds components like JLabel,JButton,JTextField.
·
According
to the button clicked corresponding action is performed.
·
Result of
the corresponding operation is displayed on the text field.
Important
notes:
·
In all
swing program the package that should be imported is “javax.swing.*”.
·
If in the
program JApplet is inherited then
the “init()” method is used to
initialize the applet.
·
If in the
program JFrame is inherited then the
inheriting class’s constructor initializes the swing application.
1.If super() method is called ,it should be the first
line inside the constructor.
2.Frame’s visibility and size must be set.
0 comments: