📄 skintitlepane.java
字号:
}
/**
* Description of the Method
*
* @param b Description of Parameter
* @return Description of the Returned Value
*/
protected PropertyChangeListener createActionChangeListener(AbstractButton b) {
return new ActionChangedListener(b);
}
// end TitlePaneLayout
/**
* Description of the Method
*
* @param b Description of Parameter
* @param a Description of Parameter
*/
private void registerButtonForAction(AbstractButton b, Action a) {
PropertyChangeListener actionPropertyChangeListener =
createActionChangeListener(b);
a.addPropertyChangeListener(actionPropertyChangeListener);
b.setEnabled(a.isEnabled());
}
/**
* Description of the Class
*
* @author fred
*/
public class PropertyChangeHandler implements PropertyChangeListener {
/**
* Description of the Method
*
* @param evt Description of Parameter
*/
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) {
updateButtons();
repaint();
return;
}
enableActions();
revalidate();
repaint();
}
}
/**
* Description of the Class
*
* @author fred
*/
public class TitlePaneLayout implements LayoutManager {
/**
* Adds a feature to the LayoutComponent attribute of the TitlePaneLayout
* object
*
* @param name The feature to be added to the LayoutComponent attribute
* @param c The feature to be added to the LayoutComponent attribute
*/
public void addLayoutComponent(String name, Component c) {
}
/**
* Description of the Method
*
* @param c Description of Parameter
*/
public void removeLayoutComponent(Component c) {
}
/**
* Description of the Method
*
* @param c Description of Parameter
* @return Description of the Returned Value
*/
public Dimension preferredLayoutSize(Container c) {
return new Dimension(100, 18);
}
/**
* Description of the Method
*
* @param c Description of Parameter
* @return Description of the Returned Value
*/
public Dimension minimumLayoutSize(Container c) {
return preferredLayoutSize(c);
}
/**
* Description of the Method
*
* @param c Description of Parameter
*/
public void layoutContainer(Container c) {
int w = getWidth();
int nmembers = c.getComponentCount();
int atlX = 2;
int atrX = 0;
menuBar.setBounds(atlX, (getHeight() - 16) / 2, 16, 16);
atlX += 18;
for (int i = 1
/*
* skip menubar
*/
; i < nmembers; i++) {
SkinWindowButton m = (SkinWindowButton) c.getComponent(i);
m.setSelected(m_Window.isSelected());
// only adjust the system buttons.
boolean userDefinedAction =(m.getWindowAction()==SkinTitlePane.NO_ACTION);
if (!userDefinedAction)
m.setVisible(m.isEnabled());
if (m.isEnabled() || userDefinedAction) {
if (m.getAlign() == ALIGN_TOP_LEFT) {
if (m.getXCoord() == -1) {
m.setLocation(atlX, Math.max(m.getYCoord(), 1));
atlX += m.getWidth();
}
else {
m.setLocation(m.getXCoord(), m.getYCoord());
}
}
else if (m.getAlign() == ALIGN_TOP_RIGHT) {
if (m.getXCoord() == -1) {
m.setLocation(w - atrX - m.getWidth(), Math.max(m.getYCoord(), 1));
atrX += m.getWidth();
}
else {
m.setLocation(w - m.getXCoord(), m.getYCoord());
}
}
}
}
}
}
/**
* This inner class is marked "public" due to a compiler bug. This
* class should be treated as a "protected" inner class. Instantiate
* it only within subclasses of <Foo>.
*
* @author fred
*/
public class CloseAction extends AbstractAction {
/**
* Constructor for the CloseAction object
*/
public CloseAction() {
super("Close");
}
/**
* Description of the Method
*
* @param e Description of Parameter
*/
public void actionPerformed(ActionEvent e) {
if (m_Window.isClosable()) {
try {
m_Window.setClosed(true);
} catch (PropertyVetoException e0) {
}
}
}
}
// end CloseAction
/**
* This inner class is marked "public" due to a compiler bug. This
* class should be treated as a "protected" inner class. Instantiate
* it only within subclasses of <Foo>.
*
* @author fred
*/
public class MaximizeAction extends AbstractAction {
/**
* Constructor for the MaximizeAction object
*/
public MaximizeAction() {
super("Maximize");
}
/**
* Description of the Method
*
* @param e Description of Parameter
*/
public void actionPerformed(ActionEvent e) {
if (m_Window.isMaximizable()) {
if (!m_Window.isMaximum()) {
try {
m_Window.setMaximum(true);
} catch (PropertyVetoException e5) {
}
}
else {
try {
m_Window.setMaximum(false);
if (m_Window.isIconifiable() && m_Window.isIcon()) {
m_Window.setIcon(false);
}
} catch (PropertyVetoException e6) {
}
}
}
}
}
// MaximizeAction
/**
* This inner class is marked "public" due to a compiler bug. This
* class should be treated as a "protected" inner class. Instantiate
* it only within subclasses of <Foo>.
*
* @author fred
* @created 27 avril 2002
*/
public class IconifyAction extends AbstractAction {
/**
* Constructor for the IconifyAction object
*/
public IconifyAction() {
super("Minimize");
}
/**
* Description of the Method
*
* @param e Description of Parameter
*/
public void actionPerformed(ActionEvent e) {
if (m_Window.isIconifiable()) {
if (!m_Window.isIcon()) {
try {
m_Window.setIcon(true);
} catch (PropertyVetoException e1) {
}
}
else {
try {
m_Window.setIcon(false);
if (m_Window.isMaximizable() && m_Window.isMaximum()) {
m_Window.setMaximum(false);
}
} catch (PropertyVetoException e1) {
}
}
}
}
}
// end IconifyAction
/**
* This inner class is marked "public" due to a compiler bug. This
* class should be treated as a "protected" inner class. Instantiate
* it only within subclasses of <Foo>.
*
* @author fred
* @created 27 avril 2002
*/
public class RestoreAction extends AbstractAction {
/**
* Constructor for the RestoreAction object
*/
public RestoreAction() {
super("Restore");
}
/**
* Description of the Method
*
* @param e Description of Parameter
*/
public void actionPerformed(ActionEvent e) {
if (m_Window.isMaximizable() && m_Window.isMaximum()) {
try {
m_Window.setMaximum(false);
} catch (PropertyVetoException e4) {
}
}
else if (m_Window.isIconifiable() && m_Window.isIcon()) {
try {
m_Window.setIcon(false);
} catch (PropertyVetoException e4) {
}
}
}
}
// end RestoreAction
/**
* Description of the Class
*
* @author fred
* @created 27 avril 2002
*/
public class ShadeAction extends AbstractAction {
/**
* Constructor for the ShadeAction object
*/
public ShadeAction() {
super("Shade");
}
/**
* Description of the Method
*
* @param event Description of Parameter
*/
public void actionPerformed(ActionEvent event) {
m_Window.setShaded(!m_Window.isShaded());
}
}
/**
* This inner class is marked "public" due to a compiler bug. This
* class should be treated as a "protected" inner class. Instantiate
* it only within subclasses of <Foo>.
*
* @author fred
* @created 27 avril 2002
*/
public class SystemMenuBar extends JMenuBar {
/**
* Gets the FocusTraversable attribute of the SystemMenuBar object
*
* @return The FocusTraversable value
*/
public boolean isFocusTraversable() {
return false;
}
/**
* Gets the Opaque attribute of the SystemMenuBar object
*
* @return The Opaque value
*/
public boolean isOpaque() {
return true;
}
/**
* Description of the Method
*/
public void requestFocus() {
}
/**
* Description of the Method
*
* @param g Description of Parameter
*/
public void paint(Graphics g) {
Icon icon = m_Window.getFrameIcon();
if (icon == null) {
icon = UIManager.getIcon("InternalFrame.icon");
}
if (icon != null) {
// Resize to 16x16 if necessary.
if (icon instanceof ImageIcon && (icon.getIconWidth() > 16 || icon.getIconHeight() > 16)) {
Image img = ((ImageIcon) icon).getImage();
((ImageIcon) icon).setImage(img.getScaledInstance(16, 16, Image.SCALE_SMOOTH));
}
icon.paintIcon(this, g, 0, 0);
}
}
}
/**
* Description of the Class
*
* @author fred
* @created 27 avril 2002
*/
private class ActionChangedListener implements PropertyChangeListener {
AbstractButton button;
/**
* Constructor for the ActionChangedListener object
*
* @param b Description of Parameter
*/
ActionChangedListener(AbstractButton b) {
super();
setTarget(b);
}
/**
* Sets the Target attribute of the ActionChangedListener object
*
* @param b The new Target value
*/
public void setTarget(AbstractButton b) {
this.button = b;
}
/**
* Description of the Method
*
* @param e Description of Parameter
*/
public void propertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (e.getPropertyName().equals(Action.NAME)) {
String text = (String) e.getNewValue();
button.setText(text);
button.repaint();
}
else if (propertyName.equals("enabled")) {
Boolean enabledState = (Boolean) e.getNewValue();
button.setEnabled(enabledState.booleanValue());
button.repaint();
}
else if (e.getPropertyName().equals(Action.SMALL_ICON)) {
Icon icon = (Icon) e.getNewValue();
button.setIcon(icon);
button.invalidate();
button.repaint();
}
}
}
}
// End Title Pane Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -