use of javax.swing.JToolBar in project logisim-evolution by reds-heig.
the class ChronoFrame method createMainStructure.
/**
* Creates the main panels for the chronogram
*/
private void createMainStructure() {
mDrawAreaEventManager = new DrawAreaEventManager();
mDrawAreaManager = new DrawAreaManager(this);
mDrawAreaEventManager.addDrawAreaListener(mDrawAreaManager);
mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.setFocusable(true);
mainPanel.requestFocus();
mainPanel.addKeyListener(this);
addWindowListener(this);
// menu bar
winMenuBar = new JMenuBar();
JMenu windowMenu = new JMenu("Window");
windowMenu.setMnemonic('W');
ontopItem = new JCheckBoxMenuItem("Set on top", true);
ontopItem.addActionListener(this);
close = new JMenuItem("Close");
close.addActionListener(this);
windowMenu.add(ontopItem);
windowMenu.addSeparator();
windowMenu.add(close);
winMenuBar.add(windowMenu);
winMenuBar.setFocusable(false);
setJMenuBar(winMenuBar);
// setAlwaysOnTop(true);
// top bar
Dimension buttonSize = new Dimension(150, 25);
topBar = new JPanel();
topBar.setLayout(new FlowLayout(FlowLayout.LEFT));
// external file
chooseFileButton = new JButton(Strings.get("ButtonLoad"));
chooseFileButton.setActionCommand("load");
chooseFileButton.addActionListener(myListener);
chooseFileButton.setPreferredSize(buttonSize);
chooseFileButton.setFocusable(false);
// export
exportDataInFile = new JButton(Strings.get("ButtonExport"));
exportDataInFile.setActionCommand("export");
exportDataInFile.addActionListener(myListener);
exportDataInFile.setPreferredSize(buttonSize);
exportDataInFile.setFocusable(false);
exportDataToImage = new JButton(Strings.get("Export as image"));
exportDataToImage.setActionCommand("exportImg");
exportDataToImage.addActionListener(myListener);
exportDataToImage.setPreferredSize(buttonSize);
exportDataToImage.setFocusable(false);
// Toolbar
JToolBar bar = new JToolBar();
bar.setFocusable(false);
JButton playButton;
if (simulator != null && simulator.isRunning()) {
playButton = new JButton(Icons.getIcon("simstop.png"));
} else {
playButton = new JButton(Icons.getIcon("simplay.png"));
}
playButton.setActionCommand("play");
playButton.addActionListener(myListener);
playButton.setToolTipText("Start/Stop simulation");
playButton.setFocusable(false);
bar.add(playButton);
JButton stepButton = new JButton(Icons.getIcon("simstep.png"));
stepButton.setActionCommand("step");
stepButton.addActionListener(myListener);
stepButton.setToolTipText("Simulate one step");
stepButton.setFocusable(false);
bar.add(stepButton);
JButton tplayButton;
if (simulator != null && simulator.isTicking()) {
tplayButton = new JButton(Icons.getIcon("simtstop.png"));
} else {
tplayButton = new JButton(Icons.getIcon("simtplay.png"));
}
tplayButton.setActionCommand("tplay");
tplayButton.addActionListener(myListener);
tplayButton.setToolTipText("Start/Stop 'sysclk' tick");
tplayButton.setFocusable(false);
bar.add(tplayButton);
JButton tstepButton = new JButton(Icons.getIcon("simtstep.png"));
tstepButton.setActionCommand("tstep");
tstepButton.addActionListener(myListener);
tstepButton.setToolTipText("Step one 'sysclk' tick");
tstepButton.setFocusable(false);
bar.add(tstepButton);
JButton tmainstepButton = new JButton(Icons.getIcon("clock.gif"));
tmainstepButton.setActionCommand("tmainstep");
tmainstepButton.addActionListener(myListener);
tmainstepButton.setToolTipText("Step one 'clk' tick");
tmainstepButton.setFocusable(false);
if (chronogramData.get("clk") == null) {
tmainstepButton.setEnabled(false);
tmainstepButton.setToolTipText("Please create a clock named 'clk' to enable this function");
}
bar.add(tmainstepButton);
mainPanel.add(BorderLayout.NORTH, bar);
statusLabel = new JLabel();
topBar.add(chooseFileButton);
topBar.add(exportDataInFile);
topBar.add(exportDataToImage);
topBar.add(new JLabel(Strings.get("SimStatusName")));
topBar.add(statusLabel);
mainPanel.add(BorderLayout.SOUTH, topBar);
// split pane
mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
mainPanel.add(BorderLayout.CENTER, mainSplitPane);
setTitle(Strings.get("ChronoTitle") + ": " + project.getLogisimFile().getDisplayName());
setResizable(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(new Dimension(1024, 768));
setContentPane(mainPanel);
prefs = Preferences.userRoot().node(this.getClass().getName());
setLocation(prefs.getInt("X", 0), prefs.getInt("Y", 0));
setSize(prefs.getInt("W", getSize().width), prefs.getInt("H", getSize().height));
setVisible(true);
}
use of javax.swing.JToolBar in project artisynth_core by artisynth.
the class NumericProbeDisplayLarge method initialize.
private void initialize() {
setSize(new Dimension(700, 400));
String inputOutputString = (myProbe.isInput()) ? "Input probe" : "Output probe";
setTitle(myTrackNumber + " " + inputOutputString + ": " + myProbe.getName());
// create probe panels based on the fact if it is input or output probes
myPanel = (NumericProbePanel) myProbe.getDisplay(getWidth(), getHeight(), LARGE_PROBE_DISPLAY);
if (myPanel.isAutoRanging()) {
myPanel.adjustRangeIfNecessary();
}
JToolBar sideToolBar = new JToolBar(JToolBar.VERTICAL);
zoomInBtn = ButtonCreator.createIconicButton(zoomInIcon, "Zoom In", "Zoom In", true, false, this);
zoomOutBtn = ButtonCreator.createIconicButton(zoomOutIcon, "Zoom Out", "Zoom Out", true, false, this);
moveDisplayBtn = ButtonCreator.createIconicButton(moveDisplayIcon, "Move Display", "Move Display", true, false, this);
pointerBtn = ButtonCreator.createIconicButton(pointerIcon, "Edit Plot", "Edit Plot", true, false, this);
upArrowBtn = ButtonCreator.createIconicButton(upArrowIcon, "Increase Range", "Increase Range", true, false, this);
downArrowBtn = ButtonCreator.createIconicButton(downArrowIcon, "Decrease Range", "Decrease Range", true, false, this);
fitRangeBtn = ButtonCreator.createIconicButton(fitRangeIcon, "Fit Range", "Fit Range", true, false, this);
autoRangeCheck = new BooleanSelector("Auto range", true);
autoRangeCheck.addValueChangeListener(this);
setYRange(myPanel.getAutoRange());
setXRange(myPanel.getDefaultDomain());
yRangeField = new DoubleIntervalField("Y range", new DoubleInterval(yMin, yMax), "%.6g");
yRangeField.addValueChangeListener(this);
xRangeField = new DoubleIntervalField("X range", new DoubleInterval(xMin, xMax), "%.6g");
xRangeField.addValueChangeListener(this);
sideToolBar.add(pointerBtn);
sideToolBar.addSeparator();
sideToolBar.add(zoomInBtn);
sideToolBar.add(zoomOutBtn);
sideToolBar.add(moveDisplayBtn);
sideToolBar.addSeparator();
sideToolBar.add(upArrowBtn);
sideToolBar.add(downArrowBtn);
sideToolBar.add(fitRangeBtn);
sideToolBar.addSeparator();
JToolBar rangeToolBar = new JToolBar();
rangeToolBar.add(autoRangeCheck);
rangeToolBar.addSeparator();
rangeToolBar.add(yRangeField);
rangeToolBar.addSeparator();
rangeToolBar.add(xRangeField);
rangeToolBar.addSeparator();
normalBorder = zoomInBtn.getBorder();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(myPanel, BorderLayout.CENTER);
getContentPane().add(sideToolBar, BorderLayout.WEST);
getContentPane().add(rangeToolBar, BorderLayout.NORTH);
pack();
}
use of javax.swing.JToolBar in project freeplane by freeplane.
the class MenuBuilderAcceptanceTest method setup.
@BeforeClass
public static void setup() {
final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
when(userInputListenerFactory.getToolBar("/main_toolbar")).thenReturn(new JToolBar());
when(userInputListenerFactory.getNodePopupMenu()).thenReturn(new JPopupMenu());
when(userInputListenerFactory.getMapPopup()).thenReturn(new JPopupMenu());
when(userInputListenerFactory.getMenuBar()).thenReturn(TestMenuBarFactory.createFreeplaneMenuBar());
final PhaseProcessor buildProcessor = new MenuBuildProcessFactory(userInputListenerFactory, Controller.getCurrentModeController(), new FreeplaneResourceAccessor(), mock(IAcceleratorMap.class), new EntriesForAction(), Collections.<BuildPhaseListener>emptyList()).getBuildProcessor();
final String menuResource = "/xml/mindmapmodemenu.xml";
final InputStream resource = MenuBuilderAcceptanceTest.class.getResourceAsStream(menuResource);
final BufferedReader reader = new BufferedReader(new InputStreamReader(resource));
menuStructure = XmlEntryStructureBuilder.buildMenuStructure(reader);
buildProcessor.build(menuStructure);
}
use of javax.swing.JToolBar in project ffx by mjschnie.
the class ModelingPanel method initialize.
private void initialize() {
// Command Description
descriptTextArea = new JTextArea();
descriptTextArea.setEditable(false);
descriptTextArea.setLineWrap(true);
descriptTextArea.setWrapStyleWord(true);
descriptTextArea.setDoubleBuffered(true);
Insets insets = descriptTextArea.getInsets();
insets.set(5, 5, 5, 5);
descriptTextArea.setMargin(insets);
descriptScrollPane = new JScrollPane(descriptTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
descriptScrollPane.setBorder(etchedBorder);
// Command Input
commandTextArea = new JTextArea();
commandTextArea.setEditable(false);
commandTextArea.setLineWrap(true);
commandTextArea.setWrapStyleWord(true);
commandTextArea.setDoubleBuffered(true);
commandTextArea.setMargin(insets);
// Command Options
optionsTabbedPane = new JTabbedPane();
statusLabel = new JLabel();
statusLabel.setBorder(etchedBorder);
statusLabel.setToolTipText(" Modeling command that will be executed");
commandPanel = new JPanel(flowLayout);
commandPanel.add(optionsTabbedPane);
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, commandPanel, descriptScrollPane);
splitPane.setContinuousLayout(true);
splitPane.setResizeWeight(1.0d);
splitPane.setOneTouchExpandable(true);
setLayout(new BorderLayout());
add(splitPane, BorderLayout.CENTER);
add(statusLabel, BorderLayout.SOUTH);
// Initialize the Amino/Nucleic Acid ComboBox.
acidComboBox.setEditable(false);
acidComboBox.setMaximumSize(sizer.getPreferredSize());
acidComboBox.setPreferredSize(sizer.getPreferredSize());
acidComboBox.setMinimumSize(sizer.getPreferredSize());
acidComboBox.setFont(Font.decode("Monospaced"));
acidTextField.setMaximumSize(sizer.getPreferredSize());
acidTextField.setMinimumSize(sizer.getPreferredSize());
acidTextField.setPreferredSize(sizer.getPreferredSize());
acidTextArea.setEditable(false);
acidTextArea.setWrapStyleWord(true);
acidTextArea.setLineWrap(true);
acidTextArea.setFont(Font.decode("Monospaced"));
acidScrollPane = new JScrollPane(acidTextArea);
Dimension d = new Dimension(300, 400);
acidScrollPane.setPreferredSize(d);
acidScrollPane.setMaximumSize(d);
acidScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
// Load the FFX commands.xml file that defines FFX commands.
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
db.setEntityResolver(new DTDResolver());
URL comURL = getClass().getClassLoader().getResource("ffx/ui/commands/commands.xml");
Document doc = db.parse(comURL.openStream());
NodeList nodelist = doc.getChildNodes();
Node commandroot = null;
for (int i = 0; i < nodelist.getLength(); i++) {
commandroot = nodelist.item(i);
if (commandroot.getNodeName().equals("FFXCommands") && commandroot instanceof Element) {
break;
}
}
if (commandroot == null || !(commandroot instanceof Element)) {
commandList = null;
}
commandList = ((Element) commandroot).getElementsByTagName("Command");
} catch (ParserConfigurationException | SAXException | IOException e) {
System.err.println(e);
} finally {
if (commandList == null) {
System.out.println("Force Field X commands.xml could not be parsed.");
logger.severe("Force Field X will exit.");
System.exit(-1);
}
}
// Create a ComboBox with commands specific to each type of coordinate
// file.
xyzCommands = new JComboBox<>();
intCommands = new JComboBox<>();
arcCommands = new JComboBox<>();
pdbCommands = new JComboBox<>();
anyCommands = new JComboBox<>();
Element command;
String name;
int numcommands = commandList.getLength();
for (int i = 0; i < numcommands; i++) {
command = (Element) commandList.item(i);
name = command.getAttribute("name");
String temp = command.getAttribute("fileType");
if (temp.contains("ANY")) {
temp = "XYZ INT ARC PDB";
anyCommands.addItem(name);
}
String[] types = temp.split(" +");
for (String type : types) {
if (type.contains("XYZ")) {
xyzCommands.addItem(name);
}
if (type.contains("INT")) {
intCommands.addItem(name);
}
if (type.contains("ARC")) {
arcCommands.addItem(name);
}
if (type.contains("PDB")) {
pdbCommands.addItem(name);
}
}
}
initCommandComboBox(xyzCommands);
initCommandComboBox(intCommands);
initCommandComboBox(arcCommands);
initCommandComboBox(pdbCommands);
initCommandComboBox(anyCommands);
currentCommandBox = anyCommands;
activeCommand = (String) anyCommands.getSelectedItem();
// Load the default Command.
loadCommand();
// Load the default Log File Settings.
logSettings.setActionCommand("LogSettings");
loadLogSettings();
// Create the Toolbar.
toolBar = new JToolBar("Modeling Commands", JToolBar.HORIZONTAL);
toolBar.setLayout(new FlowLayout(FlowLayout.LEFT));
jbLaunch = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/cog_go.png")));
jbLaunch.setActionCommand("Launch");
jbLaunch.setToolTipText("Launch the Force Field X Command");
jbLaunch.addActionListener(this);
insets.set(2, 2, 2, 2);
jbLaunch.setMargin(insets);
toolBar.add(jbLaunch);
jbStop = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/stop.png")));
jbStop.setActionCommand("End");
jbStop.setToolTipText("Terminate the Current Force Field X Command");
jbStop.addActionListener(this);
jbStop.setMargin(insets);
jbStop.setEnabled(false);
toolBar.add(jbStop);
toolBar.addSeparator();
toolBar.add(anyCommands);
currentCommandBox = anyCommands;
toolBar.addSeparator();
/*
toolBar.add(logSettings);
JButton jbdelete = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/page_delete.png")));
jbdelete.setActionCommand("Delete");
jbdelete.setToolTipText("Delete Log Files");
jbdelete.addActionListener(this);
jbdelete.setMargin(insets);
toolBar.add(jbdelete);
toolBar.addSeparator();
*/
ImageIcon icinfo = new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/information.png"));
descriptCheckBox = new JCheckBoxMenuItem(icinfo);
descriptCheckBox.addActionListener(this);
descriptCheckBox.setActionCommand("Description");
descriptCheckBox.setToolTipText("Show/Hide Modeling Command Descriptions");
descriptCheckBox.setMargin(insets);
toolBar.add(descriptCheckBox);
toolBar.add(new JLabel(""));
toolBar.setBorderPainted(false);
toolBar.setFloatable(false);
toolBar.setRollover(true);
add(toolBar, BorderLayout.NORTH);
// Load ModelingPanel preferences.
Preferences prefs = Preferences.userNodeForPackage(ffx.ui.ModelingPanel.class);
descriptCheckBox.setSelected(!prefs.getBoolean("JobPanel_description", true));
descriptCheckBox.doClick();
}
use of javax.swing.JToolBar in project ffx by mjschnie.
the class KeywordPanel method initToolBar.
/**
* <p>
* initToolBar</p>
*/
public void initToolBar() {
toolBar = new JToolBar("Keyword Editor");
toolBar.setLayout(flowLayout);
ClassLoader loader = getClass().getClassLoader();
JButton jbopen = new JButton(new ImageIcon(loader.getResource("ffx/ui/icons/folder_page.png")));
jbopen.setActionCommand("Open...");
jbopen.setToolTipText("Open a *.KEY File for Editing");
jbopen.addActionListener(this);
Insets insets = jbopen.getInsets();
insets.top = 2;
insets.bottom = 2;
insets.left = 2;
insets.right = 2;
jbopen.setMargin(insets);
// toolBar.add(jbopen);
JButton jbsave = new JButton(new ImageIcon(loader.getResource("ffx/ui/icons/disk.png")));
jbsave.setActionCommand("Save");
jbsave.setToolTipText("Save the Active *.KEY File");
jbsave.addActionListener(this);
jbsave.setMargin(insets);
toolBar.add(jbsave);
JButton jbsaveas = new JButton(new ImageIcon(loader.getResource("ffx/ui/icons/page_save.png")));
jbsaveas.setActionCommand("Save As...");
jbsaveas.setToolTipText("Save the Active *.KEY File Under a New Name");
jbsaveas.addActionListener(this);
jbsaveas.setMargin(insets);
toolBar.add(jbsaveas);
JButton jbclose = new JButton(new ImageIcon(loader.getResource("ffx/ui/icons/cancel.png")));
jbclose.setActionCommand("Close");
jbclose.setToolTipText("Close the Active *.KEY File");
jbclose.addActionListener(this);
jbclose.setMargin(insets);
// toolBar.add(jbclose);
toolBar.addSeparator();
groupComboBox.setMaximumSize(groupComboBox.getPreferredSize());
groupComboBox.addActionListener(this);
groupComboBox.setEditable(false);
toolBar.add(groupComboBox);
toolBar.addSeparator();
ImageIcon icinfo = new ImageIcon(loader.getResource("ffx/ui/icons/information.png"));
descriptCheckBox = new JCheckBoxMenuItem(icinfo);
descriptCheckBox.setActionCommand("Description");
descriptCheckBox.setToolTipText("Show/Hide Keyword Descriptions");
descriptCheckBox.addActionListener(this);
descriptCheckBox.setMargin(insets);
toolBar.add(descriptCheckBox);
toolBar.add(new JLabel(""));
toolBar.setBorderPainted(false);
toolBar.setFloatable(false);
toolBar.setRollover(true);
toolBar.setOrientation(JToolBar.HORIZONTAL);
}
Aggregations