use of javax.swing.JToolBar in project archi by archimatetool.
the class SimpleSwingExample method start.
public void start() {
// $NON-NLS-1$
mainFrame = new JFrame("Simple Swing Layout Example");
toolBar = new JToolBar();
mainFrame.getContentPane().setLayout(new BorderLayout());
mainFrame.getContentPane().add(toolBar, BorderLayout.NORTH);
// $NON-NLS-1$
lblProgress = new JLabel("Progress: ");
mainFrame.getContentPane().add(lblProgress, BorderLayout.SOUTH);
createMainPanel();
mainFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
stop();
mainFrame.dispose();
}
});
// $NON-NLS-1$
btnContinuous = new JToggleButton("continuous", false);
// $NON-NLS-1$
btnAsynchronous = new JToggleButton("asynchronous", false);
toolBar.add(btnContinuous);
toolBar.add(btnAsynchronous);
// $NON-NLS-1$
btnStop = new JButton("Stop");
btnStop.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stop();
}
});
toolBar.add(btnStop);
// $NON-NLS-1$
JButton btnCreateGraph = new JButton("New graph");
btnCreateGraph.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stop();
createGraph(true);
}
});
toolBar.add(btnCreateGraph);
// $NON-NLS-1$
JButton btnCreateTree = new JButton("New tree");
btnCreateTree.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stop();
createGraph(false);
}
});
toolBar.add(btnCreateTree);
createGraph(false);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
mainFrame.setLocation((int) (screenSize.getWidth() - INITIAL_PANEL_WIDTH) / 2, (int) (screenSize.getHeight() - INITIAL_PANEL_HEIGHT) / 2);
mainFrame.pack();
mainFrame.setVisible(true);
mainFrame.repaint();
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
SPRING = new SpringLayoutAlgorithm(LayoutStyles.NONE);
TREE_VERT = new TreeLayoutAlgorithm(LayoutStyles.NONE);
TREE_HORIZ = new HorizontalTreeLayoutAlgorithm(LayoutStyles.NONE);
RADIAL = new RadialLayoutAlgorithm(LayoutStyles.NONE);
GRID = new GridLayoutAlgorithm(LayoutStyles.NONE);
HORIZ = new HorizontalLayoutAlgorithm(LayoutStyles.NONE);
VERT = new VerticalLayoutAlgorithm(LayoutStyles.NONE);
SPRING.setIterations(1000);
// initialize layouts
TREE_VERT.setComparator(new Comparator() {
@Override
public int compare(Object o1, Object o2) {
if (o1 instanceof Comparable && o2 instanceof Comparable) {
return ((Comparable) o1).compareTo(o2);
}
return 0;
}
});
GRID.setRowPadding(20);
// $NON-NLS-1$
addAlgorithm(SPRING, "Spring", false);
// $NON-NLS-1$
addAlgorithm(TREE_VERT, "Tree-V", false);
// $NON-NLS-1$
addAlgorithm(TREE_HORIZ, "Tree-H", false);
// $NON-NLS-1$
addAlgorithm(RADIAL, "Radial", false);
// $NON-NLS-1$
addAlgorithm(GRID, "Grid", false);
// $NON-NLS-1$
addAlgorithm(HORIZ, "Horiz", false);
// $NON-NLS-1$
addAlgorithm(VERT, "Vert", false);
for (int i = 0; i < algorithms.size(); i++) {
final LayoutAlgorithm algorithm = (LayoutAlgorithm) algorithms.get(i);
final String algorithmName = (String) algorithmNames.get(i);
// final boolean algorithmAnimate = ((Boolean)algorithmAnimates.get(i)).booleanValue();
JButton algorithmButton = new JButton(algorithmName);
algorithmButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
currentLayoutAlgorithm = algorithm;
currentLayoutAlgorithmName = algorithmName;
algorithm.setEntityAspectRatio((double) mainPanel.getWidth() / (double) mainPanel.getHeight());
// animate = algorithmAnimate;
performLayout();
}
});
toolBar.add(algorithmButton);
}
}
});
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InvocationTargetException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
use of javax.swing.JToolBar in project cytoscape-impl by cytoscape.
the class CytoscapeMenus method createViewFrameToolBar.
public JToolBar createViewFrameToolBar() {
JToolBar viewToolBar = null;
final int total = toolBar.getComponentCount();
boolean addSeparator = false;
int buttonsAfterSeparator = 0;
for (int i = 0; i < total; i++) {
final Component c = toolBar.getComponent(i);
if (c instanceof JButton && ((JButton) c).getAction() instanceof CyAction) {
final JButton btn = ((JButton) c);
final CyAction action = (CyAction) btn.getAction();
if (viewFrameActions.contains(action)) {
if (viewToolBar == null) {
viewToolBar = new JToolBar();
viewToolBar.setBorder(toolBar.getBorder());
}
if (addSeparator) {
viewToolBar.addSeparator();
addSeparator = false;
buttonsAfterSeparator = 0;
}
final JButton newBtn = CytoscapeToolBar.createToolBarButton(action);
viewToolBar.add(newBtn);
buttonsAfterSeparator++;
}
} else if (c instanceof JSeparator && buttonsAfterSeparator > 0) {
addSeparator = true;
}
}
if (viewToolBar != null && viewToolBar.getComponentCount() > 0 && viewToolBar.getComponentAtIndex(viewToolBar.getComponentCount() - 1) instanceof JSeparator)
viewToolBar.remove(viewToolBar.getComponentCount() - 1);
return viewToolBar;
}
use of javax.swing.JToolBar in project cytoscape-impl by cytoscape.
the class CytoscapeDesktop method setupStatusPanel.
private JToolBar setupStatusPanel(StatusBarPanelFactory jobStatusPanelFactory, StatusBarPanelFactory taskStatusPanelFactory) {
final JPanel taskStatusPanel = taskStatusPanelFactory.createTaskStatusPanel();
final JPanel jobStatusPanel = jobStatusPanelFactory.createTaskStatusPanel();
final JToolBar statusToolBar = new JToolBar();
final MemStatusPanel memStatusPanel = new MemStatusPanel();
if (LookAndFeelUtil.isNimbusLAF()) {
jobStatusPanel.setOpaque(false);
taskStatusPanel.setOpaque(false);
statusToolBar.setOpaque(false);
memStatusPanel.setOpaque(false);
}
final JPanel statusPanel = new JPanel();
statusPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIManager.getColor("Separator.foreground")));
final GroupLayout layout = new GroupLayout(statusPanel);
statusPanel.setLayout(layout);
layout.setAutoCreateContainerGaps(false);
layout.setAutoCreateGaps(false);
layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addComponent(jobStatusPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(taskStatusPanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(statusToolBar, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(memStatusPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addContainerGap());
layout.setVerticalGroup(layout.createSequentialGroup().addGap(LookAndFeelUtil.isWinLAF() ? 5 : 0).addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(jobStatusPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(taskStatusPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(statusToolBar, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(memStatusPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addGap(LookAndFeelUtil.isWinLAF() ? 5 : 0));
getMainPanel().add(statusPanel, BorderLayout.SOUTH);
return statusToolBar;
}
use of javax.swing.JToolBar in project Spark by igniterealtime.
the class CoBrowser method buildUI.
private void buildUI() {
if (!isShowing) {
update(getGraphics());
isShowing = true;
final JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
toolbar.add(backButton);
toolbar.add(urlField);
toolbar.add(goButton);
toolbar.setOpaque(false);
final BackgroundPane titlePanel = new BackgroundPane();
titlePanel.setLayout(new GridBagLayout());
JLabel cobrowsingLabel = new JLabel();
cobrowsingLabel.setText(FpRes.getString("cobrowsing.session"));
cobrowsingLabel.setFont(new Font("Dialog", Font.BOLD, 11));
titlePanel.add(cobrowsingLabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
titlePanel.add(pushCurrentPageButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0));
titlePanel.add(followMeButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0));
titlePanel.add(toolbar, new GridBagConstraints(0, 1, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 5, 0), 0, 0));
add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
updateLinkLabel(getStartLocation());
goButton.addActionListener(this);
backButton.addActionListener(this);
pushCurrentPageButton.addActionListener(this);
}
}
use of javax.swing.JToolBar in project beast2 by CompEvol.
the class ModelBuilder method makeToolbar.
void makeToolbar() {
m_jTbTools = new JToolBar();
m_jTbTools.setFloatable(false);
// m_jTbTools.setLayout(new GridBagLayout());
m_jTbTools.add(a_new);
m_jTbTools.add(a_save);
m_jTbTools.add(a_load);
m_jTbTools.addSeparator(new Dimension(2, 2));
m_jTbTools.add(a_cutnode);
m_jTbTools.add(a_copynode);
m_jTbTools.add(a_pastenode);
m_jTbTools.addSeparator(new Dimension(2, 2));
m_jTbTools.add(a_undo);
m_jTbTools.add(a_redo);
m_jTbTools.addSeparator(new Dimension(2, 2));
m_jTbTools.add(a_select);
m_jTbTools.add(a_function);
// m_jTbTools.add(a_rect);
// m_jTbTools.add(a_rrect);
// m_jTbTools.add(a_ellipse);
// m_jTbTools.add(a_line);
// m_jTbTools.add(a_poly);
m_jTbTools.add(a_arrow);
m_jTbTools.addSeparator(new Dimension(2, 2));
m_jTbTools.add(a_alignleft);
m_jTbTools.add(a_alignright);
m_jTbTools.add(a_aligntop);
m_jTbTools.add(a_alignbottom);
m_jTbTools.add(a_centerhorizontal);
m_jTbTools.add(a_centervertical);
m_jTbTools.add(a_spacehorizontal);
m_jTbTools.add(a_spacevertical);
setLayout(new BorderLayout());
// add("North", m_jTbTools);
// add("Center", g_panel);
m_jTbTools2 = new JToolBar();
m_jTbTools2.setFloatable(false);
m_jTbTools2.add(a_relax);
m_jTbTools2.add(a_viewLoggers);
m_jTbTools2.add(a_viewOperators);
m_jTbTools2.add(a_viewSequences);
m_jTbTools2.add(a_layout);
}
Aggregations