home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 November
/
Chip_1998-11_cd.bin
/
tema
/
Cafe
/
jfc.bin
/
MotifFileChooserUI.java
< prev
next >
Wrap
Text File
|
1998-02-26
|
7KB
|
198 lines
/*
* @(#)MotifFileChooserUI.java 1.6 98/02/03
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
package com.sun.java.swing.plaf.motif;
import com.sun.java.swing.*;
import com.sun.java.swing.preview.*;
import com.sun.java.swing.preview.JDirectoryPane;
import com.sun.java.swing.event.*;
import com.sun.java.swing.plaf.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.io.File;
import java.util.*;
/**
* Motif FileChooserUI.
*
* @version 1.6 02/03/98
* @author Jeff Dinkins
*/
public class MotifFileChooserUI extends FileChooserUI {
protected Action okayAction = new OkayAction();
protected Action cancelAction = new CancelAction();
protected Action updateAction = new UpdateAction();
protected JButton okayButton;
protected JButton cancelButton;
protected JButton updateButton;
protected JButton helpButton;
protected JFileChooser fileChooser;
protected JDirectoryPane directoryPane;
protected Component accessory;
private static Dimension PREF_SIZE = new Dimension(350, 450);
private static Dimension MIN_SIZE = new Dimension(200, 300);
private static final Dimension hstrut10 = new Dimension(10, 1);
private static final Dimension vstrut10 = new Dimension(1, 10);
private static final Insets buttonMargin = new Insets(3, 3, 3, 3);
protected JPanel centerPanel;
//
// ComponentUI Interface Implementation methods
//
public static ComponentUI createUI(JComponent c) {
return new MotifFileChooserUI((JFileChooser)c);
}
public MotifFileChooserUI(JFileChooser b) {
}
public void installUI(JComponent c) {
fileChooser = (JFileChooser) c;
directoryPane = fileChooser.getDirectoryPane();
accessory = fileChooser.getAccessory();
fileChooser.setLayout(new BoxLayout(fileChooser, BoxLayout.Y_AXIS));
fileChooser.add(Box.createRigidArea(vstrut10));
// Add the directory pane
centerPanel = new JPanel(new BorderLayout());
centerPanel.add(directoryPane, BorderLayout.CENTER);
if(accessory != null) {
centerPanel.add(accessory, BorderLayout.EAST);
}
fileChooser.add(centerPanel);
fileChooser.add(Box.createRigidArea(vstrut10));
fileChooser.add(new JSeparator());
fileChooser.add(Box.createRigidArea(vstrut10));
// Add buttons
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
buttonPanel.add(Box.createGlue());
okayButton = (JButton) buttonPanel.add(new JButton("OK"));
okayButton.setMargin(buttonMargin);
buttonPanel.add(Box.createGlue());
okayButton.addActionListener(okayAction);
updateButton = (JButton) buttonPanel.add(new JButton("Update"));
updateButton.setMargin(buttonMargin);
updateButton.addActionListener(updateAction);
updateButton.setEnabled(false);
buttonPanel.add(Box.createGlue());
cancelButton = (JButton) buttonPanel.add(new JButton("Cancel"));
cancelButton.setMargin(buttonMargin);
cancelButton.addActionListener(cancelAction);
buttonPanel.add(Box.createGlue());
helpButton = (JButton) buttonPanel.add(new JButton("Help"));
helpButton.setMargin(buttonMargin);
helpButton.setEnabled(false);
buttonPanel.add(Box.createGlue());
fileChooser.add(buttonPanel);
fileChooser.add(Box.createRigidArea(vstrut10));
}
public void uninstallUI(JComponent c) {
if(c != fileChooser) {
throw new IllegalComponentStateException(this + " was asked to deinstall() "
+ c + " when it only knows about " + fileChooser + ".");
}
centerPanel = null;
directoryPane = null;
fileChooser = null;
accessory = null;
fileChooser.removeAll();
fileChooser = null;
}
public Dimension getPreferredSize(JComponent x) {
return PREF_SIZE;
}
public Dimension getMinimumSize(JComponent x) {
return MIN_SIZE;
}
public Dimension getMaximumSize(JComponent x) {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
/**
* Action when user cancels.
* <p>
* Warning: serialized objects of this class will not be compatible with
* future swing releases. The current serialization support is appropriate
* for short term storage or RMI between Swing1.0 applications. It will
* not be possible to load serialized Swing1.0 objects with future releases
* of Swing. The JDK1.2 release of Swing will be the compatibility
* baseline for the serialized form of Swing objects.
*/
protected class CancelAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
fileChooser.performCancel();
}
}
/**
* Action when user selects OK.
* <p>
* Warning: serialized objects of this class will not be compatible with
* future swing releases. The current serialization support is appropriate
* for short term storage or RMI between Swing1.0 applications. It will
* not be possible to load serialized Swing1.0 objects with future releases
* of Swing. The JDK1.2 release of Swing will be the compatibility
* baseline for the serialized form of Swing objects.
*/
protected class OkayAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
fileChooser.performOkay();
}
}
/**
* Action for update requests.
* <p>
* Warning: serialized objects of this class will not be compatible with
* future swing releases. The current serialization support is appropriate
* for short term storage or RMI between Swing1.0 applications. It will
* not be possible to load serialized Swing1.0 objects with future releases
* of Swing. The JDK1.2 release of Swing will be the compatibility
* baseline for the serialized form of Swing objects.
*/
protected class UpdateAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
}
}
}