View Javadoc
1 /* 2 * JScroll - the scrollable desktop pane for Java. 3 * Copyright (C) 2003 Tom Tessier 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 */ 20 21 package org.jscroll.widgets; 22 23 import javax.swing.JToggleButton; 24 25 import java.awt.*; 26 27 28 /*** 29 * This class creates a base toggle button. A 30 * {@link org.jscroll.widgets.JScrollInternalFrame JScrollInternalFrame} 31 * object is associated with every instance of this class. 32 * 33 * @author <a href="mailto:tessier@gabinternet.com">Tom Tessier</a> 34 * @version 1.0 11-Aug-2001 35 */ 36 public class RootToggleButton extends JToggleButton implements DesktopConstants, 37 FrameAccessorInterface { 38 private JScrollInternalFrame associatedFrame; 39 private Color defaultColor; 40 41 /*** 42 * creates the RootToggleButton 43 * 44 * @param title the title of the button 45 */ 46 public RootToggleButton(String title) { 47 super(title); 48 49 setButtonFormat(); 50 setToolTipText(title); 51 52 defaultColor = getForeground(); 53 } 54 55 private void setButtonFormat() { 56 Font buttonFont = getFont(); 57 setFont(new Font(buttonFont.getFontName(), buttonFont.getStyle(), 58 buttonFont.getSize() - 1)); 59 setMargin(new Insets(0, 0, 0, 0)); 60 } 61 62 /*** 63 * sets the associated frame 64 * 65 * @param associatedFrame the JScrollInternalFrame object to associate with 66 * the menu item 67 */ 68 public void setAssociatedFrame(JScrollInternalFrame associatedFrame) { 69 this.associatedFrame = associatedFrame; 70 } 71 72 /*** 73 * returns the associated frame 74 * 75 * @return the JScrollInternalFrame object associated with this menu item 76 */ 77 public JScrollInternalFrame getAssociatedFrame() { 78 return associatedFrame; 79 } 80 81 /*** 82 * flags the contents as "changed" by setting the foreground color to 83 * {@link 84 * org.jscroll.widgets.DesktopConstants#CONTENTS_CHANGED_COLOR 85 * CONTENTS_CHANGED_COLOR}. 86 * Used to notify the user when the contents of an inactive internal frame 87 * have changed. 88 * 89 * @param changed <code>boolean</code> indicating whether contents have 90 * changed 91 */ 92 public void flagContentsChanged(boolean changed) { 93 if (changed) { 94 setForeground(CONTENTS_CHANGED_COLOR); 95 } else { 96 setForeground(defaultColor); 97 } 98 } 99 }

This page was automatically generated by Maven