Browsing all posts in javaku.

Removing All Elements

import java.util.ArrayList;
import java.util.List;
public class MainClass {
public static void main(String args[]) throws Exception {
List list = new ArrayList();
list.add(”A”);
list.add(”B”);
list.add(”C”);
list.clear();
System.out.println(list);
}
}
Related Websites How to Handle [...]

Using Internal Frame Dialogs with JDesktopPane

Here’s a simple example that shows how this works. It also shows how you can make sure your container fills the desktop, even if the desktop changes size (since there’s no layout manager, this won’t happen automatically).
// DialogDesktop.java
//
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
// A frame that can easily support internal frame dialogs
public class DialogDesktop extends JFrame [...]

Large Tables with Paging

Here’s the PagingModel code used to track the 10,000 records:
// PagingModel.java
// A larger table model that performs “paging” of its data. This model reports a
// small number of rows (e.g., 100 or so) as a “page” of data. You can switch pages
// to view all of the rows as needed using the pageDown( ) [...]

A Table with Row Headers

// RowHeaderTable.java
//
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class RowHeaderTable extends JFrame {
public RowHeaderTable( ) {
super(”Row Header Test”);
setSize(300, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
TableModel tm = new AbstractTableModel( ) {
String data[] = {””, “a”, “b”, “c”, “d”, “e”};
[...]