Removing ToolBarLayout because it's stupid. Default JToolBar layout works just fine and even if it doesn't, just use a GridBagLayout.

This commit is contained in:
rj.keller%beonex.com 2005-05-09 20:42:13 +00:00
Родитель 3cc490ab39
Коммит 61c9bf53f3
9 изменённых файлов: 2 добавлений и 227 удалений

Просмотреть файл

@ -95,18 +95,13 @@ public class Composition extends GeneralFrame {
fToolBar = mCompositionPanel.getToolBar();
fToolBar.add(fToolBar.makeNewSpring());
// fToolBar.addItem(ToolbarFactory.MakeINSToolbarItem(ToolBarLayout.CreateSpring(),
// null));
// fToolBar.addItem(ToolbarFactory.MakeINSToolbarItem(fAnimation, null));
mAddressBar = mCompositionPanel.getAddressBar();
//top collapsible item
fToolBarPanelConstraints.anchor = GridBagConstraints.WEST;
fToolBarPanelConstraints.fill = GridBagConstraints.HORIZONTAL;
// fToolBarPanelConstraints.weightx = 1.0;
fToolBarPanel.add(fToolBar, fToolBarPanelConstraints);
fToolBarPanel.setComponent(fToolBar);
fToolBarPanelConstraints.anchor = GridBagConstraints.EAST;
fToolBarPanelConstraints.fill = GridBagConstraints.NONE;
fToolBarPanelConstraints.weightx = 1.0;

Просмотреть файл

@ -62,9 +62,6 @@ public class FolderFrame extends GeneralFrame {
getRootPane().setJMenuBar(fMenu);
fToolBar = fFolderPanel.getToolBar();
// fToolBar.addItem(ToolbarFactory.MakeINSToolbarItem(ToolBarLayout.CreateSpring(),
// null));
// fToolBar.addItem(ToolbarFactory.MakeINSToolbarItem(fAnimation, null));
fToolBarPanel.setComponent(fToolBar);
fStatusBar = buildStatusBar();

Просмотреть файл

@ -76,7 +76,6 @@ import javax.swing.UIManager;
import javax.swing.BoxLayout;
import grendel.prefs.base.InvisiblePrefs;
import grendel.ui.ToolBarLayout;
import grendel.widgets.*;
public class GeneralFrame extends JFrame
@ -89,7 +88,6 @@ public class GeneralFrame extends JFrame
protected Animation fAnimation;
protected JMenuBar fMenu;
protected CollapsiblePanel fToolBarPanel;
protected GridBagLayout fToolBarPanelLayout;
protected GridBagConstraints fToolBarPanelConstraints;
protected GrendelToolBar fToolBar;
protected Component fStatusBar;
@ -136,7 +134,6 @@ public class GeneralFrame extends JFrame
30);
fToolBarPanel = new CollapsiblePanel(true);
fToolBarPanelLayout = new ToolBarLayout();
fToolBarPanelConstraints = new GridBagConstraints();
fPanel.add(fToolBarPanel, BorderLayout.NORTH);
// fUIManager = new netscape.orion.uimanager.UIManager(fToolBarPanel);

Просмотреть файл

@ -27,8 +27,6 @@
package grendel.ui;
import grendel.ui.ToolBarLayout;
import grendel.widgets.GrendelToolBar;
import java.awt.BorderLayout;
@ -84,7 +82,6 @@ public class GeneralPanel extends JPanel {
try {
res = new GrendelToolBar();
// res.setLayout(new ToolBarLayout());
ResourceBundle toolbarresources = ResourceBundle.getBundle(fResourceBase + ".Toolbar");
ResourceBundle menuresources = ResourceBundle.getBundle(fResourceBase + ".Menus");

Просмотреть файл

@ -61,9 +61,6 @@ public class MessageFrame extends GeneralFrame {
getRootPane().setJMenuBar(fMenu);
fToolBar = fMessagePanel.getToolBar();
// fToolBar.addItem(ToolbarFactory.MakeINSToolbarItem(ToolBarLayout.CreateSpring(),
// null));
// fToolBar.addItem(ToolbarFactory.MakeINSToolbarItem(fAnimation, null));
fToolBarPanel.setComponent(fToolBar);
fStatusBar = buildStatusBar();

Просмотреть файл

Просмотреть файл

@ -49,7 +49,6 @@ import javax.swing.JScrollPane;
//import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import grendel.ui.ToolBarLayout;
import grendel.widgets.GrendelToolBar;
import com.trfenv.parsers.Event;
@ -141,7 +140,6 @@ public class Util {
static public GrendelToolBar MergeToolBars(GrendelToolBar aBar1, GrendelToolBar aBar2) {
GrendelToolBar res = new GrendelToolBar();
res.setLayout(new ToolBarLayout());
Component barArray1[] = aBar1.getComponents();
Component barArray2[] = aBar2.getComponents();

Просмотреть файл

@ -1,200 +0,0 @@
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This file has been contributed to Mozilla.
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Grendel mail/news client.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1997 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* R.J. Keller <rj.keller@beonex.com>
*
* Created: Jeff Galyan <jeffrey.galyan@sun.com>, 30 Dec 1998
*/
package grendel.widgets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.BorderLayout;
import javax.swing.Box;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.plaf.metal.MetalIconFactory;
import javax.swing.ImageIcon;
import grendel.ui.ToolBarLayout;
import grendel.widgets.Collapsible;
import grendel.widgets.Spring;
/**
* This is an implementation of the grendel.widgets.Collapsible interface,
* which provides the standard Communicator-style collapsing toolbar panel.
*
* @author Jeff Galyan
* @author R.J. Keller
* @see Collapsible
*/
public class CollapsiblePanel extends JPanel implements Collapsible {
private static final int VERTICAL = 0;
private static final int HORIZONTAL = 1;
private boolean collapsed = false;
private Component curComponent;
/**
* Constructor
*/
public CollapsiblePanel(boolean isDoubleBuffered) {
super(isDoubleBuffered);
setLayout(new BorderLayout());
collapsed = false;
}
/**
*Sets the component that is to be collapsed and uncollapsed. Only one
*component can be shown in this panel at one time. For multiple components,
*add them all to a JPanel. Since this is usually for toolbars only, it
*shouldn't be an issue.
*/
public void setComponent(Component comp) {
curComponent = comp;
removeAll();
CollapseButton collapseButton = new CollapseButton(VERTICAL);
add(collapseButton, BorderLayout.WEST);
Dimension dim = collapseButton.getSize();
collapseButton.reshape(0,0,dim.width,dim.height);
//set the new components background to the panel background.
setBackground(comp.getBackground());
add(comp, BorderLayout.CENTER);
revalidate();
}
public Component getComponent() {
return curComponent;
}
/**
* Collapses the panel.
*/
public void collapse() {
removeAll();
add(new CollapseButton(HORIZONTAL), BorderLayout.WEST);
Dimension dim2 = getSize();
setSize(new Dimension(dim2.width, 5));
add(new Spring(), BorderLayout.CENTER);
revalidate();
collapsed = true;
}
/**
* Uncollapses the panel.
*/
public void expand() {
removeAll();
add(new CollapseButton(VERTICAL), BorderLayout.WEST);
add(curComponent, BorderLayout.CENTER);
revalidate();
collapsed = false;
}
/**
* Tells you whether this component is collapsible.
* @returns a boolean indicating this component is collapsible.
*/
public boolean isCollapsible() {
return collapsible;
}
/**
* Tells you whether this component is currently collapsed.
* Useful for checking the component's status.
* @returns true if this component is collapsed, false if it is not.
*/
public boolean isCollapsed() {
return collapsed;
}
class CollapseListener implements ActionListener {
public void actionPerformed(ActionEvent evt) {
if (isCollapsed() == true) {
expand();
} else {
collapse();
}
}
}
class CollapseButton extends JButton {
private ImageIcon collapseButtonIconVertical = new ImageIcon("widgets/images/collapseButton-vertical.gif", "regular collapseButton icon");
private ImageIcon collapseButtonVerticalRollover = new ImageIcon("widgets/images/collapseButton-vertical-rollover.gif", "vertical rollover icon");
private ImageIcon collapseButtonVerticalPressed = new ImageIcon("widgets/images/collapseButton-vertical-pressed.gif", "vertical pressed icon");
private ImageIcon collapseButtonIconHorizontal = new ImageIcon("widgets/images/collapseButton-horizontal.gif", "horizontal normal icon");
private ImageIcon collapseButtonHorizontalRollover = new ImageIcon("widgets/images/collapseButton-horizontal-rollover.gif", "horizontal rollover icon");
private ImageIcon collapseButtonHorizontalPressed = new ImageIcon("widgets/images/collapseButton-horizontal-pressed.gif", "horizontal pressed icon");
final int VERTICAL = 0;
final int HORIZONTAL = 1;
public CollapseButton(int orientation) {
super();
setRolloverEnabled(true);
setFocusPainted(false);
setDefaultCapable(false);
setBorder(null);
setBorderPainted(false);
setMargin(new Insets(0,0,0,0));
setToolTipText("Collapses/Expands the ToolBar");
if (orientation == VERTICAL) {
setIcon(collapseButtonIconVertical);
setRolloverIcon(collapseButtonVerticalRollover);
setPressedIcon(collapseButtonVerticalPressed);
} else {
setIcon(collapseButtonIconHorizontal);
setRolloverIcon(collapseButtonHorizontalRollover);
setPressedIcon(collapseButtonHorizontalPressed);
}
addActionListener(new CollapseListener());
}
}
}

Просмотреть файл

@ -34,27 +34,21 @@ import javax.swing.ImageIcon;
import javax.swing.JToolBar;
import javax.swing.JButton;
import grendel.ui.ToolBarLayout;
import grendel.widgets.Spring;
import com.trfenv.parsers.Event;
public class GrendelToolBar extends JToolBar {
private ToolBarLayout layout;
public GrendelToolBar() {
super();
layout = new ToolBarLayout();
setLayout(layout);
setFloatable(false);
setBackground(new java.awt.Color(238,238,238));
}
public Spring makeNewSpring() {
return layout.createSpring();
return new Spring();
}
public void addButton(Event aActionListener,