Java Reference
In-Depth Information
Figure 2-12. Restrictive focus cycle
The program in Listing 2-12 demonstrates the behavior illustrated in Figure 2-12. The
on-screen program will look just like Figure 2-11; it just behaves differently.
Listing 2-12. Restricting the Focus Cycle
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FocusCycleSample {
public static void main(String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame frame = new JFrame("Focus Cycle Sample");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.weightx = 1.0;
constraints.weighty = 1.0;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.fill = GridBagConstraints.BOTH;
 
Search WWH ::




Custom Search