Adv Java - [Swing: JButton Class]

♠ Posted by Unknown in
Swing Button Classes Swing buttons provide features that are not found in the Button class defined by the AWT. For example, you can associate an icon with a Swing button. Swing buttons are subclasses of the AbstractButton class, which extends JComponent. AbstractButton contains many methods that allow you to control the behavior of buttons, check boxes, and radio button...

Adv Java - [Swing JTextField Class]

♠ Posted by Unknown in
JTextField Class The swing text field is encapsulated by the JTextComponent class, which extends JComponent. It provides functionality that is common to Swing text components. One of its subclass is JTextField, which allows you to edit one line of tex...

Adv Java - [Swing: ImageIcon/JLabel Classes]

♠ Posted by Unknown in
ImageIcon Class In Swing, icons are encapsulated by the ImageIcon class, which paints an icon from an image. Two of lists constructors are show here:      ImageIcon(String filename)      ImageIcon(URL url) The first form used the image in the file named “filename”. The second form used the image in the resource identified by “url”....

Adv Java - [Swing Layout Manager]

♠ Posted by Unknown in
Layout Managers The way that you place components on a form in Java is probably different from any other GUI system you’ve used. The way components are placed on a form is controlled not by absolute positioning but by a “Layout Manager” that decides how the components lie based on the order that you add() them. The size, shape, and placement of components will be remarkably different from one layout manager to another. In addition, the layout managers adapt to the dimensions of your applet or application window, so if the window dimension is changed, the size, shape, and placement of the components can change in response....

Adv Java - [Swing Fundamental]

♠ Posted by Unknown in
swing Swing is a set of classes that provides more powerful and flexible components than are possible with the AWT. In addition to the familiar components, such as buttons, check boxes, and labels, Swings supplies several exciting addition, including tabbed panes, scroll panes, trees, and tables. Even familiar components such as buttons have more capabilities in swing. For example, a button may have both an image and a text string associated with it. Also, the image can be changed as the state of the button changes....

Core Java - [Java File Handling]

♠ Posted by Unknown in
Java Stream Classes The java.io package a large number of stream classes that provide capabilities for processing all types of data. These classes may be categorized into two groups on the data type on which they operate....

Core Java - [AWT GridLayout [Frame] Example]

♠ Posted by Unknown in
GridLayout  Manager on Frame Example: import java.awt.*; import java.awt.event.*; class FindHighestExample extends Frame implements ActionListener {     Label lblFirst, lblSecond, lblThird, lblAnswer;     TextField tfFirst, tfSecond, tfThird;     Button btnCheck, btnClear, btnExit;     Panel p1, p2;     public FindHighestExample()     {         lblFirst = new Label("Enter First Value : ");         lblSecond = new Label("Enter Second Value : ");         lblThird =...

Core Java - [AWT CardLayout Manager]

♠ Posted by Unknown in
CardLayout The CardLayout manager arranges components in a queue of cards. You can only see one card at a time. To construct a CardLayout manager, simply use the constructor CardLayout(). Cards are usually placed in a container such as a panel. Components are placed into the card queue in the order in which they are added. To add a component in the CardLayout container, use the following method.                                    ...

Core Java - [AWT GridBag Layout Manager]

♠ Posted by Unknown in
GridBagLayout The GridBagLayout manager is the most flexible and most complex. The components can vary in size, however, and can be added in any order in GridBagLayout. The Constructor GridBagLayout() is used to create a new GridBagLayout.  In the GridLayout, the grid size (the number of rows and columns) is specified in the constructor. The size is unspecified, however, in the GridBagLayout. How a GridBagLayout places a set of components depends on each component's GridBagConstraints and minimum size, as well as the preferred size of the component's container. gridx and gridy : Specifies the cell at the upper left of the component's display area, where the upper left most cell has address gridx=0 and gridy=0. numrows and numcols: Specifies the number of cells ina row or column in the component's display area. the default value is 1. weightx and weighty: Specifies the extra space to allocate horizontally and vertically for the component in a row...

Core Java - [AWT BorderLayout Manager]

♠ Posted by Unknown in
BorderLayout The BorderLayout manager divides the window into five areas: East, South, West, North, and Center. Components are added to a BorderLayout by using add(String, Component). You can use one of the following two constructors to create a new BorderLayout.                                     public BorderLayout(int hGap, int vGap) This constructs a new BorderLayout with the specified horizontal and vertical...

Core Java - [AWT GridLayout Manager]

♠ Posted by Unknown in
GridLayout The GridLayout manager arranges components in a grid(matrix) formation with the number of rows and columns defined by the constructor. The components are placed in the grid from left to right starting with the first row, then the second, and so on, in the order in which they are added. The GridLayout manager has two constructors:                                     public GridLayout(int rows, int...

Core Java - [AWT FlowLayout Manager]

♠ Posted by Unknown in
FlowLayout FlowLayout is the simplest layout manager. The components are arranged in the container from left to right in the order in which they were added. When one row becomes filled, a new row is started. You can specify the way the components are aligned by using one of three constants:                    FlowLayout.RIGHT                   FlowLayout.CENTER                   FlowLayout.LEFT you can also specify the gap between components...

Core Java - [Java LayoutManagers]

♠ Posted by Unknown in
Java Layout Managers The AWT components are placed in containers. Each container has a layout manager to arrange the AWT components within the container. Java knows where to place button because the layout manager works behind the scenes to place the components in the correct locations. The AWT provides five layout managers:  FlowLayout  GridLayout GridBagLayout BorderLayout CardLayout  These classes implement the LayoutManager interface. The layout managers are defined by implementing the LayoutManager interface. The LayoutManager interface defines the common methods that each layout manager uses to arrange components. The common methods are add() and remove(). Use the add() method to add a component to the container and the remove() method to remove a component from the container...

Core Java - [Java Menu]

♠ Posted by Unknown in
Create Menu in Java Menu makes selection easier, and are widely used in window applications. In Java, menus can only appear on a frame. Java provides three classes - MenBar, Menu, and MenuItem - to implements menus in frame. A frame can hold a menu bar to which the pull-down menus are attached. Menu Consist of menu items that the user can select. 1. To create a Menu bar and associate it with frame. Frame f = new Frame(); f.setsize(300,300); f.setVisible(true); MenuBar mb = new MenuBar(); f.setMenuBar(mb); 2. To Create Menus.                          public Menu(String label, boolean tearOff); In above constructor the "true" tearOff enables the programmer to create a menu that desplays even when the mouse button is released.             public Menu(String label); This constructs a new menu instance with...