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