下面列出了javax.swing.JToolBar#setOrientation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void initUI() {
JPanel pLeft = new JPanel();
pLeft.setLayout(new BorderLayout(0, 0));
JToolBar toolBar1 = new JToolBar();
toolBar1.setFloatable(false);
toolBar1.setOrientation(SwingConstants.VERTICAL);
initToolBar1(toolBar1);
pLeft.add(toolBar1, BorderLayout.WEST);
left = createContactsUI();
left.onLoadContacts(false);
pLeft.add(left, BorderLayout.CENTER);
setLeftComponent(pLeft);
JPanel pRight = new JPanel();
pRight.setLayout(new BorderLayout(0, 0));
tabbedChat = new ClosableTabHost(this);
pRight.add(tabbedChat, BorderLayout.CENTER);
setRightComponent(pRight);
setResizeWeight(0.3);
setDividerLocation(250);
}
protected void initComponents() {
setLayout(new BorderLayout());
actionBar = new JToolBar();
actionBar.setOrientation(JToolBar.VERTICAL);
actionBar.setLayout(new BoxLayout(actionBar, BoxLayout.Y_AXIS));
actionBar.setFloatable(false);
fixSize(actionBar);
add(actionBar, BorderLayout.WEST);
// Make actionBar initially invisible. setButtons will make it visible
// if actions are defined.
// This will prevent 'blinking' of the toolbar (see IZ 233206)
actionBar.setVisible(false);
findBar = new FindBar(new FindBar.Owner() {
@Override
public void close(FindBar fb) {
findBar.getState().setVisible(false);
// OLD TerminalContainerImpl.super.remove(findBar);
componentRemove(findBar);
validate();
requestFocus();
}
});
}
public static JToolBar createToolbar() {
JToolBar toolbar = new JToolBar();
toolbar.setBorder(new LineBorder(Color.BLACK, 2));
toolbar.setFloatable(false);
toolbar.setOrientation(SwingConstants.VERTICAL);
toolbar.setBackground(UI.BACKGROUND);
return toolbar;
}
public static JToolBar createToolbar() {
JToolBar toolbar = new JToolBar();
toolbar.setBorder(new LineBorder(Color.BLACK, 2));
toolbar.setFloatable(false);
toolbar.setOrientation(SwingConstants.VERTICAL);
toolbar.setBackground(UI.BACKGROUND);
return toolbar;
}
private void initToolBar() {
toolBar = new JToolBar();
toolBar.setOrientation(JToolBar.HORIZONTAL);
toolBar.setFloatable(false);
toolBar.setPreferredSize(new Dimension(getWidth(), 40));
manuallyLoadData = new JButton();
manuallyLoadData.setIcon(Utils.createImageIcon("images/loaddata.png", "Load Data"));
manuallyLoadData.setToolTipText("Manually locate the chrome data files folder.");
toolBar.add(manuallyLoadData);
autoLoadData = new JButton();
autoLoadData.setIcon(Utils.createImageIcon("images/autosearch.png", "Auto Search and Load Data"));
autoLoadData.setToolTipText("Automatically search and load chrome files.");
toolBar.add(autoLoadData);
toolBar.add(new JToolBar.Separator());
exportTSV = new JButton("Export to");
exportTSV.setIcon(Utils.createImageIcon("images/csv.png", "Export results to CSV"));
exportTSV.setToolTipText("Export Results to CSV");
exportTSV.setHorizontalTextPosition(SwingConstants.LEFT);
exportTSV.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
ExportDialog export = new ExportDialog(ExportType.TSV);
export.setVisible(true);
}
});
toolBar.add(exportTSV);
exportHTML = new JButton("Export to");
exportHTML.setIcon(Utils.createImageIcon("images/html.png", "Export results to HTML"));
exportHTML.setToolTipText("Export results to HTML.");
exportHTML.setHorizontalTextPosition(SwingConstants.LEFT);
toolBar.add(exportHTML);
toolBar.add(new JToolBar.Separator());
helpButton = new JButton();
helpButton.setIcon(Utils.createImageIcon("images/help.png", "Need Help? Click Me!"));
helpButton.setToolTipText("Need Help? Click Me!");
toolBar.add(helpButton);
aboutButton = new JButton();
aboutButton.setIcon(Utils.createImageIcon("images/about.png", "About this tool!"));
aboutButton.setToolTipText("About this tool!");
toolBar.add(aboutButton);
toolBar.add(new JToolBar.Separator());
exitButton = new JButton();
exitButton.setIcon(Utils.createImageIcon("images/exit.png", "Exit Application."));
exitButton.setToolTipText("Exit Application");
exitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
ChromeForensicsGui.getInstance().dispose();
}
});
toolBar.add(exitButton);
}
@SuppressWarnings("unchecked")
private void createToolBar() {
final JButton zoomIn = new JButton(Icon("zoom-in-2.png"));
final JButton zoomOut = new JButton(Icon("zoom-out-2.png"));
final JButton resize = new JButton(Icon("transform-scale-2.png"));
final JButton rotateLeft = new JButton(Icon("object-rotate-left-2.png"));
final JButton mirrorX = new JButton(Icon("mirror_x.png"));
final JButton mirrorY = new JButton(Icon("mirror_y.png"));
JToolBar toolbar1 = new JToolBar();
toolbar1.add(zoomIn);
toolbar1.add(zoomOut);
toolbar1.addSeparator();
toolbar1.add(resize);
toolbar1.add(rotateLeft);
toolbar1.add(mirrorX);
toolbar1.add(mirrorY);
toolbar1.setFloatable(false);
topContainer.add(toolbar1, BorderLayout.CENTER);
final ButtonGroup toolsGroup = new ButtonGroup();
final JToggleButton colorPicker = new JToggleButton(Icon("color-picker.png"));
final JToggleButton imageCrop = new JToggleButton(Icon("transform-crop.png"));
toolsGroup.add(colorPicker);
toolsGroup.add(imageCrop);
JToolBar toolbar2 = new JToolBar();
toolbar2.setOrientation(JToolBar.VERTICAL);
toolbar2.setFloatable(false);
toolbar2.add(colorPicker);
toolbar2.add(imageCrop);
COMPONENT.add(toolbar2, BorderLayout.WEST);
ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == zoomIn) {
setScaleFactor(getScaleFactor() + 0.1f);
} else if (source == zoomOut) {
setScaleFactor(getScaleFactor() - 0.1f);
} else if (source == resize) {
querySizeAndResize();
} else if (source == rotateLeft) {
editedImage = RotateLeftFilter.create().filter(editedImage);
resizeDisplay();
enableSaving();
} else if (source == mirrorX) {
editedImage = MirrorFilter.create().filter(editedImage, MirrorFilter.X);
resizeDisplay();
enableSaving();
} else if (source == mirrorY) {
editedImage = MirrorFilter.create().filter(editedImage, MirrorFilter.Y);
resizeDisplay();
enableSaving();
} else if (source == colorPicker) {
setCurrentTool(ColorPicker.create());
} else if (source == imageCrop) {
setCurrentTool(CropTool.create());
}
}
};
for (AbstractButton b : Arrays.asList(zoomIn, zoomOut, resize, /*save, saveAs,*/
rotateLeft, mirrorX, mirrorY, colorPicker, imageCrop)) {
b.addActionListener(al);
}
}
protected void setupInstance(JToolBar instance) {
super.setupInstance(instance);
instance.setBorderPainted(paintBorder);
if (margin != null) instance.setMargin(margin.createInstance());
instance.setFloatable(floatable);
instance.setOrientation(orientation);
}
protected void setupInstance(JToolBar instance) {
super.setupInstance(instance);
instance.setBorderPainted(paintBorder);
if (margin != null) instance.setMargin(margin.createInstance());
instance.setFloatable(floatable);
instance.setOrientation(orientation);
}
/**
* Inserts the specified toolbar into this boundary at the provided indices.
* Subclasses generally should not override this method, but may provide
* more detailed behavior by overriding the toolBarAdded() callback method
* instead.
*/
public void addToolBar(final JToolBar toolbar, final int rowIndex, final int index) {
toolbar.setOrientation(ourOrientation);
ourToolBars.add(toolbar);
toolBarAdded(toolbar, rowIndex, index);
}