Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 

Swing Chapter 4. (The basics) Layout Managers. Easy for reading, Click here!

Custom Search
Swing Chapter 4. (The basics) Layout Managers. Easy for reading, Click here!

[ Return to Swing (Book) ]

Page: 7/7 



Previous Page Previous Page (6/7)
Subpages: 1. Layouts overview 
2. Comparing common layout managers
3.
Using GridBagLayout
4. Choosing the right layout
5. Custom layout manager: part I -Label/field pairs
6. Custom layout manager: part II - Common interfaces
7. Dynamic layout in a JavaBeans container

4.7    Dynamic layout in a JavaBeans container

In this section we will use different layouts to manage JavaBeans in a simple container application. This will help us to further understand the role of layouts in dynamically managing containers with a variable number of components. This example also sets up the framework for a powerful bean editor environment developed in chapter 18 using JTables. By allowing modification of component properties we can use this environment to experiment with preferred, maximum, and minimum sizes, and observe the behavior different layout managers exibit in various situations. This provides us with the ability to learn much more about each layout manager, and allows us to prototype simple interfaces without actually implementing them.

This example consists of a frame container that allows the creation, loading, and saving of JavaBeans using serialization. Beans can be added and removed from this container and we implement a focus mechanism to visually identify the currently selected bean. Most importantly, the layout manager of this container can be changed at run-time. (You may want to review the JavaBeans material in chapter 2 before attempting to work through this example.)

 

Figure 4.18 BeanContainer displaying 4 Clock components using a FlowLayout

<<file figure4-18.gif>>

Figure 4.19 BeanContainer displaying 4 Clock components using a GridLayout

<<file figure4-19.gif>>

Figure 4.20 BeanContainer displaying 4 Clock components using a horizontal BoxLayout

<<file figure4-20.gif>>

Figure 4.21 BeanContainer displaying 4 Clock components using a vertical BoxLayout

<<file figure4-21.gif>>

Figure 4.22 BeanContainer displaying 4 Clock components using a DialogLayout

<<file figure4-22.gif>>

Figure 4.23 BeanContainer displaying button/input field pairs using DialogLayout

<<file figure4-23.gif>>

Figure 4.24 BeanContainer displaying button/input field pairs using DialogLayout

<<file figure4-24.gif>>

The Code: BeanContainer.java

see \Chapter4\6

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.beans.*;

import java.lang.reflect.*;

import javax.swing.*;

import dl.*;

public class BeanContainer extends JFrame implements FocusListener

{

  protected File m_currentDir = new File(".");

  protected Component m_activeBean;

  protected String m_className = "clock.Clock";

  protected JFileChooser m_chooser = new JFileChooser();

  public BeanContainer() {

    super("Simple Bean Container");

    getContentPane().setLayout(new FlowLayout());

    setSize(300, 300);

    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    JMenuBar menuBar = createMenuBar();

    setJMenuBar(menuBar);

    WindowListener wndCloser = new WindowAdapter() {

      public void windowClosing(WindowEvent e) {

        System.exit(0);

      }

    };

    addWindowListener(wndCloser);

    setVisible(true);

  }

  protected JMenuBar createMenuBar() {

    JMenuBar menuBar = new JMenuBar();

    JMenu mFile = new JMenu("File");

    JMenuItem mItem = new JMenuItem("New...");

    ActionListener lst = new ActionListener() {

      public void actionPerformed(ActionEvent e) { 

        Thread newthread = new Thread() {

          public void run() {

            String result = (String)JOptionPane.showInputDialog(

              BeanContainer.this,

              "Please enter class name to create a new bean",

              "Input", JOptionPane.INFORMATION_MESSAGE, null,

              null, m_className);

            repaint();

            if (result==null)

              return;

            try {

              m_className = result;

              Class cls = Class.forName(result);

              Object obj = cls.newInstance();

              if (obj instanceof Component) {

                m_activeBean = (Component)obj;

                m_activeBean.addFocusListener(

                  BeanContainer.this);

                m_activeBean.requestFocus();

                getContentPane().add(m_activeBean);

              }

              validate();

            }

            catch (Exception ex) {

              ex.printStackTrace();

              JOptionPane.showMessageDialog(

                BeanContainer.this, "Error: "+ex.toString(),

                "Warning", JOptionPane.WARNING_MESSAGE);

            }

          }

        };

        newthread.start();

      }

    };

    mItem.addActionListener(lst);

    mFile.add(mItem);

    mItem = new JMenuItem("Load...");

    lst = new ActionListener() {

      public void actionPerformed(ActionEvent e) { 

        Thread newthread = new Thread() {

          public void run() {

            m_chooser.setCurrentDirectory(m_currentDir);

            m_chooser.setDialogTitle(

              "Please select file with serialized bean");

            int result = m_chooser.showOpenDialog(

              BeanContainer.this);

            repaint();

            if (result != JFileChooser.APPROVE_OPTION)

              return;

            m_currentDir = m_chooser.getCurrentDirectory();

            File fChoosen = m_chooser.getSelectedFile();

            try {

              FileInputStream fStream =

                new FileInputStream(fChoosen);

              ObjectInput  stream  = 

                new ObjectInputStream(fStream);

              Object obj = stream.readObject();

              if (obj instanceof Component) {

                m_activeBean = (Component)obj;

                m_activeBean.addFocusListener(

                  BeanContainer.this);

                m_activeBean.requestFocus();

                getContentPane().add(m_activeBean);

              }

              stream.close();

              fStream.close();

              validate();

            }

            catch (Exception ex) {

              ex.printStackTrace();

              JOptionPane.showMessageDialog(

                BeanContainer.this, "Error: "+ex.toString(),

                "Warning", JOptionPane.WARNING_MESSAGE);

            }

            repaint();

          }

        };

        newthread.start();

      }

    };

    mItem.addActionListener(lst);

    mFile.add(mItem);

    mItem = new JMenuItem("Save...");

    lst = new ActionListener() {

      public void actionPerformed(ActionEvent e) {

        Thread newthread = new Thread() {

          public void run() {

            if (m_activeBean == null)

              return;

            m_chooser.setDialogTitle(

              "Please choose file to serialize bean");

            m_chooser.setCurrentDirectory(m_currentDir);

            int result = m_chooser.showSaveDialog(

              BeanContainer.this);

            repaint();

            if (result != JFileChooser.APPROVE_OPTION)

              return;

            m_currentDir = m_chooser.getCurrentDirectory();

            File fChoosen = m_chooser.getSelectedFile();

            try {

              FileOutputStream fStream =

                new FileOutputStream(fChoosen);

              ObjectOutput stream  = 

                new ObjectOutputStream(fStream);

              stream.writeObject(m_activeBean);

              stream.close();

              fStream.close();

            }

            catch (Exception ex) {

              ex.printStackTrace();

            JOptionPane.showMessageDialog(

              BeanContainer.this, "Error: "+ex.toString(),

              "Warning", JOptionPane.WARNING_MESSAGE);

            }

          }

        };

        newthread.start();

      }

    };

    mItem.addActionListener(lst);

    mFile.add(mItem);

    mFile.addSeparator();

    mItem = new JMenuItem("Exit");

    lst = new ActionListener() {

      public void actionPerformed(ActionEvent e) {

        System.exit(0);

      }

    };

    mItem.addActionListener(lst);

    mFile.add(mItem);

    menuBar.add(mFile);

    JMenu mEdit = new JMenu("Edit");

    mItem = new JMenuItem("Delete");

    lst = new ActionListener() {

      public void actionPerformed(ActionEvent e) {

        if (m_activeBean == null)

          return;

        getContentPane().remove(m_activeBean);

        m_activeBean = null;

        validate();

        repaint();

      }

    };

    mItem.addActionListener(lst);

    mEdit.add(mItem);

    menuBar.add(mEdit);

    JMenu mLayout = new JMenu("Layout");

    ButtonGroup group = new ButtonGroup();

    mItem = new JRadioButtonMenuItem("FlowLayout");

    mItem.setSelected(true);

    lst = new ActionListener() {

      public void actionPerformed(ActionEvent e){

        getContentPane().setLayout(new FlowLayout());

        validate();

        repaint();

      }

    };

    mItem.addActionListener(lst);

    group.add(mItem);

    mLayout.add(mItem);

    mItem = new JRadioButtonMenuItem("GridLayout");

    lst = new ActionListener() {

      public void actionPerformed(ActionEvent e){

        int col = 3;

        int row = (int)Math.ceil(getContentPane().

          getComponentCount()/(double)col);

        getContentPane().setLayout(new GridLayout(row, col, 10, 10));

        validate();

        repaint();

      }

    };

    mItem.addActionListener(lst);

    group.add(mItem);

    mLayout.add(mItem);

    mItem = new JRadioButtonMenuItem("BoxLayout - X");

    lst = new ActionListener() {

      public void actionPerformed(ActionEvent e) {

        getContentPane().setLayout(new BoxLayout(

          getContentPane(), BoxLayout.X_AXIS));

        validate();

        repaint();

      }

    };

    mItem.addActionListener(lst);

    group.add(mItem);

    mLayout.add(mItem);

    mItem = new JRadioButtonMenuItem("BoxLayout - Y");

    lst = new ActionListener() {

      public void actionPerformed(ActionEvent e) {

        getContentPane().setLayout(new BoxLayout(

          getContentPane(), BoxLayout.Y_AXIS));

        validate();

        repaint();

      }

    };

    mItem.addActionListener(lst);

    group.add(mItem);

    mLayout.add(mItem);

    mItem = new JRadioButtonMenuItem("DialogLayout");

    lst = new ActionListener() {

      public void actionPerformed(ActionEvent e) {

        getContentPane().setLayout(new DialogLayout());

        validate();

        repaint();

      }

    };

    mItem.addActionListener(lst);

    group.add(mItem);

    mLayout.add(mItem);

    menuBar.add(mLayout);

    return menuBar;

  }

  public void focusGained(FocusEvent e) {

    m_activeBean = e.getComponent();

    repaint();

  }

  public void focusLost(FocusEvent e) {}

  // This is a heavyweight component so we override paint

  // instead of paintComponent. super.paint(g) will

  // paint all child components first, and then we

  // simply draw over top of them.

  public void paint(Graphics g) {

    super.paint(g);

    if (m_activeBean == null)

      return;

    Point pt = getLocationOnScreen();

    Point pt1 = m_activeBean.getLocationOnScreen();

    int x = pt1.x - pt.x - 2;

    int y = pt1.y - pt.y - 2;

    int w = m_activeBean.getWidth() + 2;

    int h = m_activeBean.getHeight() + 2;

    g.setColor(Color.black);

    g.drawRect(x, y, w, h);

  }

  public static void main(String argv[]) {

    new BeanContainer();

  }

}

The Code: Clock.java

see \Chapter4\6\clock

package clock;

import java.applet.*;

import java.awt.*;

import java.awt.event.*;

import java.beans.*;

import java.io.*;

import java.util.*;

import javax.swing.*;

import javax.swing.border.*;

public class Clock extends JButton

 implements Customizer, Externalizable, Runnable

{

  protected PropertyChangeSupport m_helper;

  protected boolean  m_digital = false;

  protected Calendar m_calendar;

  protected Dimension m_preffSize;

  public Clock() {

    m_calendar = Calendar.getInstance();

    m_helper = new PropertyChangeSupport(this);

    Border br1 = new EtchedBorder(EtchedBorder.RAISED,

      Color.white, new Color(128, 0, 0));

    Border br2 = new MatteBorder(4, 4, 4, 4, Color.red);

    setBorder(new CompoundBorder(br1, br2));

    setBackground(Color.white);

    setForeground(Color.black);

    (new Thread(this)).start();

  }

  public void writeExternal(ObjectOutput out) throws IOException {

    out.writeBoolean(m_digital);

    out.writeObject(getBackground());

    out.writeObject(getForeground());

    out.writeObject(getPreferredSize());

  }

  public void readExternal(ObjectInput in)

   throws IOException, ClassNotFoundException {

    setDigital(in.readBoolean());

    setBackground((Color)in.readObject());

    setForeground((Color)in.readObject());

    setPreferredSize((Dimension)in.readObject());

  }

  public Dimension getPreferredSize() {

    if (m_preffSize != null)

      return m_preffSize;

    else

      return new Dimension(50, 50);

  }

  public void setPreferredSize(Dimension preffSize) {

    m_preffSize = preffSize;

  }

  public Dimension getMinimumSize() {

    return getPreferredSize();

  }

  public Dimension getMaximumSize() {

    return getPreferredSize();

  }

  public void setDigital(boolean digital) {

    m_helper.firePropertyChange("digital",

      new Boolean(m_digital),

      new Boolean(digital));

    m_digital = digital;

    repaint();

  }

  public boolean getDigital() { return m_digital; }

  public void addPropertyChangeListener(

   PropertyChangeListener lst) {

    if (m_helper != null)

      m_helper.addPropertyChangeListener(lst);

  }

  public void removePropertyChangeListener(

   PropertyChangeListener lst) {

    if (m_helper != null)

      m_helper.removePropertyChangeListener(lst);

  }

  public void setObject(Object bean) {}

  public void paintComponent(Graphics g) {

    super.paintComponent(g);

    g.setColor(getBackground());

    g.fillRect(0, 0, getWidth(), getHeight());

    getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());

    m_calendar.setTime(new Date());  // get current time

    int hrs = m_calendar.get(Calendar.HOUR_OF_DAY);

    int min = m_calendar.get(Calendar.MINUTE);

    g.setColor(getForeground());

    if (m_digital) {

      String time = ""+hrs+":"+min;

      g.setFont(getFont());

      FontMetrics fm = g.getFontMetrics();

      int y = (getHeight() + fm.getAscent())/2;

      int x = (getWidth() - fm.stringWidth(time))/2;

      g.drawString(time, x, y);

    }

    else {

      int x = getWidth()/2;

      int y = getHeight()/2;

      int rh = getHeight()/4;

      int rm = getHeight()/3;

      double ah = ((double)hrs+min/60.0)/6.0*Math.PI;

      double am = min/30.0*Math.PI;

      g.drawLine(x, y, (int)(x+rh*Math.sin(ah)),

        (int)(y-rh*Math.cos(ah)));

      g.drawLine(x, y, (int)(x+rm*Math.sin(am)),

        (int)(y-rm*Math.cos(am)));

    }

    g.setColor(colorRetainer);

  }

  public void run() {

    while (true) {

      repaint();

      try {

        Thread.sleep(30*1000);

      }

      catch(InterruptedException ex) { break; }

    }

  }

}

Understanding the Code

Class BeanContainer

This class extends JFrame to provide the frame for this application. It also implements the FocusListener interface to manage focus transfer between beans in the container. This class declares four instance variables:

File m_currentDir: the most recent directory used to load and save beans.

Component m_activeBean: a bean component which currently has the focus.

String m_className: fully qualified class name of our custom Clock bean,

JFileChooser m_chooser: used for saving and loading beans.

The only GUI provided by the container itself is the menu bar. The createMenuBar() method creates the menu bar, its items, and their corresponding action listeners. Three menus are added to the menu bar: "File," "Edit," and "Layout."

Note: All code corresponding to "New...," "Load..., and "Save..." in the "File" menu is wrapped in a separate thread to avoid unnecesary load on the event-dispatching thread. See chapter 2 for more about multithreading.

Menu item "New..." in the "File" menu displays an input dialog (using the JOptionPane.showInputDialog() method) to enter the class name of a new bean to be added to the container. Once a name has been entered, the program attempts to load that class, create a new class instance using a default constructor, and add that new object to the container. The newly created component requests the focus and receives a this reference to BeanContainer as a FocusListener. Note that any caught exceptions will be displayed in a message box.

Menu item "Load..." from the "File" menu displays a JFileChooser dialog to select a file containing a previously serialized bean component. If this succeeds, the program opens an input stream on this file and reads the first stored object. If this object is derived from the java.awt.Component class it is added to the container. The loaded component requests the focus and receives a this reference to BeanContainer as a FocusListener. Note that any caught exceptions will be displayed in a message box.

Menu item "Save..." from the "File" menu displays a JFileChooser dialog to select a file destination for serializing the bean component which currently has the focus. If this succeeds, the program opens an output stream on that file and writes the currently active component to that stream. Note that any caught exceptions will be displayed in a message box.

Menu item "Exit" simply quits and closes the application with System.exit(0).

The "Edit" menu contains a single item titled "Delete" which removes the currently active bean from the container:

      getContentPane().remove(m_activeBean);

      m_activeBean = null;

      validate();

      repaint();

Menu "Layout" contains several JRadioButtonMenuItems managed with a ButtonGroup group. These items are titled "FlowLayout," "GridLayout," "BoxLayout - X," "BoxLayout - Y," and "DialogLayout." Each item receives an ActionListener which sets the corresponding layout manager of the application frame's content pane, calls validate to lay out the container again, and the repaints it. For example:

      getContentPane().setLayout(new DialogLayout());

      validate();

      repaint();

Method focusGained stores a reference to the component which currently has the focus into instance variable m_activebean. Method paint() is implemented to draw a rectangle around the component which currently has the focus. It is important to note here the static JPopupMenu method called in the BeanContainer constructor:

      JPopupMenu.setDefaultLightWeightPopupEnabled(false);

This method forces all popup menus (which menu bars use to display their contents) to use heavyweight popups rather than lightweight popups. By default popup menus are lightweight unless they cannot fit within their parent container's bounds. The reason we disable this is because our paint() method will render the bean selection rectangle over top of the lightweight popups otherwise.

Class Clock

This class is a sample bean clock component which can be used in a bean container just as any other bean. This class extends the JButton component to inherit it's focus grabbing functionality. This class also implements three interfaces: Customizer to handle property listeners, Externalizable to completely manage its own serialization, and Runnable to be run by a thread. Four instance variables are declared:

PropertyChangeSupport m_helper: an object to manage PropertyChangeListeners.

boolean m_digital: a custom property for this component which manages the display state of the clock (digital or arrow-based).

Calendar m_calendar: helper object to handle Java's time objects (instances of Date).

Dimension m_preffSize: a preferred size for this component which may be set using the setPreferredSize method.

The constructor of the Clock class creates the helper objects and sets the border for this component as a CompoundBorder containing an EtchedBorder and a MatteBorder imitating the border of a real clock. It then sets the background and foreground colors and starts a new Thread to run the clock.

Method writeExternal() writes the current state of a Clock object into an ObjectOutput stream. Four properties are written: m_digital, Background, Foreground, and PreferredSize. Method readExternal() reads the previously saved state of a Clock object from an ObjectInput stream. It reads these four properties and applies them to the object previously created with the default constructor. These methods are called from the "Save" and "Load" menu bar action listener code in BeanContainer. Specifically, they are called when writeObject and readObject are invoked.

Note: The serialization mechanism in Swing has not yet matured. You can easily find that both lightweight and heavyweight components throw exceptions during the process of serialization. This is the reason we implement the Externalizable interface to take complete control over the serialization of the Clock bean. Another reason is that the default serialization mechanism tends to serialize a substantial amount of unnecessary information, whereas our custom implementation stores only the necessities.

The rest of this class need not be explained here, as it does not relate directly to the topic of this chapter and represents a simple example of a bean component. If you're interested, take note of the paintComponent() method which, depending on whether the clock is in digital mode or not (determined by m_digital), either computes the current position of the clock's arrows and draws them, or renders the time as a drawn String.

Running the Code

This application provides a framework for experimenting with any available JavaBeans, as well as with both lightweight (Swing) and heavyweight (AWT) components: we can create, serialize, delete, and restore them.

Note that we can apply several layouts to manage these components dynamically. Figures 4.18-4.23 show BeanContainer using five different layout managers to arrange four Clock beans. To create a bean choose "New" from the "File" menu and type the fully qualifies name of the class. For instance, to create a Clock you need to type "clock.Clock" in the input dialog.

Once you've experimented with Clock beans try loading some Swing JavaBeans. Figure 4.24 shows BeanDialog with two JButtons, and two JTextFields. They were created in the following order (and thus have corresponding container indices): JButton, JTextField, JButton, JTextField. Try doing this and remember that you need to specify fully qualified class names such as "javax.swing.JButton" when adding a new bean. Note that this ordering adhere's to our DialogLayout label/input field pairs scheme, except that here we are using buttons in place of labels. So when we set BeanContainer's layout to DialogLayout we know what to expect.

Note: You will notice selection problems with components such as JComboBox, JSplitPane and JLabel (which has no selection mechanism). Because of JComboBox is actually a container containing a button, it is impossible to give it the current focus after it has been added to BeanContainer. A more complete version of BeanContainer would take this into account and implement more robust focus requesting behavior.

Later in this book, after a discussion of tables, we add powerful functionality to this example allowing the manipulation of bean properties. It is highly suggested that you skip ahead for a moment and run this example: (see \Chapter18\8).

Start the chapter 18 example and create JButton and JTextField beans exactly as you did above. Select DialogLayout from the "Layout" menu and then click on the top-most JButton to give it the focus. Now select "Properties" from the "Edit" menu. A separate frame will pop up with a JTable containing all of the JButton's properties. Navigate to the "label" property and change it to "Button 1" (by double clicking on its "Value" field). Now select the corresponding top-most JTextField and change its "preferredSize" property to "4,40". Figure 4.24 illustrates what you should see.

By changing the preferred, maximum, and minimum sizes, as well as other component properties, we can directly examine the behavior different layout managers impose on our container. Experimenting with this example is a very convenient way to learn more about how the layout managers behave. It also forms the foundation for an interface development environment (IDE), which many developers use to simplify interface design.



[ Return to Swing (Book) ]


Top 10 read Java Articles
 Get free "1000 Java Tips eBook"

 Java Calendar and Date: good to know facts and code examples

 Array vs ArrayList vs LinkedList vs Vector: an excellent overview and examples

 How can I convert any Java Object into byte array? And byte array to file object

 The Java Lesson 1: What is Java?

 How do I compare two dates and times, date between dates, time between times and

 Maven vs Ant or Ant vs Maven?

 How to open, read, write, close file(s) in Java? Examples on move, rename and de

 Java Array

 Java: JLabel font and color


[ More in News Section ]
Java Lessons

The Java Lesson 1:
What is Java?
The Java Lesson 2:
Anatomy of a simple Java program
The Java Lesson 3:
Identifiers and primitive data types
The Java Lesson 4:
Variables, constants, and literals
The Java Lesson 5:
Arithmetic operations, conversions, and casts
The Java Lesson 6:
Boolean expressions and operations
The Java Lesson 7:
Bitwise operations
The Java Lesson 8:
Flow control with if and else
The Java Lesson 9:
switch statements
The Java Lesson 10:
for, while, and do-while statements
The Java Lesson 11:
Using break and continue
The Java Lesson 12:
Class methods and how they are called
The Java Lesson 13:
Using the Math class
The Java Lesson 14:
Creating and calling custom class methods
The Java Lesson 15:
Overloading class methods
The Java Lesson 16:
An introduction to objects and object references
The Java Lesson 17:
The String class
The Java Lesson 18:
The StringBuffer class
The Java Lesson 19:
Initializing and processing arrays of primitives
The Java Lesson 20:
Initializing and processing arrays of objects
The Java Lesson 23:
Inheritance and overriding inherited methods
The Java Lesson 24:
abstract classes and polymorphism
The Java Lesson 25:
Interfaces, instanceof, and object conversion and casting
The Java Lesson 26:
Introduction to graphical programming and the java.awt packa
The Java Lesson 27:
The Component class
The Java Lesson 28:
Containers and simple layout managers
The Java Lesson 29:
The Color and Font classes
The Java Lesson 30:
Drawing geometric shapes
The Java Lesson 31:
Choice, List, and Checkbox controls
The Java Lesson 32:
Using the Scrollbar graphical control
The Java Lesson 33:
Menus and submenus
The Java Lesson 34:
An introduction to applets and the Applet class
The Java Lesson 35:
Essential HTML to launch an applet and pass it parameters
The Java Lesson 36:
Mouse event processing
Java Lesson 37:
Menus and submenus
Java Lesson 38:
The WindowListener interface and the WindowAdapter class
Java Lesson 39:
An introduction to GridBagLayout
Java Lesson 40:
An introduction to the Java Collections API
Java Lesson 41:
Exception handling with try, catch, and finally blocks
Java Lesson 42:
Claiming and throwing exceptions
Java Lesson 43:
Multithreading, the Thread class, and the Runnable interface
Java Lesson 44:
An introduction to I/O and the File and FileDialog classes
Java Lesson 45:
Low-level and high-level stream classes
Java Lesson 46:
Using the RandomAccessFile class
Java Lessons by
Joh Huhtala: Update

Latest articles
 Java Profiler JProbe to Resolve Performance Problems Faster

 SSL with GlassFish v2, page 5

 SSL with GlassFish v2, page 4

 SSL with GlassFish v2, page 3

 SSL with GlassFish v2, page 2

 The Java Lesson 2: Anatomy of a simple Java program, page 2

 New site about Java for robots and robotics: both software and hardware.

 Exceptions -III: What's an exception and why do I care?

 Exceptions -II: What's an exception and why do I care?

 Exceptions: What's an exception and why do I care?

 Double your Java code quality in 10 minutes, here is receipt

 Murach's Java Servlets and JSP

 How to get ascii code from a char in Java?

 Can we just try without catch? Yes!

 Make Tomcat page load faster

 Make your Tomcat More secure - limit network address for certain IP addresses

 New Java book online starts now here...

 Implementing RESTful Web Services in Java

 Firefox trimming from 1 GB to 40 Mb with many tabs opened

 SSL with GlassFish v2

 My request to replublish Tech Tips

 Search JavaFAQ.nu site here

 New Advanced Installer for Java 6.0 brings XML updates and imports 3rd party MSI

 EJB programming restrictions

 Maven vs Ant or Ant vs Maven?

 Why Java does not use default value which it should?

 How to unsign signed bytes in Java - your guide is here

 The Java Lesson 3: Identifiers and primitive data types. Page 2

 The Java Lesson 7: Bitwise operations with good examples, click here! Page 4

 The Java Lesson 7: Bitwise operations with good examples, click here! Page 3


[ More in News Section ]


Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy