8077095: Fix missing doclint warnings in the javax.swing.plaf.basic package
Reviewed-by: serb
This commit is contained in:
parent
2ec458e126
commit
0b622e20f7
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -219,12 +219,14 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
|
||||
|
||||
/**
|
||||
* Obsolete - not used.
|
||||
* @param e list data event
|
||||
*/
|
||||
public void intervalAdded(ListDataEvent e) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Obsolete - not used.
|
||||
* @param e list data event
|
||||
*/
|
||||
public void intervalRemoved(ListDataEvent e) {
|
||||
}
|
||||
@ -238,7 +240,12 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
|
||||
ShellFolder.sort(v);
|
||||
}
|
||||
|
||||
// Obsolete - not used
|
||||
/**
|
||||
* Obsolete - not used
|
||||
* @return a comparison of the file names
|
||||
* @param a a file
|
||||
* @param b another file
|
||||
*/
|
||||
protected boolean lt(File a, File b) {
|
||||
// First ignore case when comparing
|
||||
int diff = a.getName().toLowerCase().compareTo(b.getName().toLowerCase());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -50,23 +50,39 @@ import sun.swing.SwingUtilities2;
|
||||
public class BasicFileChooserUI extends FileChooserUI {
|
||||
|
||||
/* FileView icons */
|
||||
/** Directory icon */
|
||||
protected Icon directoryIcon = null;
|
||||
/** File icon */
|
||||
protected Icon fileIcon = null;
|
||||
/** Computer icon */
|
||||
protected Icon computerIcon = null;
|
||||
/** Hard drive icon */
|
||||
protected Icon hardDriveIcon = null;
|
||||
/** Floppy drive icon */
|
||||
protected Icon floppyDriveIcon = null;
|
||||
|
||||
/** New folder icon */
|
||||
protected Icon newFolderIcon = null;
|
||||
/** Up folder icon */
|
||||
protected Icon upFolderIcon = null;
|
||||
/** Home folder icon */
|
||||
protected Icon homeFolderIcon = null;
|
||||
/** List view icon */
|
||||
protected Icon listViewIcon = null;
|
||||
/** Details view icon */
|
||||
protected Icon detailsViewIcon = null;
|
||||
/** View menu icon */
|
||||
protected Icon viewMenuIcon = null;
|
||||
|
||||
/** Save button mnemonic */
|
||||
protected int saveButtonMnemonic = 0;
|
||||
/** Open button mnemonic */
|
||||
protected int openButtonMnemonic = 0;
|
||||
/** Cancel button mnemonic */
|
||||
protected int cancelButtonMnemonic = 0;
|
||||
/** Update button mnemonic */
|
||||
protected int updateButtonMnemonic = 0;
|
||||
/** Help button mnemonic */
|
||||
protected int helpButtonMnemonic = 0;
|
||||
|
||||
/**
|
||||
@ -77,10 +93,15 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
*/
|
||||
protected int directoryOpenButtonMnemonic = 0;
|
||||
|
||||
/** Save button text */
|
||||
protected String saveButtonText = null;
|
||||
/** Open button text */
|
||||
protected String openButtonText = null;
|
||||
/** Cancel button text */
|
||||
protected String cancelButtonText = null;
|
||||
/** Update button text */
|
||||
protected String updateButtonText = null;
|
||||
/** Help button text */
|
||||
protected String helpButtonText = null;
|
||||
|
||||
/**
|
||||
@ -91,13 +112,20 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
*/
|
||||
protected String directoryOpenButtonText = null;
|
||||
|
||||
/** Open dialog title text */
|
||||
private String openDialogTitleText = null;
|
||||
/** Save dialog title text */
|
||||
private String saveDialogTitleText = null;
|
||||
|
||||
/** Save button tool tip text */
|
||||
protected String saveButtonToolTipText = null;
|
||||
/** Open button tool tip text */
|
||||
protected String openButtonToolTipText = null;
|
||||
/** Cancel button tool tip text */
|
||||
protected String cancelButtonToolTipText = null;
|
||||
/** Update button tool tip text */
|
||||
protected String updateButtonToolTipText = null;
|
||||
/** Help button tool tip text */
|
||||
protected String helpButtonToolTipText = null;
|
||||
|
||||
/**
|
||||
@ -158,9 +186,17 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
return new BasicFileChooserUI((JFileChooser) c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code BasicFileChooserUI}.
|
||||
* @param b file chooser
|
||||
*/
|
||||
public BasicFileChooserUI(JFileChooser b) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the UI.
|
||||
* @param c the component
|
||||
*/
|
||||
public void installUI(JComponent c) {
|
||||
accessoryPanel = new JPanel(new BorderLayout());
|
||||
filechooser = (JFileChooser) c;
|
||||
@ -175,6 +211,10 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
filechooser.applyComponentOrientation(filechooser.getComponentOrientation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the UI.
|
||||
* @param c the component
|
||||
*/
|
||||
public void uninstallUI(JComponent c) {
|
||||
uninstallListeners(filechooser);
|
||||
uninstallComponents(filechooser);
|
||||
@ -190,12 +230,24 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
handler = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the components.
|
||||
* @param fc the file chooser
|
||||
*/
|
||||
public void installComponents(JFileChooser fc) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the components.
|
||||
* @param fc the file chooser
|
||||
*/
|
||||
public void uninstallComponents(JFileChooser fc) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the listeners.
|
||||
* @param fc the file chooser
|
||||
*/
|
||||
protected void installListeners(JFileChooser fc) {
|
||||
propertyChangeListener = createPropertyChangeListener(fc);
|
||||
if(propertyChangeListener != null) {
|
||||
@ -241,6 +293,10 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Uninstalls the listeners.
|
||||
* @param fc the file chooser
|
||||
*/
|
||||
protected void uninstallListeners(JFileChooser fc) {
|
||||
if(propertyChangeListener != null) {
|
||||
fc.removePropertyChangeListener(propertyChangeListener);
|
||||
@ -252,6 +308,10 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Installs the defaults.
|
||||
* @param fc the file chooser
|
||||
*/
|
||||
protected void installDefaults(JFileChooser fc) {
|
||||
installIcons(fc);
|
||||
installStrings(fc);
|
||||
@ -264,6 +324,10 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
LookAndFeel.installProperty(fc, "opaque", Boolean.FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the icons.
|
||||
* @param fc the file chooser
|
||||
*/
|
||||
protected void installIcons(JFileChooser fc) {
|
||||
directoryIcon = UIManager.getIcon("FileView.directoryIcon");
|
||||
fileIcon = UIManager.getIcon("FileView.fileIcon");
|
||||
@ -279,6 +343,10 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
viewMenuIcon = UIManager.getIcon("FileChooser.viewMenuIcon");
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the strings.
|
||||
* @param fc the file chooser
|
||||
*/
|
||||
protected void installStrings(JFileChooser fc) {
|
||||
|
||||
Locale l = fc.getLocale();
|
||||
@ -315,6 +383,10 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
directoryOpenButtonToolTipText = UIManager.getString("FileChooser.directoryOpenButtonToolTipText",l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the defaults.
|
||||
* @param fc the file chooser
|
||||
*/
|
||||
protected void uninstallDefaults(JFileChooser fc) {
|
||||
uninstallIcons(fc);
|
||||
uninstallStrings(fc);
|
||||
@ -323,6 +395,10 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the icons.
|
||||
* @param fc the file chooser
|
||||
*/
|
||||
protected void uninstallIcons(JFileChooser fc) {
|
||||
directoryIcon = null;
|
||||
fileIcon = null;
|
||||
@ -338,6 +414,10 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
viewMenuIcon = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the strings.
|
||||
* @param fc the file chooser
|
||||
*/
|
||||
protected void uninstallStrings(JFileChooser fc) {
|
||||
saveButtonText = null;
|
||||
openButtonText = null;
|
||||
@ -354,6 +434,9 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
directoryOpenButtonToolTipText = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the model.
|
||||
*/
|
||||
protected void createModel() {
|
||||
if (model != null) {
|
||||
model.invalidateFileCache();
|
||||
@ -361,50 +444,102 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
model = new BasicDirectoryModel(getFileChooser());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the model.
|
||||
* @return the model
|
||||
*/
|
||||
public BasicDirectoryModel getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the property change listener.
|
||||
* @param fc the file chooser
|
||||
* @return the property change listener
|
||||
*/
|
||||
public PropertyChangeListener createPropertyChangeListener(JFileChooser fc) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file name.
|
||||
* @return the file name
|
||||
*/
|
||||
public String getFileName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the directory name.
|
||||
* @return the directory name
|
||||
*/
|
||||
public String getDirectoryName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file name.
|
||||
* @param filename the file name
|
||||
*/
|
||||
public void setFileName(String filename) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the directory name.
|
||||
* @param dirname the file name
|
||||
*/
|
||||
public void setDirectoryName(String dirname) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void rescanCurrentDirectory(JFileChooser fc) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void ensureFileIsVisible(JFileChooser fc, File f) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file chooser.
|
||||
* @return the file chooser
|
||||
*/
|
||||
public JFileChooser getFileChooser() {
|
||||
return filechooser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the accessory panel.
|
||||
* @return the accessory panel
|
||||
*/
|
||||
public JPanel getAccessoryPanel() {
|
||||
return accessoryPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the approve button.
|
||||
* @param fc the file chooser
|
||||
* @return the approve button
|
||||
*/
|
||||
protected JButton getApproveButton(JFileChooser fc) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public JButton getDefaultButton(JFileChooser fc) {
|
||||
return getApproveButton(fc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the approve button tool tip.
|
||||
* @param fc the file chooser
|
||||
* @return the approve button tool tip
|
||||
*/
|
||||
public String getApproveButtonToolTipText(JFileChooser fc) {
|
||||
String tooltipText = fc.getApproveButtonToolTipText();
|
||||
if(tooltipText != null) {
|
||||
@ -419,6 +554,9 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the icon cache.
|
||||
*/
|
||||
public void clearIconCache() {
|
||||
fileView.clearIconCache();
|
||||
}
|
||||
@ -435,11 +573,22 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
return handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a double click listener.
|
||||
* @param fc the file chooser
|
||||
* @param list the list
|
||||
* @return a double click listener
|
||||
*/
|
||||
protected MouseListener createDoubleClickListener(JFileChooser fc,
|
||||
JList<?> list) {
|
||||
return new Handler(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a list selection listener.
|
||||
* @param fc the file chooser
|
||||
* @return a list selection listener
|
||||
*/
|
||||
public ListSelectionListener createListSelectionListener(JFileChooser fc) {
|
||||
return getHandler();
|
||||
}
|
||||
@ -566,12 +715,19 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A double click listener.
|
||||
*/
|
||||
protected class DoubleClickListener extends MouseAdapter {
|
||||
// NOTE: This class exists only for backward compatibility. All
|
||||
// its functionality has been moved into Handler. If you need to add
|
||||
// new functionality add it to the Handler, but make sure this
|
||||
// class calls into the Handler.
|
||||
Handler handler;
|
||||
/**
|
||||
* Constucts a {@code DoubleClickListener}.
|
||||
* @param list the lsit
|
||||
*/
|
||||
public DoubleClickListener(JList<?> list) {
|
||||
handler = new Handler(list);
|
||||
}
|
||||
@ -587,16 +743,21 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
handler.mouseEntered(e);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
handler.mouseClicked(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A selection listener.
|
||||
*/
|
||||
protected class SelectionListener implements ListSelectionListener {
|
||||
// NOTE: This class exists only for backward compatibility. All
|
||||
// its functionality has been moved into Handler. If you need to add
|
||||
// new functionality add it to the Handler, but make sure this
|
||||
// class calls into the Handler.
|
||||
/** {@inheritDoc} */
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
getHandler().valueChanged(e);
|
||||
}
|
||||
@ -672,6 +833,8 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
|
||||
/**
|
||||
* Returns the title of this dialog
|
||||
* @param fc the file chooser
|
||||
* @return the title of this dialog
|
||||
*/
|
||||
public String getDialogTitle(JFileChooser fc) {
|
||||
String dialogTitle = fc.getDialogTitle();
|
||||
@ -686,7 +849,11 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the approve button mnemonic.
|
||||
* @param fc the file chooser
|
||||
* @return the approve button mnemonic
|
||||
*/
|
||||
public int getApproveButtonMnemonic(JFileChooser fc) {
|
||||
int mnemonic = fc.getApproveButtonMnemonic();
|
||||
if (mnemonic > 0) {
|
||||
@ -700,6 +867,7 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getApproveButtonText(JFileChooser fc) {
|
||||
String buttonText = fc.getApproveButtonText();
|
||||
if (buttonText != null) {
|
||||
@ -718,6 +886,10 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
// ***** Directory Actions *****
|
||||
// *****************************
|
||||
|
||||
/**
|
||||
* Returns a new folder action.
|
||||
* @return a new folder action
|
||||
*/
|
||||
public Action getNewFolderAction() {
|
||||
if (newFolderAction == null) {
|
||||
newFolderAction = new NewFolderAction();
|
||||
@ -730,22 +902,42 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
return newFolderAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a go home action.
|
||||
* @return a go home action
|
||||
*/
|
||||
public Action getGoHomeAction() {
|
||||
return goHomeAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a change to parent directory action.
|
||||
* @return a change to parent directory action
|
||||
*/
|
||||
public Action getChangeToParentDirectoryAction() {
|
||||
return changeToParentDirectoryAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an approve selection action.
|
||||
* @return an approve selection action
|
||||
*/
|
||||
public Action getApproveSelectionAction() {
|
||||
return approveSelectionAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cancel selection action.
|
||||
* @return a cancel selection action
|
||||
*/
|
||||
public Action getCancelSelectionAction() {
|
||||
return cancelSelectionAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an update action.
|
||||
* @return an update action
|
||||
*/
|
||||
public Action getUpdateAction() {
|
||||
return updateAction;
|
||||
}
|
||||
@ -756,9 +948,11 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
*/
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class NewFolderAction extends AbstractAction {
|
||||
/** Constructs a {@code NewFolderAction}. */
|
||||
protected NewFolderAction() {
|
||||
super(FilePane.ACTION_NEW_FOLDER);
|
||||
}
|
||||
/** {@inheritDoc} */
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (readOnly) {
|
||||
return;
|
||||
@ -799,6 +993,7 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
*/
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class GoHomeAction extends AbstractAction {
|
||||
/** Constructs a {@code GoHomeAction}. */
|
||||
protected GoHomeAction() {
|
||||
super("Go Home");
|
||||
}
|
||||
@ -808,12 +1003,17 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change to parent directory action.
|
||||
*/
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class ChangeToParentDirectoryAction extends AbstractAction {
|
||||
/** Constructs a {@code ChangeToParentDirectoryAction}. */
|
||||
protected ChangeToParentDirectoryAction() {
|
||||
super("Go Up");
|
||||
putValue(Action.ACTION_COMMAND_KEY, FilePane.ACTION_CHANGE_TO_PARENT_DIRECTORY);
|
||||
}
|
||||
/** {@inheritDoc} */
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
getFileChooser().changeToParentDirectory();
|
||||
}
|
||||
@ -824,9 +1024,11 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
*/
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class ApproveSelectionAction extends AbstractAction {
|
||||
/** Constructs an {@code ApproveSelectionAction}. */
|
||||
protected ApproveSelectionAction() {
|
||||
super(FilePane.ACTION_APPROVE_SELECTION);
|
||||
}
|
||||
/** {@inheritDoc} */
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (isDirectorySelected()) {
|
||||
File dir = getDirectory();
|
||||
@ -1133,6 +1335,7 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
*/
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class CancelSelectionAction extends AbstractAction {
|
||||
/** {@inheritDoc} */
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
getFileChooser().cancelSelection();
|
||||
}
|
||||
@ -1143,6 +1346,7 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
*/
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
protected class UpdateAction extends AbstractAction {
|
||||
/** {@inheritDoc} */
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser fc = getFileChooser();
|
||||
fc.setCurrentDirectory(fc.getFileSystemView().createFileObject(getDirectoryName()));
|
||||
@ -1188,15 +1392,27 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
// *****************************************
|
||||
// ***** default AcceptAll file filter *****
|
||||
// *****************************************
|
||||
/**
|
||||
* Accept all file filter.
|
||||
*/
|
||||
protected class AcceptAllFileFilter extends FileFilter {
|
||||
|
||||
/** Constructs an {@code AcceptAllFileFilter}. */
|
||||
public AcceptAllFileFilter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true.
|
||||
* @param f the file
|
||||
* @return true
|
||||
*/
|
||||
public boolean accept(File f) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getDescription() {
|
||||
return UIManager.getString("FileChooser.acceptAllFileFilterText");
|
||||
}
|
||||
@ -1206,18 +1422,26 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
// ***********************
|
||||
// * FileView operations *
|
||||
// ***********************
|
||||
/**
|
||||
* A basic file view.
|
||||
*/
|
||||
protected class BasicFileView extends FileView {
|
||||
/* FileView type descriptions */
|
||||
// PENDING(jeff) - pass in the icon cache size
|
||||
/** The icon cache */
|
||||
protected Hashtable<File,Icon> iconCache = new Hashtable<File,Icon>();
|
||||
|
||||
/** Constructs a {@code BasicFileView}. */
|
||||
public BasicFileView() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the icon cache.
|
||||
*/
|
||||
public void clearIconCache() {
|
||||
iconCache = new Hashtable<File,Icon>();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getName(File f) {
|
||||
// Note: Returns display name rather than file name
|
||||
String fileName = null;
|
||||
@ -1227,11 +1451,12 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getDescription(File f) {
|
||||
return f.getName();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getTypeDescription(File f) {
|
||||
String type = getFileChooser().getFileSystemView().getSystemTypeDescription(f);
|
||||
if (type == null) {
|
||||
@ -1244,10 +1469,20 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cached icon for the file.
|
||||
* @param f the file
|
||||
* @return the cached icon for the file
|
||||
*/
|
||||
public Icon getCachedIcon(File f) {
|
||||
return iconCache.get(f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches an icon for a file.
|
||||
* @param f the file
|
||||
* @param i the icon
|
||||
*/
|
||||
public void cacheIcon(File f, Icon i) {
|
||||
if(f == null || i == null) {
|
||||
return;
|
||||
@ -1255,6 +1490,7 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
iconCache.put(f, i);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Icon getIcon(File f) {
|
||||
Icon icon = getCachedIcon(f);
|
||||
if(icon != null) {
|
||||
@ -1278,6 +1514,11 @@ public class BasicFileChooserUI extends FileChooserUI {
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not a file is hidden.
|
||||
* @param f the file
|
||||
* @return whether or not a file is hidden
|
||||
*/
|
||||
public Boolean isHidden(File f) {
|
||||
String name = f.getName();
|
||||
if(name != null && name.charAt(0) == '.') {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -42,22 +42,31 @@ import sun.swing.UIAction;
|
||||
*/
|
||||
public class BasicInternalFrameUI extends InternalFrameUI
|
||||
{
|
||||
|
||||
/** frame */
|
||||
protected JInternalFrame frame;
|
||||
|
||||
private Handler handler;
|
||||
/** Border listener */
|
||||
protected MouseInputAdapter borderListener;
|
||||
/** Property change listener */
|
||||
protected PropertyChangeListener propertyChangeListener;
|
||||
/** Internal frame layout */
|
||||
protected LayoutManager internalFrameLayout;
|
||||
/** Component listener */
|
||||
protected ComponentListener componentListener;
|
||||
/** Glass pane dispatcher */
|
||||
protected MouseInputListener glassPaneDispatcher;
|
||||
private InternalFrameListener internalFrameListener;
|
||||
|
||||
/** North pane */
|
||||
protected JComponent northPane;
|
||||
/** South pane */
|
||||
protected JComponent southPane;
|
||||
/** West pane */
|
||||
protected JComponent westPane;
|
||||
/** East pane */
|
||||
protected JComponent eastPane;
|
||||
|
||||
/** Title pane */
|
||||
protected BasicInternalFrameTitlePane titlePane; // access needs this
|
||||
|
||||
private static DesktopManager sharedDesktopManager;
|
||||
@ -85,10 +94,19 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ComponentUI Interface Implementation methods
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Returns a component UI.
|
||||
* @param b a component
|
||||
* @return a component UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
return new BasicInternalFrameUI((JInternalFrame)b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code BasicInternalFrameUI}.
|
||||
* @param b the internal frame
|
||||
*/
|
||||
public BasicInternalFrameUI(JInternalFrame b) {
|
||||
LookAndFeel laf = UIManager.getLookAndFeel();
|
||||
if (laf instanceof BasicLookAndFeel) {
|
||||
@ -96,6 +114,10 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the UI.
|
||||
* @param c the component
|
||||
*/
|
||||
public void installUI(JComponent c) {
|
||||
|
||||
frame = (JInternalFrame)c;
|
||||
@ -108,6 +130,10 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
LookAndFeel.installProperty(frame, "opaque", Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the UI.
|
||||
* @param c the component
|
||||
*/
|
||||
public void uninstallUI(JComponent c) {
|
||||
if(c != frame)
|
||||
throw new IllegalComponentStateException(
|
||||
@ -124,6 +150,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
frame = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the defaults.
|
||||
*/
|
||||
protected void installDefaults(){
|
||||
Icon frameIcon = frame.getFrameIcon();
|
||||
if (frameIcon == null || frameIcon instanceof UIResource) {
|
||||
@ -144,6 +173,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
LookAndFeel.installBorder(frame, "InternalFrame.border");
|
||||
|
||||
}
|
||||
/**
|
||||
* Installs the keyboard actions.
|
||||
*/
|
||||
protected void installKeyboardActions(){
|
||||
createInternalFrameListener();
|
||||
if (internalFrameListener != null) {
|
||||
@ -184,6 +216,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
BasicLookAndFeel.installAudioActionMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the components.
|
||||
*/
|
||||
protected void installComponents(){
|
||||
setNorthPane(createNorthPane(frame));
|
||||
setSouthPane(createSouthPane(frame));
|
||||
@ -192,6 +227,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the listeners.
|
||||
* @since 1.3
|
||||
*/
|
||||
protected void installListeners() {
|
||||
@ -257,6 +293,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the defaults.
|
||||
*/
|
||||
protected void uninstallDefaults() {
|
||||
Icon frameIcon = frame.getFrameIcon();
|
||||
if (frameIcon instanceof UIResource) {
|
||||
@ -267,6 +306,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
LookAndFeel.uninstallBorder(frame);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the components.
|
||||
*/
|
||||
protected void uninstallComponents(){
|
||||
setNorthPane(null);
|
||||
setSouthPane(null);
|
||||
@ -279,6 +321,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the listeners.
|
||||
* @since 1.3
|
||||
*/
|
||||
protected void uninstallListeners() {
|
||||
@ -298,6 +341,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
borderListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the keyboard actions.
|
||||
*/
|
||||
protected void uninstallKeyboardActions(){
|
||||
if (internalFrameListener != null) {
|
||||
frame.removeInternalFrameListener(internalFrameListener);
|
||||
@ -321,22 +367,38 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
frame.setCursor(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the layout manager.
|
||||
* @return the layout manager
|
||||
*/
|
||||
protected LayoutManager createLayoutManager(){
|
||||
return getHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the property change listener.
|
||||
* @return the property change listener
|
||||
*/
|
||||
protected PropertyChangeListener createPropertyChangeListener(){
|
||||
return getHandler();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the preferred size.
|
||||
* @param x the component
|
||||
* @return the preferred size
|
||||
*/
|
||||
public Dimension getPreferredSize(JComponent x) {
|
||||
if(frame == x)
|
||||
return frame.getLayout().preferredLayoutSize(x);
|
||||
return new Dimension(100, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum size.
|
||||
* @param x the component
|
||||
* @return the minimum size
|
||||
*/
|
||||
public Dimension getMinimumSize(JComponent x) {
|
||||
if(frame == x) {
|
||||
return frame.getLayout().minimumLayoutSize(x);
|
||||
@ -344,6 +406,11 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
return new Dimension(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum size.
|
||||
* @param x the component
|
||||
* @return the maximum size
|
||||
*/
|
||||
public Dimension getMaximumSize(JComponent x) {
|
||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
@ -371,60 +438,114 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deinstalls the mouse handlers.
|
||||
* @param c the component
|
||||
*/
|
||||
protected void deinstallMouseHandlers(JComponent c) {
|
||||
c.removeMouseListener(borderListener);
|
||||
c.removeMouseMotionListener(borderListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the mouse handlers.
|
||||
* @param c the component
|
||||
*/
|
||||
protected void installMouseHandlers(JComponent c) {
|
||||
c.addMouseListener(borderListener);
|
||||
c.addMouseMotionListener(borderListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the north pane.
|
||||
* @param w the internal frame
|
||||
* @return the north pane
|
||||
*/
|
||||
protected JComponent createNorthPane(JInternalFrame w) {
|
||||
titlePane = new BasicInternalFrameTitlePane(w);
|
||||
return titlePane;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the north pane.
|
||||
* @param w the internal frame
|
||||
* @return the north pane
|
||||
*/
|
||||
protected JComponent createSouthPane(JInternalFrame w) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the west pane.
|
||||
* @param w the internal frame
|
||||
* @return the west pane
|
||||
*/
|
||||
protected JComponent createWestPane(JInternalFrame w) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the east pane.
|
||||
* @param w the internal frame
|
||||
* @return the east pane
|
||||
*/
|
||||
protected JComponent createEastPane(JInternalFrame w) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the border listener.
|
||||
* @param w the internal frame
|
||||
* @return the border listener
|
||||
*/
|
||||
protected MouseInputAdapter createBorderListener(JInternalFrame w) {
|
||||
return new BorderListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the internal frame listener.
|
||||
*/
|
||||
protected void createInternalFrameListener(){
|
||||
internalFrameListener = getHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or no the key binding is registered.
|
||||
* @return whether or no the key binding is registered
|
||||
*/
|
||||
protected final boolean isKeyBindingRegistered(){
|
||||
return keyBindingRegistered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the key binding registration.
|
||||
* @param b new value for key binding registration
|
||||
*/
|
||||
protected final void setKeyBindingRegistered(boolean b){
|
||||
keyBindingRegistered = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or no the key binding is active.
|
||||
* @return whether or no the key binding is active
|
||||
*/
|
||||
public final boolean isKeyBindingActive(){
|
||||
return keyBindingActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the key binding activity.
|
||||
* @param b new value for key binding activity
|
||||
*/
|
||||
protected final void setKeyBindingActive(boolean b){
|
||||
keyBindingActive = b;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup the menu open key.
|
||||
*/
|
||||
protected void setupMenuOpenKey(){
|
||||
// PENDING(hania): Why are these WHEN_IN_FOCUSED_WINDOWs? Shouldn't
|
||||
// they be WHEN_ANCESTOR_OF_FOCUSED_COMPONENT?
|
||||
@ -437,13 +558,24 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
//SwingUtilities.replaceUIActionMap(frame, actionMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the menu close key.
|
||||
*/
|
||||
protected void setupMenuCloseKey(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the north pane.
|
||||
* @return the north pane
|
||||
*/
|
||||
public JComponent getNorthPane() {
|
||||
return northPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the north pane.
|
||||
* @param c the new north pane
|
||||
*/
|
||||
public void setNorthPane(JComponent c) {
|
||||
if (northPane != null &&
|
||||
northPane instanceof BasicInternalFrameTitlePane) {
|
||||
@ -456,30 +588,57 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the south pane.
|
||||
* @return the south pane
|
||||
*/
|
||||
public JComponent getSouthPane() {
|
||||
return southPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the south pane.
|
||||
* @param c the new south pane
|
||||
*/
|
||||
public void setSouthPane(JComponent c) {
|
||||
southPane = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the west pane.
|
||||
* @return the west pane
|
||||
*/
|
||||
public JComponent getWestPane() {
|
||||
return westPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the west pane.
|
||||
* @param c the new west pane
|
||||
*/
|
||||
public void setWestPane(JComponent c) {
|
||||
westPane = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the east pane.
|
||||
* @return the east pane
|
||||
*/
|
||||
public JComponent getEastPane() {
|
||||
return eastPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the east pane.
|
||||
* @param c the new east pane
|
||||
*/
|
||||
public void setEastPane(JComponent c) {
|
||||
eastPane = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal frame property change listener.
|
||||
*/
|
||||
public class InternalFramePropertyChangeListener implements
|
||||
PropertyChangeListener {
|
||||
// NOTE: This class exists only for backward compatibility. All
|
||||
@ -495,27 +654,45 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal frame layout.
|
||||
*/
|
||||
public class InternalFrameLayout implements LayoutManager {
|
||||
// NOTE: This class exists only for backward compatibility. All
|
||||
// its functionality has been moved into Handler. If you need to add
|
||||
// new functionality add it to the Handler, but make sure this
|
||||
// class calls into the Handler.
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addLayoutComponent(String name, Component c) {
|
||||
getHandler().addLayoutComponent(name, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void removeLayoutComponent(Component c) {
|
||||
getHandler().removeLayoutComponent(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Dimension preferredLayoutSize(Container c) {
|
||||
return getHandler().preferredLayoutSize(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Dimension minimumLayoutSize(Container c) {
|
||||
return getHandler().minimumLayoutSize(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void layoutContainer(Container c) {
|
||||
getHandler().layoutContainer(c);
|
||||
}
|
||||
@ -527,6 +704,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
* find the JDesktop component and returns the desktopManager from
|
||||
* it. If this fails, it will return a default DesktopManager that
|
||||
* should work in arbitrary parents.
|
||||
* @return the proper DesktopManager
|
||||
*/
|
||||
protected DesktopManager getDesktopManager() {
|
||||
if(frame.getDesktopPane() != null
|
||||
@ -537,6 +715,10 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
return sharedDesktopManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the desktop manager.
|
||||
* @return the desktop manager
|
||||
*/
|
||||
protected DesktopManager createDesktopManager(){
|
||||
return new DefaultDesktopManager();
|
||||
}
|
||||
@ -653,7 +835,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
Rectangle startingBounds;
|
||||
int resizeDir;
|
||||
|
||||
|
||||
/** resize none */
|
||||
protected final int RESIZE_NONE = 0;
|
||||
private boolean discardRelease = false;
|
||||
|
||||
@ -1114,6 +1296,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
|
||||
} /// End BorderListener Class
|
||||
|
||||
/**
|
||||
* Component handler.
|
||||
*/
|
||||
protected class ComponentHandler implements ComponentListener {
|
||||
// NOTE: This class exists only for backward compatibility. All
|
||||
// its functionality has been moved into Handler. If you need to add
|
||||
@ -1124,92 +1309,155 @@ public class BasicInternalFrameUI extends InternalFrameUI
|
||||
getHandler().componentResized(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
getHandler().componentMoved(e);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void componentShown(ComponentEvent e) {
|
||||
getHandler().componentShown(e);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
getHandler().componentHidden(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a component listener.
|
||||
* @return a component listener
|
||||
*/
|
||||
protected ComponentListener createComponentListener() {
|
||||
return getHandler();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Glass pane dispatcher.
|
||||
*/
|
||||
protected class GlassPaneDispatcher implements MouseInputListener {
|
||||
// NOTE: This class exists only for backward compatibility. All
|
||||
// its functionality has been moved into Handler. If you need to add
|
||||
// new functionality add it to the Handler, but make sure this
|
||||
// class calls into the Handler.
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void mousePressed(MouseEvent e) {
|
||||
getHandler().mousePressed(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
getHandler().mouseEntered(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
getHandler().mouseMoved(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void mouseExited(MouseEvent e) {
|
||||
getHandler().mouseExited(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
getHandler().mouseClicked(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
getHandler().mouseReleased(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
getHandler().mouseDragged(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code GlassPaneDispatcher}.
|
||||
* @return a {@code GlassPaneDispatcher}
|
||||
*/
|
||||
protected MouseInputListener createGlassPaneDispatcher() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Basic internal frame listener.
|
||||
*/
|
||||
protected class BasicInternalFrameListener implements InternalFrameListener
|
||||
{
|
||||
// NOTE: This class exists only for backward compatibility. All
|
||||
// its functionality has been moved into Handler. If you need to add
|
||||
// new functionality add it to the Handler, but make sure this
|
||||
// class calls into the Handler.
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void internalFrameClosing(InternalFrameEvent e) {
|
||||
getHandler().internalFrameClosing(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void internalFrameClosed(InternalFrameEvent e) {
|
||||
getHandler().internalFrameClosed(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void internalFrameOpened(InternalFrameEvent e) {
|
||||
getHandler().internalFrameOpened(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void internalFrameIconified(InternalFrameEvent e) {
|
||||
getHandler().internalFrameIconified(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void internalFrameDeiconified(InternalFrameEvent e) {
|
||||
getHandler().internalFrameDeiconified(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void internalFrameActivated(InternalFrameEvent e) {
|
||||
getHandler().internalFrameActivated(e);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void internalFrameDeactivated(InternalFrameEvent e) {
|
||||
getHandler().internalFrameDeactivated(e);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -875,30 +875,38 @@ public class BasicMenuItemUI extends MenuItemUI
|
||||
if (dumpStack == true)
|
||||
Thread.dumpStack();
|
||||
}
|
||||
/** Mouse input handler */
|
||||
protected class MouseInputHandler implements MouseInputListener {
|
||||
// NOTE: This class exists only for backward compatibility. All
|
||||
// its functionality has been moved into Handler. If you need to add
|
||||
// new functionality add it to the Handler, but make sure this
|
||||
// class calls into the Handler.
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
getHandler().mouseClicked(e);
|
||||
}
|
||||
/** {@inheritDoc} */
|
||||
public void mousePressed(MouseEvent e) {
|
||||
getHandler().mousePressed(e);
|
||||
}
|
||||
/** {@inheritDoc} */
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
getHandler().mouseReleased(e);
|
||||
}
|
||||
/** {@inheritDoc} */
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
getHandler().mouseEntered(e);
|
||||
}
|
||||
/** {@inheritDoc} */
|
||||
public void mouseExited(MouseEvent e) {
|
||||
getHandler().mouseExited(e);
|
||||
}
|
||||
/** {@inheritDoc} */
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
getHandler().mouseDragged(e);
|
||||
}
|
||||
/** {@inheritDoc} */
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
getHandler().mouseMoved(e);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -136,7 +136,7 @@ public class BasicOptionPaneUI extends OptionPaneUI {
|
||||
|
||||
/**
|
||||
* Creates a new {@code BasicOptionPaneUI} instance.
|
||||
*
|
||||
* @param x the component
|
||||
* @return a new {@code BasicOptionPaneUI} instance
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -60,35 +60,59 @@ public class BasicScrollBarUI
|
||||
|
||||
// NOTE: DO NOT use this field directly, SynthScrollBarUI assumes you'll
|
||||
// call getMinimumThumbSize to access it.
|
||||
/** Minimum thumb size */
|
||||
protected Dimension minimumThumbSize;
|
||||
/** Maximum thumb size */
|
||||
protected Dimension maximumThumbSize;
|
||||
|
||||
/** Thumb highlight color */
|
||||
protected Color thumbHighlightColor;
|
||||
/** Thumb light shadow color */
|
||||
protected Color thumbLightShadowColor;
|
||||
/** Thumb dark shadow color */
|
||||
protected Color thumbDarkShadowColor;
|
||||
/** Thumb color */
|
||||
protected Color thumbColor;
|
||||
/** Track color */
|
||||
protected Color trackColor;
|
||||
/** Track highlight color */
|
||||
protected Color trackHighlightColor;
|
||||
|
||||
/** Scrollbar */
|
||||
protected JScrollBar scrollbar;
|
||||
/** Increment button */
|
||||
protected JButton incrButton;
|
||||
/** Decrement button */
|
||||
protected JButton decrButton;
|
||||
/** Dragging */
|
||||
protected boolean isDragging;
|
||||
/** Track listener */
|
||||
protected TrackListener trackListener;
|
||||
/** Button listener */
|
||||
protected ArrowButtonListener buttonListener;
|
||||
/** Model listener */
|
||||
protected ModelListener modelListener;
|
||||
|
||||
/** Thumb rectangle */
|
||||
protected Rectangle thumbRect;
|
||||
/** Track rectangle */
|
||||
protected Rectangle trackRect;
|
||||
|
||||
/** Track highlight */
|
||||
protected int trackHighlight;
|
||||
|
||||
/** No highlight */
|
||||
protected static final int NO_HIGHLIGHT = 0;
|
||||
/** Decrease highlight */
|
||||
protected static final int DECREASE_HIGHLIGHT = 1;
|
||||
/** Increase highlight */
|
||||
protected static final int INCREASE_HIGHLIGHT = 2;
|
||||
|
||||
/** Scroll listener */
|
||||
protected ScrollListener scrollListener;
|
||||
/** Property change listener */
|
||||
protected PropertyChangeListener propertyChangeListener;
|
||||
/** Scroll timer */
|
||||
protected Timer scrollTimer;
|
||||
|
||||
private final static int scrollSpeedThrottle = 60; // delay in milli seconds
|
||||
@ -148,12 +172,18 @@ public class BasicScrollBarUI
|
||||
map.put(new Actions(Actions.MAX_SCROLL));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the UI.
|
||||
* @param c the component
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new BasicScrollBarUI();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configures the scroll bar colors.
|
||||
*/
|
||||
protected void configureScrollBarColors()
|
||||
{
|
||||
LookAndFeel.installColors(scrollbar, "ScrollBar.background",
|
||||
@ -166,7 +196,10 @@ public class BasicScrollBarUI
|
||||
trackHighlightColor = UIManager.getColor("ScrollBar.trackHighlight");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Installs the UI.
|
||||
* @param c the component
|
||||
*/
|
||||
public void installUI(JComponent c) {
|
||||
scrollbar = (JScrollBar)c;
|
||||
thumbRect = new Rectangle(0, 0, 0, 0);
|
||||
@ -177,6 +210,10 @@ public class BasicScrollBarUI
|
||||
installKeyboardActions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the UI.
|
||||
* @param c the component
|
||||
*/
|
||||
public void uninstallUI(JComponent c) {
|
||||
scrollbar = (JScrollBar)c;
|
||||
uninstallListeners();
|
||||
@ -189,7 +226,9 @@ public class BasicScrollBarUI
|
||||
decrButton = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Installs the defaults.
|
||||
*/
|
||||
protected void installDefaults()
|
||||
{
|
||||
scrollBarWidth = UIManager.getInt("ScrollBar.width");
|
||||
@ -240,7 +279,9 @@ public class BasicScrollBarUI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Installs the components.
|
||||
*/
|
||||
protected void installComponents(){
|
||||
switch (scrollbar.getOrientation()) {
|
||||
case JScrollBar.VERTICAL:
|
||||
@ -264,12 +305,17 @@ public class BasicScrollBarUI
|
||||
scrollbar.setEnabled(scrollbar.isEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the components.
|
||||
*/
|
||||
protected void uninstallComponents(){
|
||||
scrollbar.remove(incrButton);
|
||||
scrollbar.remove(decrButton);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Installs the listeners.
|
||||
*/
|
||||
protected void installListeners(){
|
||||
trackListener = createTrackListener();
|
||||
buttonListener = createArrowButtonListener();
|
||||
@ -294,7 +340,9 @@ public class BasicScrollBarUI
|
||||
scrollTimer.setInitialDelay(300); // default InitialDelay?
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Installs the keyboard actions.
|
||||
*/
|
||||
protected void installKeyboardActions(){
|
||||
LazyActionMap.installLazyActionMap(scrollbar, BasicScrollBarUI.class,
|
||||
"ScrollBar.actionMap");
|
||||
@ -307,6 +355,9 @@ public class BasicScrollBarUI
|
||||
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the keyboard actions.
|
||||
*/
|
||||
protected void uninstallKeyboardActions(){
|
||||
SwingUtilities.replaceUIInputMap(scrollbar, JComponent.WHEN_FOCUSED,
|
||||
null);
|
||||
@ -343,7 +394,9 @@ public class BasicScrollBarUI
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Uninstall the listeners.
|
||||
*/
|
||||
protected void uninstallListeners() {
|
||||
scrollTimer.stop();
|
||||
scrollTimer = null;
|
||||
@ -363,7 +416,9 @@ public class BasicScrollBarUI
|
||||
handler = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Uninstalls the defaults.
|
||||
*/
|
||||
protected void uninstallDefaults(){
|
||||
LookAndFeel.uninstallBorder(scrollbar);
|
||||
if (scrollbar.getLayout() == this) {
|
||||
@ -379,22 +434,42 @@ public class BasicScrollBarUI
|
||||
return handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a track listener.
|
||||
* @return a track listener
|
||||
*/
|
||||
protected TrackListener createTrackListener(){
|
||||
return new TrackListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an arrow button listener.
|
||||
* @return an arrow button listener
|
||||
*/
|
||||
protected ArrowButtonListener createArrowButtonListener(){
|
||||
return new ArrowButtonListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a model listener.
|
||||
* @return a model listener
|
||||
*/
|
||||
protected ModelListener createModelListener(){
|
||||
return new ModelListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a scroll listener.
|
||||
* @return a scroll listener
|
||||
*/
|
||||
protected ScrollListener createScrollListener(){
|
||||
return new ScrollListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a property change listener.
|
||||
* @return a property change listener
|
||||
*/
|
||||
protected PropertyChangeListener createPropertyChangeListener() {
|
||||
return getHandler();
|
||||
}
|
||||
@ -470,6 +545,11 @@ public class BasicScrollBarUI
|
||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a decrease button.
|
||||
* @param orientation the orientation
|
||||
* @return a decrease button
|
||||
*/
|
||||
protected JButton createDecreaseButton(int orientation) {
|
||||
return new BasicArrowButton(orientation,
|
||||
UIManager.getColor("ScrollBar.thumb"),
|
||||
@ -478,6 +558,11 @@ public class BasicScrollBarUI
|
||||
UIManager.getColor("ScrollBar.thumbHighlight"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an increase button.
|
||||
* @param orientation the orientation
|
||||
* @return an increase button
|
||||
*/
|
||||
protected JButton createIncreaseButton(int orientation) {
|
||||
return new BasicArrowButton(orientation,
|
||||
UIManager.getColor("ScrollBar.thumb"),
|
||||
@ -487,6 +572,10 @@ public class BasicScrollBarUI
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Paints the decrease highlight.
|
||||
* @param g the graphics
|
||||
*/
|
||||
protected void paintDecreaseHighlight(Graphics g)
|
||||
{
|
||||
Insets insets = scrollbar.getInsets();
|
||||
@ -519,6 +608,10 @@ public class BasicScrollBarUI
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Paints the increase highlight.
|
||||
* @param g the graphics
|
||||
*/
|
||||
protected void paintIncreaseHighlight(Graphics g)
|
||||
{
|
||||
Insets insets = scrollbar.getInsets();
|
||||
@ -552,6 +645,12 @@ public class BasicScrollBarUI
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Paints the track.
|
||||
* @param g the graphics
|
||||
* @param c the component
|
||||
* @param trackBounds the track bounds
|
||||
*/
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds)
|
||||
{
|
||||
g.setColor(trackColor);
|
||||
@ -565,7 +664,12 @@ public class BasicScrollBarUI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Paints the thumb.
|
||||
* @param g the graphics
|
||||
* @param c the component
|
||||
* @param thumbBounds the thumb bounds
|
||||
*/
|
||||
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
|
||||
{
|
||||
if(thumbBounds.isEmpty() || !scrollbar.isEnabled()) {
|
||||
@ -644,6 +748,10 @@ public class BasicScrollBarUI
|
||||
return (useCachedValue) ? scrollBarValue : sb.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Laysouts a vertical scroll bar.
|
||||
* @param sb the scroll bar
|
||||
*/
|
||||
protected void layoutVScrollbar(JScrollBar sb)
|
||||
{
|
||||
Dimension sbSize = sb.getSize();
|
||||
@ -742,7 +850,10 @@ public class BasicScrollBarUI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Laysouts a vertical scroll bar.
|
||||
* @param sb the scroll bar
|
||||
*/
|
||||
protected void layoutHScrollbar(JScrollBar sb)
|
||||
{
|
||||
Dimension sbSize = sb.getSize();
|
||||
@ -966,6 +1077,10 @@ public class BasicScrollBarUI
|
||||
scrollbar.setValue(newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls by block.
|
||||
* @param direction the direction to scroll
|
||||
*/
|
||||
protected void scrollByBlock(int direction)
|
||||
{
|
||||
scrollByBlock(scrollbar, direction);
|
||||
@ -1033,6 +1148,10 @@ public class BasicScrollBarUI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls by unit.
|
||||
* @param direction the direction to scroll
|
||||
*/
|
||||
protected void scrollByUnit(int direction) {
|
||||
scrollByUnits(scrollbar, direction, 1, false);
|
||||
}
|
||||
@ -1050,7 +1169,6 @@ public class BasicScrollBarUI
|
||||
|
||||
/**
|
||||
* A listener to listen for model changes.
|
||||
*
|
||||
*/
|
||||
protected class ModelListener implements ChangeListener {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
@ -1069,10 +1187,15 @@ public class BasicScrollBarUI
|
||||
protected class TrackListener
|
||||
extends MouseAdapter implements MouseMotionListener
|
||||
{
|
||||
/** The offset */
|
||||
protected transient int offset;
|
||||
protected transient int currentMouseX, currentMouseY;
|
||||
/** Current mouse x position */
|
||||
protected transient int currentMouseX;
|
||||
/** Current mouse y position */
|
||||
protected transient int currentMouseY;
|
||||
private transient int direction = +1;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void mouseReleased(MouseEvent e)
|
||||
{
|
||||
if (isDragging) {
|
||||
@ -1339,6 +1462,7 @@ public class BasicScrollBarUI
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
if (!isDragging) {
|
||||
updateThumbState(e.getX(), e.getY());
|
||||
@ -1406,19 +1530,34 @@ public class BasicScrollBarUI
|
||||
int direction = +1;
|
||||
boolean useBlockIncrement;
|
||||
|
||||
/** Constructs a {@code ScrollListener}. */
|
||||
public ScrollListener() {
|
||||
direction = +1;
|
||||
useBlockIncrement = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code ScrollListener}.
|
||||
* @param dir direction
|
||||
* @param block use block increment
|
||||
*/
|
||||
public ScrollListener(int dir, boolean block) {
|
||||
direction = dir;
|
||||
useBlockIncrement = block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the direction.
|
||||
* @param direction the new direction
|
||||
*/
|
||||
public void setDirection(int direction) { this.direction = direction; }
|
||||
/**
|
||||
* Sets the scrolling by block
|
||||
* @param block whether or not to scroll by block
|
||||
*/
|
||||
public void setScrollByBlock(boolean block) { this.useBlockIncrement = block; }
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(useBlockIncrement) {
|
||||
scrollByBlock(direction);
|
||||
@ -1497,13 +1636,14 @@ public class BasicScrollBarUI
|
||||
}
|
||||
}
|
||||
|
||||
/** Property change handler */
|
||||
public class PropertyChangeHandler implements PropertyChangeListener
|
||||
{
|
||||
// NOTE: This class exists only for backward compatibility. All
|
||||
// its functionality has been moved into Handler. If you need to add
|
||||
// new functionality add it to the Handler, but make sure this
|
||||
// class calls into the Handler.
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
getHandler().propertyChange(e);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -746,6 +746,9 @@ public class BasicScrollPaneUI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Property change handler.
|
||||
*/
|
||||
public class PropertyChangeHandler implements PropertyChangeListener
|
||||
{
|
||||
|
||||
@ -754,6 +757,9 @@ public class BasicScrollPaneUI
|
||||
// new functionality add it to the Handler, but make sure this
|
||||
// class calls into the Handler.
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void propertyChange(PropertyChangeEvent e)
|
||||
{
|
||||
getHandler().propertyChange(e);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -47,33 +47,55 @@ public class BasicSliderUI extends SliderUI{
|
||||
// Old actions forward to an instance of this.
|
||||
private static final Actions SHARED_ACTION = new Actions();
|
||||
|
||||
/** Positive scroll */
|
||||
public static final int POSITIVE_SCROLL = +1;
|
||||
/** Negative scroll */
|
||||
public static final int NEGATIVE_SCROLL = -1;
|
||||
/** Minimum scroll */
|
||||
public static final int MIN_SCROLL = -2;
|
||||
/** Maximum scroll */
|
||||
public static final int MAX_SCROLL = +2;
|
||||
|
||||
/** Scroll timer */
|
||||
protected Timer scrollTimer;
|
||||
/** Slider */
|
||||
protected JSlider slider;
|
||||
|
||||
/** Focus insets */
|
||||
protected Insets focusInsets = null;
|
||||
/** Inset cache */
|
||||
protected Insets insetCache = null;
|
||||
/** Left-to-right cache */
|
||||
protected boolean leftToRightCache = true;
|
||||
/** Focus rectangle */
|
||||
protected Rectangle focusRect = null;
|
||||
/** Content rectangle */
|
||||
protected Rectangle contentRect = null;
|
||||
/** Label rectangle */
|
||||
protected Rectangle labelRect = null;
|
||||
/** Tick rectangle */
|
||||
protected Rectangle tickRect = null;
|
||||
/** Track rectangle */
|
||||
protected Rectangle trackRect = null;
|
||||
/** Thumb rectangle */
|
||||
protected Rectangle thumbRect = null;
|
||||
|
||||
protected int trackBuffer = 0; // The distance that the track is from the side of the control
|
||||
/** The distance that the track is from the side of the control */
|
||||
protected int trackBuffer = 0;
|
||||
|
||||
private transient boolean isDragging;
|
||||
|
||||
/** Track listener */
|
||||
protected TrackListener trackListener;
|
||||
/** Change listener */
|
||||
protected ChangeListener changeListener;
|
||||
/** Component listener */
|
||||
protected ComponentListener componentListener;
|
||||
/** Focus listener */
|
||||
protected FocusListener focusListener;
|
||||
/** Scroll listener */
|
||||
protected ScrollListener scrollListener;
|
||||
/** Property chane listener */
|
||||
protected PropertyChangeListener propertyChangeListener;
|
||||
private Handler handler;
|
||||
private int lastValue;
|
||||
@ -93,15 +115,26 @@ public class BasicSliderUI extends SliderUI{
|
||||
*/
|
||||
private boolean sameLabelBaselines;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the shadow color.
|
||||
* @return the shadow color
|
||||
*/
|
||||
protected Color getShadowColor() {
|
||||
return shadowColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the highlight color.
|
||||
* @return the highlight color
|
||||
*/
|
||||
protected Color getHighlightColor() {
|
||||
return highlightColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the focus color.
|
||||
* @return the focus color
|
||||
*/
|
||||
protected Color getFocusColor() {
|
||||
return focusColor;
|
||||
}
|
||||
@ -119,13 +152,26 @@ public class BasicSliderUI extends SliderUI{
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ComponentUI Interface Implementation methods
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Creates a UI.
|
||||
* @param b a component
|
||||
* @return a UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
return new BasicSliderUI((JSlider)b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code BasicSliderUI}.
|
||||
* @param b a slider
|
||||
*/
|
||||
public BasicSliderUI(JSlider b) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs a UI.
|
||||
* @param c a component
|
||||
*/
|
||||
public void installUI(JComponent c) {
|
||||
slider = (JSlider) c;
|
||||
|
||||
@ -162,6 +208,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
calculateGeometry(); // This figures out where the labels, ticks, track, and thumb are.
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls a UI.
|
||||
* @param c a component
|
||||
*/
|
||||
public void uninstallUI(JComponent c) {
|
||||
if ( c != slider )
|
||||
throw new IllegalComponentStateException(
|
||||
@ -193,6 +243,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
slider = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the defaults.
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected void installDefaults( JSlider slider ) {
|
||||
LookAndFeel.installBorder(slider, "Slider.border");
|
||||
LookAndFeel.installColorsAndFont(slider, "Slider.background",
|
||||
@ -208,32 +262,66 @@ public class BasicSliderUI extends SliderUI{
|
||||
if (focusInsets == null) focusInsets = new InsetsUIResource(2,2,2,2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the defaults.
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected void uninstallDefaults(JSlider slider) {
|
||||
LookAndFeel.uninstallBorder(slider);
|
||||
|
||||
focusInsets = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a track listener.
|
||||
* @return a track listener
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected TrackListener createTrackListener(JSlider slider) {
|
||||
return new TrackListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a change listener.
|
||||
* @return a change listener
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected ChangeListener createChangeListener(JSlider slider) {
|
||||
return getHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a composite listener.
|
||||
* @return a composite listener
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected ComponentListener createComponentListener(JSlider slider) {
|
||||
return getHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a focus listener.
|
||||
* @return a focus listener
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected FocusListener createFocusListener(JSlider slider) {
|
||||
return getHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a scroll listener.
|
||||
* @return a scroll listener
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected ScrollListener createScrollListener( JSlider slider ) {
|
||||
return new ScrollListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a property change listener.
|
||||
* @return a property change listener
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected PropertyChangeListener createPropertyChangeListener(
|
||||
JSlider slider) {
|
||||
return getHandler();
|
||||
@ -246,6 +334,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs listeners.
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected void installListeners( JSlider slider ) {
|
||||
slider.addMouseListener(trackListener);
|
||||
slider.addMouseMotionListener(trackListener);
|
||||
@ -255,6 +347,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
slider.getModel().addChangeListener(changeListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls listeners.
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected void uninstallListeners( JSlider slider ) {
|
||||
slider.removeMouseListener(trackListener);
|
||||
slider.removeMouseMotionListener(trackListener);
|
||||
@ -265,6 +361,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
handler = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs keyboard actions.
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected void installKeyboardActions( JSlider slider ) {
|
||||
InputMap km = getInputMap(JComponent.WHEN_FOCUSED, slider);
|
||||
SwingUtilities.replaceUIInputMap(slider, JComponent.WHEN_FOCUSED, km);
|
||||
@ -302,6 +402,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
map.put(new Actions(Actions.MAX_SCROLL_INCREMENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls keyboard actions.
|
||||
* @param slider a slider
|
||||
*/
|
||||
protected void uninstallKeyboardActions( JSlider slider ) {
|
||||
SwingUtilities.replaceUIActionMap(slider, null);
|
||||
SwingUtilities.replaceUIInputMap(slider, JComponent.WHEN_FOCUSED,
|
||||
@ -430,6 +534,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return sameLabelBaselines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred horizontal size.
|
||||
* @return the preferred horizontal size
|
||||
*/
|
||||
public Dimension getPreferredHorizontalSize() {
|
||||
Dimension horizDim = (Dimension)DefaultLookup.get(slider,
|
||||
this, "Slider.horizontalSize");
|
||||
@ -439,6 +547,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return horizDim;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred vertical size.
|
||||
* @return the preferred vertical size
|
||||
*/
|
||||
public Dimension getPreferredVerticalSize() {
|
||||
Dimension vertDim = (Dimension)DefaultLookup.get(slider,
|
||||
this, "Slider.verticalSize");
|
||||
@ -448,6 +560,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return vertDim;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum horizontal size.
|
||||
* @return the minimum horizontal size
|
||||
*/
|
||||
public Dimension getMinimumHorizontalSize() {
|
||||
Dimension minHorizDim = (Dimension)DefaultLookup.get(slider,
|
||||
this, "Slider.minimumHorizontalSize");
|
||||
@ -457,6 +573,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return minHorizDim;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum vertical size.
|
||||
* @return the minimum vertical size
|
||||
*/
|
||||
public Dimension getMinimumVerticalSize() {
|
||||
Dimension minVertDim = (Dimension)DefaultLookup.get(slider,
|
||||
this, "Slider.minimumVerticalSize");
|
||||
@ -466,6 +586,11 @@ public class BasicSliderUI extends SliderUI{
|
||||
return minVertDim;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred size.
|
||||
* @param c a component
|
||||
* @return the preferred size
|
||||
*/
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
recalculateIfInsetsChanged();
|
||||
Dimension d;
|
||||
@ -485,6 +610,11 @@ public class BasicSliderUI extends SliderUI{
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum size.
|
||||
* @param c a component
|
||||
* @return the minimum size
|
||||
*/
|
||||
public Dimension getMinimumSize(JComponent c) {
|
||||
recalculateIfInsetsChanged();
|
||||
Dimension d;
|
||||
@ -505,6 +635,11 @@ public class BasicSliderUI extends SliderUI{
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum size.
|
||||
* @param c a component
|
||||
* @return the maximum size
|
||||
*/
|
||||
public Dimension getMaximumSize(JComponent c) {
|
||||
Dimension d = getPreferredSize(c);
|
||||
if ( slider.getOrientation() == JSlider.VERTICAL ) {
|
||||
@ -517,6 +652,9 @@ public class BasicSliderUI extends SliderUI{
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the geometry.
|
||||
*/
|
||||
protected void calculateGeometry() {
|
||||
calculateFocusRect();
|
||||
calculateContentRect();
|
||||
@ -528,6 +666,9 @@ public class BasicSliderUI extends SliderUI{
|
||||
calculateThumbLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the focus rectangle.
|
||||
*/
|
||||
protected void calculateFocusRect() {
|
||||
focusRect.x = insetCache.left;
|
||||
focusRect.y = insetCache.top;
|
||||
@ -535,11 +676,17 @@ public class BasicSliderUI extends SliderUI{
|
||||
focusRect.height = slider.getHeight() - (insetCache.top + insetCache.bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the thumb size rectangle.
|
||||
*/
|
||||
protected void calculateThumbSize() {
|
||||
Dimension size = getThumbSize();
|
||||
thumbRect.setSize( size.width, size.height );
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the content rectangle.
|
||||
*/
|
||||
protected void calculateContentRect() {
|
||||
contentRect.x = focusRect.x + focusInsets.left;
|
||||
contentRect.y = focusRect.y + focusInsets.top;
|
||||
@ -564,6 +711,9 @@ public class BasicSliderUI extends SliderUI{
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the thumb location.
|
||||
*/
|
||||
protected void calculateThumbLocation() {
|
||||
if ( slider.getSnapToTicks() ) {
|
||||
int sliderValue = slider.getValue();
|
||||
@ -603,6 +753,9 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the track buffer.
|
||||
*/
|
||||
protected void calculateTrackBuffer() {
|
||||
if ( slider.getPaintLabels() && slider.getLabelTable() != null ) {
|
||||
Component highLabel = getHighestValueLabel();
|
||||
@ -627,7 +780,9 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the track rectangle.
|
||||
*/
|
||||
protected void calculateTrackRect() {
|
||||
int centerSpacing; // used to center sliders added using BorderLayout.CENTER (bug 4275631)
|
||||
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
||||
@ -671,6 +826,9 @@ public class BasicSliderUI extends SliderUI{
|
||||
return 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the tick rectangle.
|
||||
*/
|
||||
protected void calculateTickRect() {
|
||||
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
||||
tickRect.x = trackRect.x;
|
||||
@ -691,6 +849,9 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the label rectangle.
|
||||
*/
|
||||
protected void calculateLabelRect() {
|
||||
if ( slider.getPaintLabels() ) {
|
||||
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
||||
@ -733,6 +894,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the thumb size.
|
||||
* @return the thumb size
|
||||
*/
|
||||
protected Dimension getThumbSize() {
|
||||
Dimension size = new Dimension();
|
||||
|
||||
@ -748,16 +913,24 @@ public class BasicSliderUI extends SliderUI{
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* A property change handler.
|
||||
*/
|
||||
public class PropertyChangeHandler implements PropertyChangeListener {
|
||||
// NOTE: This class exists only for backward compatibility. All
|
||||
// its functionality has been moved into Handler. If you need to add
|
||||
// new functionality add it to the Handler, but make sure this
|
||||
// class calls into the Handler.
|
||||
/** {@inheritDoc} */
|
||||
public void propertyChange( PropertyChangeEvent e ) {
|
||||
getHandler().propertyChange(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the widest label.
|
||||
* @return the width of the widest label
|
||||
*/
|
||||
protected int getWidthOfWidestLabel() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Dictionary dictionary = slider.getLabelTable();
|
||||
@ -772,6 +945,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return widest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the tallest label.
|
||||
* @return the height of the tallest label
|
||||
*/
|
||||
protected int getHeightOfTallestLabel() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Dictionary dictionary = slider.getLabelTable();
|
||||
@ -786,6 +963,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return tallest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the highest value label.
|
||||
* @return the width of the highest value label
|
||||
*/
|
||||
protected int getWidthOfHighValueLabel() {
|
||||
Component label = getHighestValueLabel();
|
||||
int width = 0;
|
||||
@ -797,6 +978,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the lowest value label.
|
||||
* @return the width of the lowest value label
|
||||
*/
|
||||
protected int getWidthOfLowValueLabel() {
|
||||
Component label = getLowestValueLabel();
|
||||
int width = 0;
|
||||
@ -808,6 +993,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the highest value label.
|
||||
* @return the height of the highest value label
|
||||
*/
|
||||
protected int getHeightOfHighValueLabel() {
|
||||
Component label = getHighestValueLabel();
|
||||
int height = 0;
|
||||
@ -819,6 +1008,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the lowest value label.
|
||||
* @return the height of the lowest value label
|
||||
*/
|
||||
protected int getHeightOfLowValueLabel() {
|
||||
Component label = getLowestValueLabel();
|
||||
int height = 0;
|
||||
@ -830,6 +1023,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws inverted.
|
||||
* @return the inverted-ness
|
||||
*/
|
||||
protected boolean drawInverted() {
|
||||
if (slider.getOrientation()==JSlider.HORIZONTAL) {
|
||||
if(BasicGraphicsUtils.isLeftToRight(slider)) {
|
||||
@ -960,6 +1157,9 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculates if the insets have changed.
|
||||
*/
|
||||
protected void recalculateIfInsetsChanged() {
|
||||
Insets newInsets = slider.getInsets();
|
||||
if ( !newInsets.equals( insetCache ) ) {
|
||||
@ -968,6 +1168,9 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculates if the orientation has changed.
|
||||
*/
|
||||
protected void recalculateIfOrientationChanged() {
|
||||
boolean ltr = BasicGraphicsUtils.isLeftToRight(slider);
|
||||
if ( ltr!=leftToRightCache ) {
|
||||
@ -976,6 +1179,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints focus.
|
||||
* @param g the graphics
|
||||
*/
|
||||
public void paintFocus(Graphics g) {
|
||||
g.setColor( getFocusColor() );
|
||||
|
||||
@ -983,6 +1190,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
focusRect.width, focusRect.height );
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints track.
|
||||
* @param g the graphics
|
||||
*/
|
||||
public void paintTrack(Graphics g) {
|
||||
|
||||
Rectangle trackBounds = trackRect;
|
||||
@ -1023,6 +1234,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints ticks.
|
||||
* @param g the graphics
|
||||
*/
|
||||
public void paintTicks(Graphics g) {
|
||||
Rectangle tickBounds = tickRect;
|
||||
|
||||
@ -1120,22 +1335,50 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints minor tick for horizontal slider.
|
||||
* @param g the graphics
|
||||
* @param tickBounds the tick bounds
|
||||
* @param x the x coordinate
|
||||
*/
|
||||
protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
|
||||
g.drawLine( x, 0, x, tickBounds.height / 2 - 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints major tick for horizontal slider.
|
||||
* @param g the graphics
|
||||
* @param tickBounds the tick bounds
|
||||
* @param x the x coordinate
|
||||
*/
|
||||
protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
|
||||
g.drawLine( x, 0, x, tickBounds.height - 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints minor tick for vertical slider.
|
||||
* @param g the graphics
|
||||
* @param tickBounds the tick bounds
|
||||
* @param y the y coordinate
|
||||
*/
|
||||
protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) {
|
||||
g.drawLine( 0, y, tickBounds.width / 2 - 1, y );
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints major tick for vertical slider.
|
||||
* @param g the graphics
|
||||
* @param tickBounds the tick bounds
|
||||
* @param y the y coordinate
|
||||
*/
|
||||
protected void paintMajorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) {
|
||||
g.drawLine( 0, y, tickBounds.width - 2, y );
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the labels.
|
||||
* @param g the graphics
|
||||
*/
|
||||
public void paintLabels( Graphics g ) {
|
||||
Rectangle labelBounds = labelRect;
|
||||
|
||||
@ -1222,6 +1465,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
g.translate( 0, -labelTop );
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the thumb.
|
||||
* @param g the graphics
|
||||
*/
|
||||
public void paintThumb(Graphics g) {
|
||||
Rectangle knobBounds = thumbRect;
|
||||
int w = knobBounds.width;
|
||||
@ -1330,6 +1577,11 @@ public class BasicSliderUI extends SliderUI{
|
||||
// Used exclusively by setThumbLocation()
|
||||
private static Rectangle unionRect = new Rectangle();
|
||||
|
||||
/**
|
||||
* Sets the thumb location.
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
*/
|
||||
public void setThumbLocation(int x, int y) {
|
||||
unionRect.setBounds( thumbRect );
|
||||
|
||||
@ -1339,6 +1591,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
slider.repaint( unionRect.x, unionRect.y, unionRect.width, unionRect.height );
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls by block.
|
||||
* @param direction the direction
|
||||
*/
|
||||
public void scrollByBlock(int direction) {
|
||||
synchronized(slider) {
|
||||
int blockIncrement =
|
||||
@ -1360,6 +1616,10 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls by unit.
|
||||
* @param direction the direction
|
||||
*/
|
||||
public void scrollByUnit(int direction) {
|
||||
synchronized(slider) {
|
||||
int delta = ((direction > 0) ? POSITIVE_SCROLL : NEGATIVE_SCROLL);
|
||||
@ -1384,6 +1644,11 @@ public class BasicSliderUI extends SliderUI{
|
||||
scrollByBlock( dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the x position for a value.
|
||||
* @param value the value
|
||||
* @return the x position for a value
|
||||
*/
|
||||
protected int xPositionForValue( int value ) {
|
||||
int min = slider.getMinimum();
|
||||
int max = slider.getMaximum();
|
||||
@ -1409,6 +1674,11 @@ public class BasicSliderUI extends SliderUI{
|
||||
return xPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the y position for a value.
|
||||
* @param value the value
|
||||
* @return the y position for a value
|
||||
*/
|
||||
protected int yPositionForValue( int value ) {
|
||||
return yPositionForValue(value, trackRect.y, trackRect.height);
|
||||
}
|
||||
@ -1605,9 +1875,16 @@ public class BasicSliderUI extends SliderUI{
|
||||
* Instantiate it only within subclasses of <code>Foo</code>.
|
||||
*/
|
||||
public class TrackListener extends MouseInputAdapter {
|
||||
/** The offset */
|
||||
protected transient int offset;
|
||||
protected transient int currentMouseX, currentMouseY;
|
||||
/** Current mouse x. */
|
||||
protected transient int currentMouseX;
|
||||
/** Current mouse y. */
|
||||
protected transient int currentMouseY;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (!slider.isEnabled()) {
|
||||
return;
|
||||
@ -1736,6 +2013,11 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if scrolling should occur
|
||||
* @param direction the direction.
|
||||
* @return if scrolling should occur
|
||||
*/
|
||||
public boolean shouldScroll(int direction) {
|
||||
Rectangle r = thumbRect;
|
||||
if (slider.getOrientation() == JSlider.VERTICAL) {
|
||||
@ -1772,9 +2054,9 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the models value to the position of the top/left
|
||||
* of the thumb relative to the origin of the track.
|
||||
*/
|
||||
* Set the models value to the position of the top/left
|
||||
* of the thumb relative to the origin of the track.
|
||||
*/
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
int thumbMiddle;
|
||||
|
||||
@ -1839,6 +2121,7 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void mouseMoved(MouseEvent e) { }
|
||||
}
|
||||
|
||||
@ -1855,24 +2138,41 @@ public class BasicSliderUI extends SliderUI{
|
||||
int direction = POSITIVE_SCROLL;
|
||||
boolean useBlockIncrement;
|
||||
|
||||
/**
|
||||
* Constructs a {@code ScrollListener}
|
||||
*/
|
||||
public ScrollListener() {
|
||||
direction = POSITIVE_SCROLL;
|
||||
useBlockIncrement = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code ScrollListener}
|
||||
* @param dir the direction
|
||||
* @param block whether or not to scroll by block
|
||||
*/
|
||||
public ScrollListener(int dir, boolean block) {
|
||||
direction = dir;
|
||||
useBlockIncrement = block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the direction.
|
||||
* @param direction the new direction
|
||||
*/
|
||||
public void setDirection(int direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets scrolling by block
|
||||
* @param block the new scroll by block value
|
||||
*/
|
||||
public void setScrollByBlock(boolean block) {
|
||||
this.useBlockIncrement = block;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (useBlockIncrement) {
|
||||
scrollByBlock(direction);
|
||||
@ -1945,16 +2245,24 @@ public class BasicSliderUI extends SliderUI{
|
||||
boolean block;
|
||||
JSlider slider;
|
||||
|
||||
/**
|
||||
* Constructs an {@code ActionScroller}.
|
||||
* @param slider a slider
|
||||
* @param dir the direction
|
||||
* @param block block scrolling or not
|
||||
*/
|
||||
public ActionScroller( JSlider slider, int dir, boolean block) {
|
||||
this.dir = dir;
|
||||
this.block = block;
|
||||
this.slider = slider;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
SHARED_ACTION.scroll(slider, BasicSliderUI.this, dir, block);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean isEnabled() {
|
||||
boolean b = true;
|
||||
if (slider != null) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -56,22 +56,33 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
|
||||
// Instance variables initialized at installation
|
||||
|
||||
/** The tab pane */
|
||||
protected JTabbedPane tabPane;
|
||||
|
||||
/** Highlight color */
|
||||
protected Color highlight;
|
||||
/** Light highlight color */
|
||||
protected Color lightHighlight;
|
||||
/** Shadow color */
|
||||
protected Color shadow;
|
||||
/** Dark shadow color */
|
||||
protected Color darkShadow;
|
||||
/** Focus color */
|
||||
protected Color focus;
|
||||
private Color selectedColor;
|
||||
|
||||
/** Text icon gap */
|
||||
protected int textIconGap;
|
||||
|
||||
/** Tab run overlay */
|
||||
protected int tabRunOverlay;
|
||||
|
||||
/** Tab insets */
|
||||
protected Insets tabInsets;
|
||||
/** Selected tab insets */
|
||||
protected Insets selectedTabPadInsets;
|
||||
/** Tab area insets */
|
||||
protected Insets tabAreaInsets;
|
||||
/** Content border insets */
|
||||
protected Insets contentBorderInsets;
|
||||
private boolean tabsOverlapBorder;
|
||||
private boolean tabsOpaque = true;
|
||||
@ -120,19 +131,28 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
|
||||
|
||||
// Transient variables (recalculated each time TabbedPane is layed out)
|
||||
|
||||
/** Tab runs */
|
||||
protected int tabRuns[] = new int[10];
|
||||
/** Run count */
|
||||
protected int runCount = 0;
|
||||
/** Selected run */
|
||||
protected int selectedRun = -1;
|
||||
/** Tab rects */
|
||||
protected Rectangle rects[] = new Rectangle[0];
|
||||
/** Maximum tab height */
|
||||
protected int maxTabHeight;
|
||||
/** Maximum tab width */
|
||||
protected int maxTabWidth;
|
||||
|
||||
// Listeners
|
||||
|
||||
/** Tab change listener */
|
||||
protected ChangeListener tabChangeListener;
|
||||
/** Property change listener */
|
||||
protected PropertyChangeListener propertyChangeListener;
|
||||
/** Mouse change listener */
|
||||
protected MouseListener mouseListener;
|
||||
/** Focus change listener */
|
||||
protected FocusListener focusListener;
|
||||
|
||||
// Private instance data
|
||||
@ -190,6 +210,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
|
||||
// UI creation
|
||||
|
||||
/**
|
||||
* Create a UI.
|
||||
* @param c a component
|
||||
* @return a UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new BasicTabbedPaneUI();
|
||||
}
|
||||
@ -355,6 +380,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
tabContainer = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the defaults.
|
||||
*/
|
||||
protected void installDefaults() {
|
||||
LookAndFeel.installColorsAndFont(tabPane, "TabbedPane.background",
|
||||
"TabbedPane.foreground", "TabbedPane.font");
|
||||
@ -389,6 +417,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
if (contentBorderInsets == null) contentBorderInsets = new Insets(2,2,3,3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall the defaults.
|
||||
*/
|
||||
protected void uninstallDefaults() {
|
||||
highlight = null;
|
||||
lightHighlight = null;
|
||||
@ -401,6 +432,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
contentBorderInsets = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the listeners.
|
||||
*/
|
||||
protected void installListeners() {
|
||||
if ((propertyChangeListener = createPropertyChangeListener()) != null) {
|
||||
tabPane.addPropertyChangeListener(propertyChangeListener);
|
||||
@ -421,6 +455,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall the listeners.
|
||||
*/
|
||||
protected void uninstallListeners() {
|
||||
if (mouseListener != null) {
|
||||
tabPane.removeMouseListener(mouseListener);
|
||||
@ -448,18 +485,34 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
handler = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mouse listener.
|
||||
* @return a mouse listener
|
||||
*/
|
||||
protected MouseListener createMouseListener() {
|
||||
return getHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a focus listener.
|
||||
* @return a focus listener
|
||||
*/
|
||||
protected FocusListener createFocusListener() {
|
||||
return getHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a change listener.
|
||||
* @return a change listener
|
||||
*/
|
||||
protected ChangeListener createChangeListener() {
|
||||
return getHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a property change listener.
|
||||
* @return a property change listener
|
||||
*/
|
||||
protected PropertyChangeListener createPropertyChangeListener() {
|
||||
return getHandler();
|
||||
}
|
||||
@ -471,6 +524,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the keyboard actions.
|
||||
*/
|
||||
protected void installKeyboardActions() {
|
||||
InputMap km = getInputMap(JComponent.
|
||||
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
@ -498,6 +554,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls the keyboard actions.
|
||||
*/
|
||||
protected void uninstallKeyboardActions() {
|
||||
SwingUtilities.replaceUIActionMap(tabPane, null);
|
||||
SwingUtilities.replaceUIInputMap(tabPane, JComponent.
|
||||
@ -844,6 +903,15 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a tab.
|
||||
* @param g the graphics
|
||||
* @param tabPlacement the tab placement
|
||||
* @param rects rectangles
|
||||
* @param tabIndex the tab index
|
||||
* @param iconRect the icon rectangle
|
||||
* @param textRect the text rectangle
|
||||
*/
|
||||
protected void paintTab(Graphics g, int tabPlacement,
|
||||
Rectangle[] rects, int tabIndex,
|
||||
Rectangle iconRect, Rectangle textRect) {
|
||||
@ -1012,6 +1080,18 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laysout a label.
|
||||
* @param tabPlacement the tab placement
|
||||
* @param metrics the font metric
|
||||
* @param tabIndex the tab index
|
||||
* @param title the title
|
||||
* @param icon the icon
|
||||
* @param tabRect the tab rectangle
|
||||
* @param iconRect the icon rectangle
|
||||
* @param textRect the text rectangle
|
||||
* @param isSelected selection status
|
||||
*/
|
||||
protected void layoutLabel(int tabPlacement,
|
||||
FontMetrics metrics, int tabIndex,
|
||||
String title, Icon icon,
|
||||
@ -1045,6 +1125,15 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
textRect.y += yNudge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints an icon.
|
||||
* @param g the graphics
|
||||
* @param tabPlacement the tab placement
|
||||
* @param tabIndex the tab index
|
||||
* @param icon the icon
|
||||
* @param iconRect the icon rectangle
|
||||
* @param isSelected selection status
|
||||
*/
|
||||
protected void paintIcon(Graphics g, int tabPlacement,
|
||||
int tabIndex, Icon icon, Rectangle iconRect,
|
||||
boolean isSelected ) {
|
||||
@ -1053,6 +1142,17 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints text.
|
||||
* @param g the graphics
|
||||
* @param tabPlacement the tab placement
|
||||
* @param font the font
|
||||
* @param metrics the font metrics
|
||||
* @param tabIndex the tab index
|
||||
* @param title the title
|
||||
* @param textRect the text rectangle
|
||||
* @param isSelected selection status
|
||||
*/
|
||||
protected void paintText(Graphics g, int tabPlacement,
|
||||
Font font, FontMetrics metrics, int tabIndex,
|
||||
String title, Rectangle textRect,
|
||||
@ -1096,7 +1196,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the tab label shift x.
|
||||
* @param tabPlacement the tab placement
|
||||
* @param tabIndex the tab index
|
||||
* @param isSelected selection status
|
||||
* @return the tab label shift x
|
||||
*/
|
||||
protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected) {
|
||||
Rectangle tabRect = rects[tabIndex];
|
||||
String propKey = (isSelected ? "selectedLabelShift" : "labelShift");
|
||||
@ -1115,6 +1221,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tab label shift y.
|
||||
* @param tabPlacement the tab placement
|
||||
* @param tabIndex the tab index
|
||||
* @param isSelected selection status
|
||||
* @return the tab label shift y
|
||||
*/
|
||||
protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) {
|
||||
Rectangle tabRect = rects[tabIndex];
|
||||
int nudge = (isSelected ? DefaultLookup.getInt(tabPane, this, "TabbedPane.selectedLabelShift", -1) :
|
||||
@ -1132,6 +1245,16 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the focus indicator.
|
||||
* @param g the graphics
|
||||
* @param tabPlacement the tab placement
|
||||
* @param rects rectangles
|
||||
* @param tabIndex the tab index
|
||||
* @param iconRect the icon rectangle
|
||||
* @param textRect the text rectangle
|
||||
* @param isSelected selection status
|
||||
*/
|
||||
protected void paintFocusIndicator(Graphics g, int tabPlacement,
|
||||
Rectangle[] rects, int tabIndex,
|
||||
Rectangle iconRect, Rectangle textRect,
|
||||
@ -1245,6 +1368,18 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the tab background.
|
||||
* @param g the graphics context in which to paint
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param tabIndex the index of the tab with respect to other tabs
|
||||
* @param x the x coordinate of tab
|
||||
* @param y the y coordinate of tab
|
||||
* @param w the width of the tab
|
||||
* @param h the height of the tab
|
||||
* @param isSelected a {@code boolean} which determines whether or not
|
||||
* the tab is selected
|
||||
*/
|
||||
protected void paintTabBackground(Graphics g, int tabPlacement,
|
||||
int tabIndex,
|
||||
int x, int y, int w, int h,
|
||||
@ -1267,6 +1402,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the content border.
|
||||
* @param g the graphics context in which to paint
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param selectedIndex the tab index of the selected component
|
||||
*/
|
||||
protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {
|
||||
int width = tabPane.getWidth();
|
||||
int height = tabPane.getHeight();
|
||||
@ -1329,6 +1470,16 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the content border top edge.
|
||||
* @param g the graphics context in which to paint
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param selectedIndex the tab index of the selected component
|
||||
* @param x the x coordinate of tab
|
||||
* @param y the y coordinate of tab
|
||||
* @param w the width of the tab
|
||||
* @param h the height of the tab
|
||||
*/
|
||||
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex,
|
||||
int x, int y, int w, int h) {
|
||||
@ -1358,6 +1509,16 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the content border left edge.
|
||||
* @param g the graphics context in which to paint
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param selectedIndex the tab index of the selected component
|
||||
* @param x the x coordinate of tab
|
||||
* @param y the y coordinate of tab
|
||||
* @param w the width of the tab
|
||||
* @param h the height of the tab
|
||||
*/
|
||||
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex,
|
||||
int x, int y, int w, int h) {
|
||||
@ -1384,6 +1545,16 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the content border bottom edge.
|
||||
* @param g the graphics context in which to paint
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param selectedIndex the tab index of the selected component
|
||||
* @param x the x coordinate of tab
|
||||
* @param y the y coordinate of tab
|
||||
* @param w the width of the tab
|
||||
* @param h the height of the tab
|
||||
*/
|
||||
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex,
|
||||
int x, int y, int w, int h) {
|
||||
@ -1417,6 +1588,16 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the content border right edge.
|
||||
* @param g the graphics context in which to paint
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param selectedIndex the tab index of the selected component
|
||||
* @param x the x coordinate of tab
|
||||
* @param y the y coordinate of tab
|
||||
* @param w the width of the tab
|
||||
* @param h the height of the tab
|
||||
*/
|
||||
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex,
|
||||
int x, int y, int w, int h) {
|
||||
@ -1618,10 +1799,18 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
|
||||
// BasicTabbedPaneUI methods
|
||||
|
||||
/**
|
||||
* Returns the visible component.
|
||||
* @return the visible component
|
||||
*/
|
||||
protected Component getVisibleComponent() {
|
||||
return visibleComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visible component.
|
||||
* @param component the component
|
||||
*/
|
||||
protected void setVisibleComponent(Component component) {
|
||||
if (visibleComponent != null
|
||||
&& visibleComponent != component
|
||||
@ -1636,6 +1825,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
visibleComponent = component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure the rectangles are created.
|
||||
* @param tabCount the tab count
|
||||
*/
|
||||
protected void assureRectsCreated(int tabCount) {
|
||||
int rectArrayLen = rects.length;
|
||||
if (tabCount != rectArrayLen ) {
|
||||
@ -1650,6 +1843,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands the tab runs array.
|
||||
*/
|
||||
protected void expandTabRunsArray() {
|
||||
int rectLen = tabRuns.length;
|
||||
int[] newArray = new int[rectLen+10];
|
||||
@ -1657,6 +1853,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
tabRuns = newArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the run for a tab.
|
||||
* @param tabCount the tab count
|
||||
* @param tabIndex the tab index.
|
||||
* @return the run for a tab
|
||||
*/
|
||||
protected int getRunForTab(int tabCount, int tabIndex) {
|
||||
for (int i = 0; i < runCount; i++) {
|
||||
int first = tabRuns[i];
|
||||
@ -1668,6 +1870,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last tab in a run.
|
||||
* @param tabCount the tab count
|
||||
* @param run the run
|
||||
* @return the last tab in a run
|
||||
*/
|
||||
protected int lastTabInRun(int tabCount, int run) {
|
||||
if (runCount == 1) {
|
||||
return tabCount - 1;
|
||||
@ -1679,22 +1887,49 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return tabRuns[nextRun]-1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tab run overlay.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @return the tab run overlay
|
||||
*/
|
||||
protected int getTabRunOverlay(int tabPlacement) {
|
||||
return tabRunOverlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tab run indent.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param run the tab run
|
||||
* @return the tab run indent
|
||||
*/
|
||||
protected int getTabRunIndent(int tabPlacement, int run) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the tab run should be padded.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param run the tab run
|
||||
* @return whether or not the tab run should be padded
|
||||
*/
|
||||
protected boolean shouldPadTabRun(int tabPlacement, int run) {
|
||||
return runCount > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the tab run should be rotated.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @return whether or not the tab run should be rotated
|
||||
*/
|
||||
protected boolean shouldRotateTabRuns(int tabPlacement) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon for a tab.
|
||||
* @param tabIndex the index of the tab
|
||||
* @return the icon for a tab
|
||||
*/
|
||||
protected Icon getIconForTab(int tabIndex) {
|
||||
return (!tabPane.isEnabled() || !tabPane.isEnabledAt(tabIndex))?
|
||||
tabPane.getDisabledIconAt(tabIndex) : tabPane.getIconAt(tabIndex);
|
||||
@ -1718,6 +1953,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the tab height.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param tabIndex the index of the tab with respect to other tabs
|
||||
* @param fontHeight the font height
|
||||
* @return the tab height
|
||||
*/
|
||||
protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) {
|
||||
int height = 0;
|
||||
Component c = tabPane.getTabComponentAt(tabIndex);
|
||||
@ -1743,6 +1985,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the maximum tab height.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @return the maximum tab height
|
||||
*/
|
||||
protected int calculateMaxTabHeight(int tabPlacement) {
|
||||
FontMetrics metrics = getFontMetrics();
|
||||
int tabCount = tabPane.getTabCount();
|
||||
@ -1754,6 +2001,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the tab width.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param tabIndex the index of the tab with respect to other tabs
|
||||
* @param metrics the font metrics
|
||||
* @return the tab width
|
||||
*/
|
||||
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
|
||||
Insets tabInsets = getTabInsets(tabPlacement, tabIndex);
|
||||
int width = tabInsets.left + tabInsets.right + 3;
|
||||
@ -1778,6 +2032,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the maximum tab width.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @return the maximum tab width
|
||||
*/
|
||||
protected int calculateMaxTabWidth(int tabPlacement) {
|
||||
FontMetrics metrics = getFontMetrics();
|
||||
int tabCount = tabPane.getTabCount();
|
||||
@ -1788,6 +2047,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the tab area height.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param horizRunCount horizontal run count
|
||||
* @param maxTabHeight maximum tab height
|
||||
* @return the tab area height
|
||||
*/
|
||||
protected int calculateTabAreaHeight(int tabPlacement, int horizRunCount, int maxTabHeight) {
|
||||
Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
|
||||
int tabRunOverlay = getTabRunOverlay(tabPlacement);
|
||||
@ -1797,6 +2063,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the tab area width.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param vertRunCount vertical run count
|
||||
* @param maxTabWidth maximum tab width
|
||||
* @return the tab area width
|
||||
*/
|
||||
protected int calculateTabAreaWidth(int tabPlacement, int vertRunCount, int maxTabWidth) {
|
||||
Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
|
||||
int tabRunOverlay = getTabRunOverlay(tabPlacement);
|
||||
@ -1806,24 +2079,49 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tab insets.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param tabIndex the tab index
|
||||
* @return the tab insets
|
||||
*/
|
||||
protected Insets getTabInsets(int tabPlacement, int tabIndex) {
|
||||
return tabInsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selected tab pad insets.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @return the selected tab pad insets
|
||||
*/
|
||||
protected Insets getSelectedTabPadInsets(int tabPlacement) {
|
||||
rotateInsets(selectedTabPadInsets, currentPadInsets, tabPlacement);
|
||||
return currentPadInsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tab area insets.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @return the pad area insets
|
||||
*/
|
||||
protected Insets getTabAreaInsets(int tabPlacement) {
|
||||
rotateInsets(tabAreaInsets, currentTabAreaInsets, tabPlacement);
|
||||
return currentTabAreaInsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content border insets.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @return the content border insets
|
||||
*/
|
||||
protected Insets getContentBorderInsets(int tabPlacement) {
|
||||
return contentBorderInsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font metrics.
|
||||
* @return the font metrics
|
||||
*/
|
||||
protected FontMetrics getFontMetrics() {
|
||||
Font font = tabPane.getFont();
|
||||
return tabPane.getFontMetrics(font);
|
||||
@ -1832,6 +2130,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
|
||||
// Tab Navigation methods
|
||||
|
||||
/**
|
||||
* Navigate the selected tab.
|
||||
* @param direction the direction
|
||||
*/
|
||||
protected void navigateSelectedTab(int direction) {
|
||||
int tabPlacement = tabPane.getTabPlacement();
|
||||
int current = DefaultLookup.getBoolean(tabPane, this,
|
||||
@ -1910,6 +2212,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the next tab in the run.
|
||||
* @param current the current tab
|
||||
*/
|
||||
protected void selectNextTabInRun(int current) {
|
||||
int tabCount = tabPane.getTabCount();
|
||||
int tabIndex = getNextTabIndexInRun(tabCount, current);
|
||||
@ -1920,6 +2226,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
navigateTo(tabIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the previous tab in the run.
|
||||
* @param current the current tab
|
||||
*/
|
||||
protected void selectPreviousTabInRun(int current) {
|
||||
int tabCount = tabPane.getTabCount();
|
||||
int tabIndex = getPreviousTabIndexInRun(tabCount, current);
|
||||
@ -1930,6 +2240,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
navigateTo(tabIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the next tab.
|
||||
* @param current the current tab
|
||||
*/
|
||||
protected void selectNextTab(int current) {
|
||||
int tabIndex = getNextTabIndex(current);
|
||||
|
||||
@ -1939,6 +2253,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
navigateTo(tabIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the previous tab.
|
||||
* @param current the current tab
|
||||
*/
|
||||
protected void selectPreviousTab(int current) {
|
||||
int tabIndex = getPreviousTabIndex(current);
|
||||
|
||||
@ -1948,6 +2266,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
navigateTo(tabIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects an adjacent run of tabs.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param tabIndex the index of the tab with respect to other tabs
|
||||
* @param offset selection offset
|
||||
*/
|
||||
protected void selectAdjacentRunTab(int tabPlacement,
|
||||
int tabIndex, int offset) {
|
||||
if ( runCount < 2 ) {
|
||||
@ -2026,6 +2350,14 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return focusIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tab run offset.
|
||||
* @param tabPlacement the placement (left, right, bottom, top) of the tab
|
||||
* @param tabCount the tab count
|
||||
* @param tabIndex the index of the tab with respect to other tabs
|
||||
* @param forward forward or not
|
||||
* @return the tab run offset
|
||||
*/
|
||||
protected int getTabRunOffset(int tabPlacement, int tabCount,
|
||||
int tabIndex, boolean forward) {
|
||||
int run = getRunForTab(tabCount, tabIndex);
|
||||
@ -2092,15 +2424,31 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the previous tab index.
|
||||
* @param base the base
|
||||
* @return the previous tab index
|
||||
*/
|
||||
protected int getPreviousTabIndex(int base) {
|
||||
int tabIndex = (base - 1 >= 0? base - 1 : tabPane.getTabCount() - 1);
|
||||
return (tabIndex >= 0? tabIndex : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next tab index.
|
||||
* @param base the base
|
||||
* @return the next tab index
|
||||
*/
|
||||
protected int getNextTabIndex(int base) {
|
||||
return (base+1)%tabPane.getTabCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next tab index in the run.
|
||||
* @param tabCount the tab count
|
||||
* @param base the base
|
||||
* @return the next tab index in the run
|
||||
*/
|
||||
protected int getNextTabIndexInRun(int tabCount, int base) {
|
||||
if (runCount < 2) {
|
||||
return getNextTabIndex(base);
|
||||
@ -2113,6 +2461,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the previous tab index in the run.
|
||||
* @param tabCount the tab count
|
||||
* @param base the base
|
||||
* @return the previous tab index in the run
|
||||
*/
|
||||
protected int getPreviousTabIndexInRun(int tabCount, int base) {
|
||||
if (runCount < 2) {
|
||||
return getPreviousTabIndex(base);
|
||||
@ -2125,15 +2479,31 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return getPreviousTabIndex(base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the previous tab run.
|
||||
* @param baseRun the base run
|
||||
* @return the previous tab run
|
||||
*/
|
||||
protected int getPreviousTabRun(int baseRun) {
|
||||
int runIndex = (baseRun - 1 >= 0? baseRun - 1 : runCount - 1);
|
||||
return (runIndex >= 0? runIndex : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next tab run.
|
||||
* @param baseRun the base run
|
||||
* @return the next tab run
|
||||
*/
|
||||
protected int getNextTabRun(int baseRun) {
|
||||
return (baseRun+1)%runCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the insets.
|
||||
* @param topInsets the top insets
|
||||
* @param targetInsets the target insets
|
||||
* @param targetPlacement the target placement
|
||||
*/
|
||||
protected static void rotateInsets(Insets topInsets, Insets targetInsets, int targetPlacement) {
|
||||
|
||||
switch(targetPlacement) {
|
||||
@ -2292,6 +2662,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return calculateSize(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the calculated size.
|
||||
* @param minimum use the minimum size or preferred size
|
||||
* @return the calculated size
|
||||
*/
|
||||
protected Dimension calculateSize(boolean minimum) {
|
||||
int tabPlacement = tabPane.getTabPlacement();
|
||||
Insets insets = tabPane.getInsets();
|
||||
@ -2346,6 +2721,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred tab area height.
|
||||
* @param tabPlacement the tab placement
|
||||
* @param width the width
|
||||
* @return the preferred tab area height
|
||||
*/
|
||||
protected int preferredTabAreaHeight(int tabPlacement, int width) {
|
||||
FontMetrics metrics = getFontMetrics();
|
||||
int tabCount = tabPane.getTabCount();
|
||||
@ -2370,6 +2751,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred tab area width.
|
||||
* @param tabPlacement the tab placement
|
||||
* @param height the height
|
||||
* @return the preferred tab area widty
|
||||
*/
|
||||
protected int preferredTabAreaWidth(int tabPlacement, int height) {
|
||||
FontMetrics metrics = getFontMetrics();
|
||||
int tabCount = tabPane.getTabCount();
|
||||
@ -2395,6 +2782,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
return total;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@SuppressWarnings("deprecation")
|
||||
public void layoutContainer(Container parent) {
|
||||
/* Some of the code in this method deals with changing the
|
||||
@ -2517,6 +2905,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the layout info.
|
||||
*/
|
||||
public void calculateLayoutInfo() {
|
||||
int tabCount = tabPane.getTabCount();
|
||||
assureRectsCreated(tabCount);
|
||||
@ -2556,6 +2947,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the tab rectangles.
|
||||
* @param tabPlacement the tab placement
|
||||
* @param tabCount the tab count
|
||||
*/
|
||||
protected void calculateTabRects(int tabPlacement, int tabCount) {
|
||||
FontMetrics metrics = getFontMetrics();
|
||||
Dimension size = tabPane.getSize();
|
||||
@ -2741,9 +3137,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Rotates the run-index array so that the selected run is run[0]
|
||||
*/
|
||||
/**
|
||||
* Rotates the run-index array so that the selected run is run[0].
|
||||
* @param tabPlacement the tab placement
|
||||
* @param selectedRun the selected run
|
||||
*/
|
||||
protected void rotateTabRuns(int tabPlacement, int selectedRun) {
|
||||
for (int i = 0; i < selectedRun; i++) {
|
||||
int save = tabRuns[0];
|
||||
@ -2754,6 +3152,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the tab runs.
|
||||
* @param tabPlacement the tab placement
|
||||
* @param tabCount the tab count
|
||||
* @param start the start
|
||||
* @param max the max
|
||||
*/
|
||||
protected void normalizeTabRuns(int tabPlacement, int tabCount,
|
||||
int start, int max) {
|
||||
boolean verticalTabRuns = (tabPlacement == LEFT || tabPlacement == RIGHT);
|
||||
@ -2822,6 +3227,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pads the tab run.
|
||||
* @param tabPlacement the tab placement
|
||||
* @param start the start
|
||||
* @param end the end
|
||||
* @param max the max
|
||||
*/
|
||||
protected void padTabRun(int tabPlacement, int start, int end, int max) {
|
||||
Rectangle lastRect = rects[end];
|
||||
if (tabPlacement == TOP || tabPlacement == BOTTOM) {
|
||||
@ -2853,6 +3265,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pads selected tab.
|
||||
* @param tabPlacement the tab placement
|
||||
* @param selectedIndex the selected index
|
||||
*/
|
||||
protected void padSelectedTab(int tabPlacement, int selectedIndex) {
|
||||
|
||||
if (selectedIndex >= 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user