List of usage examples for javax.swing JToolBar JToolBar
public JToolBar()
HORIZONTAL
. From source file:coolmap.application.widget.impl.WidgetUserGroup.java
private void init() { table.getTableHeader().setReorderingAllowed(false); table.setAutoCreateRowSorter(true);//from w w w . j a v a2s.co m table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (isSelected) { return label; } if (column == 1) { try { label.setBackground( nodeColor.get(table.getModel().getValueAt(table.convertRowIndexToModel(row), 0))); } catch (Exception e) { } } else { label.setBackground(UI.colorWhite); } return label; } }); //Need a search box as well. // getContentPane().setLayout(new BorderLayout()); // getContentPane().add(new JScrollPane(table), BorderLayout.CENTER); JToolBar t = new JToolBar(); getContentPane().add(t, BorderLayout.NORTH); t.setFloatable(false); try { //also add an action to add group nodes JMenuItem item = new JMenuItem("selected row nodes"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CoolMapObject o = CoolMapMaster.getActiveCoolMapObject(); if (o == null) { return; } ArrayList<Range<Integer>> selected = o.getCoolMapView().getSelectedRows(); ArrayList<VNode> selectedNodes = new ArrayList<>(); for (Range<Integer> r : selected) { for (int i = r.lowerEndpoint(); i < r.upperEndpoint(); i++) { selectedNodes.add(o.getViewNodeRow(i)); } } createNewGroup(selectedNodes); //create a group } }); WidgetMaster.getViewport().addPopupMenuItem("Create group", item, false); item = new JMenuItem("selected column nodes"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CoolMapObject o = CoolMapMaster.getActiveCoolMapObject(); if (o == null) { return; } ArrayList<Range<Integer>> selected = o.getCoolMapView().getSelectedColumns(); ArrayList<VNode> selectedNodes = new ArrayList<>(); for (Range<Integer> r : selected) { for (int i = r.lowerEndpoint(); i < r.upperEndpoint(); i++) { selectedNodes.add(o.getViewNodeColumn(i)); } } createNewGroup(selectedNodes); } }); WidgetMaster.getViewport().addPopupMenuItem("Create group", item, false); } catch (Exception e) { // //Error handling. } }
From source file:ca.uhn.hl7v2.testpanel.ui.TestPanelWindow.java
/** * Initialize the contents of the frame. *//*from www. j ava 2s .c o m*/ private void initialize() { myframe = new JFrame(); myframe.setVisible(false); List<Image> l = new ArrayList<Image>(); l.add(Toolkit.getDefaultToolkit() .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png"))); l.add(Toolkit.getDefaultToolkit() .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_64.png"))); myframe.setIconImages(l); myframe.setTitle("HAPI TestPanel"); myframe.setBounds(100, 100, 796, 603); myframe.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); myframe.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent theE) { myController.close(); } }); JMenuBar menuBar = new JMenuBar(); myframe.setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('f'); menuBar.add(mnFile); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { myController.close(); } }); JMenuItem mntmNewMessage = new JMenuItem("New Message..."); mntmNewMessage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addMessage(); } }); mntmNewMessage.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/message_hl7.png"))); mnFile.add(mntmNewMessage); mySaveMenuItem = new JMenuItem("Save"); mySaveMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mySaveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessages(); } }); mnFile.add(mySaveMenuItem); mySaveAsMenuItem = new JMenuItem("Save As..."); mySaveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessagesAs(); } }); mnFile.add(mySaveAsMenuItem); mymenuItem_3 = new JMenuItem("Open"); mymenuItem_3.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mymenuItem_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.openMessages(); } }); myRevertToSavedMenuItem = new JMenuItem("Revert to Saved"); myRevertToSavedMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.revertMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem()); } }); mnFile.add(myRevertToSavedMenuItem); mnFile.add(mymenuItem_3); myRecentFilesMenu = new JMenu("Open Recent"); mnFile.add(myRecentFilesMenu); JSeparator separator = new JSeparator(); mnFile.add(separator); mnFile.add(mntmExit); JMenu mnNewMenu = new JMenu("View"); mnNewMenu.setMnemonic('v'); menuBar.add(mnNewMenu); myShowLogConsoleMenuItem = new JMenuItem("Show Log Console"); myShowLogConsoleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Prefs.getInstance().setShowLogConsole(!Prefs.getInstance().getShowLogConsole()); updateLogScrollPaneVisibility(); myframe.validate(); } }); mnNewMenu.add(myShowLogConsoleMenuItem); mymenu_1 = new JMenu("Test"); menuBar.add(mymenu_1); mymenuItem_1 = new JMenuItem("Populate TestPanel with Sample Message and Connections..."); mymenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.populateWithSampleMessageAndConnections(); } }); mymenu_1.add(mymenuItem_1); mymenu_3 = new JMenu("Tools"); menuBar.add(mymenu_3); mnHl7V2FileDiff = new JMenuItem("HL7 v2 File Diff..."); mnHl7V2FileDiff.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHl7V2FileDiff == null) { myHl7V2FileDiff = new Hl7V2FileDiffController(myController); } myHl7V2FileDiff.show(); } }); mymenu_3.add(mnHl7V2FileDiff); mymenuItem_5 = new JMenuItem("HL7 v2 File Sort..."); mymenuItem_5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHl7V2FileSort == null) { myHl7V2FileSort = new Hl7V2FileSortController(myController); } myHl7V2FileSort.show(); } }); mymenu_3.add(mymenuItem_5); mymenu_2 = new JMenu("Conformance"); menuBar.add(mymenu_2); mymenuItem_2 = new JMenuItem("Profiles and Tables..."); mymenuItem_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.showProfilesAndTablesEditor(); } }); mymenu_2.add(mymenuItem_2); mymenu = new JMenu("Help"); mymenu.setMnemonic('H'); menuBar.add(mymenu); mymenuItem = new JMenuItem("About HAPI TestPanel..."); mymenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showAboutDialog(); } }); mymenuItem.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png"))); mymenu.add(mymenuItem); mymenuItem_4 = new JMenuItem("Licenses..."); mymenuItem_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new LicensesDialog().setVisible(true); } }); mymenu.add(mymenuItem_4); myframe.getContentPane().setLayout(new BorderLayout(0, 0)); JSplitPane outerSplitPane = new JSplitPane(); outerSplitPane.setBorder(null); myframe.getContentPane().add(outerSplitPane); JSplitPane leftSplitPane = new JSplitPane(); leftSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); outerSplitPane.setLeftComponent(leftSplitPane); JPanel messagesPanel = new JPanel(); leftSplitPane.setLeftComponent(messagesPanel); GridBagLayout gbl_messagesPanel = new GridBagLayout(); gbl_messagesPanel.columnWidths = new int[] { 110, 0 }; gbl_messagesPanel.rowHeights = new int[] { 20, 30, 118, 0, 0 }; gbl_messagesPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_messagesPanel.rowWeights = new double[] { 0.0, 0.0, 100.0, 1.0, Double.MIN_VALUE }; messagesPanel.setLayout(gbl_messagesPanel); JLabel lblMessages = new JLabel("Messages"); GridBagConstraints gbc_lblMessages = new GridBagConstraints(); gbc_lblMessages.insets = new Insets(0, 0, 5, 0); gbc_lblMessages.gridx = 0; gbc_lblMessages.gridy = 0; messagesPanel.add(lblMessages, gbc_lblMessages); JToolBar messagesToolBar = new JToolBar(); messagesToolBar.setFloatable(false); messagesToolBar.setRollover(true); messagesToolBar.setAlignmentX(Component.LEFT_ALIGNMENT); GridBagConstraints gbc_messagesToolBar = new GridBagConstraints(); gbc_messagesToolBar.insets = new Insets(0, 0, 5, 0); gbc_messagesToolBar.weightx = 1.0; gbc_messagesToolBar.anchor = GridBagConstraints.NORTHWEST; gbc_messagesToolBar.gridx = 0; gbc_messagesToolBar.gridy = 1; messagesPanel.add(messagesToolBar, gbc_messagesToolBar); JButton msgOpenButton = new JButton(""); msgOpenButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.openMessages(); } }); myAddMessageButton = new JButton(""); myAddMessageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addMessage(); } }); myAddMessageButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); myAddMessageButton.setToolTipText("New Message"); myAddMessageButton.setBorderPainted(false); myAddMessageButton.addMouseListener(new HoverButtonMouseAdapter(myAddMessageButton)); messagesToolBar.add(myAddMessageButton); myDeleteMessageButton = new JButton(""); myDeleteMessageButton.setToolTipText("Close Selected Message"); myDeleteMessageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.closeMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem()); } }); myDeleteMessageButton.setBorderPainted(false); myDeleteMessageButton.addMouseListener(new HoverButtonMouseAdapter(myDeleteMessageButton)); myDeleteMessageButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/close.png"))); messagesToolBar.add(myDeleteMessageButton); msgOpenButton.setBorderPainted(false); msgOpenButton.setToolTipText("Open Messages from File"); msgOpenButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png"))); msgOpenButton.addMouseListener(new HoverButtonMouseAdapter(msgOpenButton)); messagesToolBar.add(msgOpenButton); myMsgSaveButton = new JButton(""); myMsgSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessages(); } }); myMsgSaveButton.setBorderPainted(false); myMsgSaveButton.setToolTipText("Save Selected Messages to File"); myMsgSaveButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/save.png"))); myMsgSaveButton.addMouseListener(new HoverButtonMouseAdapter(myMsgSaveButton)); messagesToolBar.add(myMsgSaveButton); myMessagesList = new JList(); myMessagesList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myMessagesList.getSelectedIndex() >= 0) { ourLog.debug("New messages selection " + myMessagesList.getSelectedIndex()); myController.setLeftSelectedItem(myMessagesList.getSelectedValue()); myOutboundConnectionsList.clearSelection(); myOutboundConnectionsList.repaint(); myInboundConnectionsList.clearSelection(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); GridBagConstraints gbc_MessagesList = new GridBagConstraints(); gbc_MessagesList.gridheight = 2; gbc_MessagesList.weightx = 1.0; gbc_MessagesList.weighty = 1.0; gbc_MessagesList.fill = GridBagConstraints.BOTH; gbc_MessagesList.gridx = 0; gbc_MessagesList.gridy = 2; messagesPanel.add(myMessagesList, gbc_MessagesList); JPanel connectionsPanel = new JPanel(); leftSplitPane.setRightComponent(connectionsPanel); GridBagLayout gbl_connectionsPanel = new GridBagLayout(); gbl_connectionsPanel.columnWidths = new int[] { 194, 0 }; gbl_connectionsPanel.rowHeights = new int[] { 0, 30, 0, 0, 0, 0, 0 }; gbl_connectionsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_connectionsPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; connectionsPanel.setLayout(gbl_connectionsPanel); JLabel lblConnections = new JLabel("Sending Connections"); lblConnections.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_lblConnections = new GridBagConstraints(); gbc_lblConnections.insets = new Insets(0, 0, 5, 0); gbc_lblConnections.anchor = GridBagConstraints.NORTH; gbc_lblConnections.fill = GridBagConstraints.HORIZONTAL; gbc_lblConnections.gridx = 0; gbc_lblConnections.gridy = 0; connectionsPanel.add(lblConnections, gbc_lblConnections); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); GridBagConstraints gbc_toolBar = new GridBagConstraints(); gbc_toolBar.insets = new Insets(0, 0, 5, 0); gbc_toolBar.anchor = GridBagConstraints.NORTH; gbc_toolBar.fill = GridBagConstraints.HORIZONTAL; gbc_toolBar.gridx = 0; gbc_toolBar.gridy = 1; connectionsPanel.add(toolBar, gbc_toolBar); myAddConnectionButton = new JButton(""); myAddConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addOutboundConnection(); } }); myAddConnectionButton.setBorderPainted(false); myAddConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddConnectionButton)); myAddConnectionButton.setBorder(null); myAddConnectionButton.setToolTipText("New Connection"); myAddConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); toolBar.add(myAddConnectionButton); myDeleteOutboundConnectionButton = new JButton(""); myDeleteOutboundConnectionButton.setToolTipText("Delete Selected Connection"); myDeleteOutboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof OutboundConnection) { myController.removeOutboundConnection((OutboundConnection) myController.getLeftSelectedItem()); } } }); myDeleteOutboundConnectionButton.setBorderPainted(false); myDeleteOutboundConnectionButton .addMouseListener(new HoverButtonMouseAdapter(myDeleteOutboundConnectionButton)); myDeleteOutboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png"))); toolBar.add(myDeleteOutboundConnectionButton); myStartOneOutboundButton = new JButton(""); myStartOneOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof OutboundConnection) { myController.startOutboundConnection((OutboundConnection) myController.getLeftSelectedItem()); } } }); myStartOneOutboundButton.setBorderPainted(false); myStartOneOutboundButton.setToolTipText("Start selected connection"); myStartOneOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png"))); myStartOneOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneOutboundButton)); toolBar.add(myStartOneOutboundButton); myStartAllOutboundButton = new JButton(""); myStartAllOutboundButton.setBorderPainted(false); myStartAllOutboundButton.setToolTipText("Start all sending connections"); myStartAllOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png"))); myStartAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllOutboundButton)); myStartAllOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent theE) { myController.startAllOutboundConnections(); } }); toolBar.add(myStartAllOutboundButton); myStopAllOutboundButton = new JButton(""); myStopAllOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.stopAllOutboundConnections(); } }); myStopAllOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png"))); myStopAllOutboundButton.setToolTipText("Stop all sending connections"); myStopAllOutboundButton.setBorderPainted(false); myStopAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllOutboundButton)); toolBar.add(myStopAllOutboundButton); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(null); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 2; connectionsPanel.add(scrollPane, gbc_scrollPane); myOutboundConnectionsList = new JList(); myOutboundConnectionsList.setBorder(null); myOutboundConnectionsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myOutboundConnectionsList.getSelectedIndex() >= 0) { ourLog.debug( "New outbound connection selection " + myOutboundConnectionsList.getSelectedIndex()); myController.setLeftSelectedItem(myOutboundConnectionsList.getSelectedValue()); myMessagesList.clearSelection(); myMessagesList.repaint(); myInboundConnectionsList.clearSelection(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); scrollPane.setViewportView(myOutboundConnectionsList); JLabel lblReceivingConnections = new JLabel("Receiving Connections"); lblReceivingConnections.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_lblReceivingConnections = new GridBagConstraints(); gbc_lblReceivingConnections.insets = new Insets(0, 0, 5, 0); gbc_lblReceivingConnections.gridx = 0; gbc_lblReceivingConnections.gridy = 3; connectionsPanel.add(lblReceivingConnections, gbc_lblReceivingConnections); JToolBar toolBar_1 = new JToolBar(); toolBar_1.setFloatable(false); GridBagConstraints gbc_toolBar_1 = new GridBagConstraints(); gbc_toolBar_1.anchor = GridBagConstraints.WEST; gbc_toolBar_1.insets = new Insets(0, 0, 5, 0); gbc_toolBar_1.gridx = 0; gbc_toolBar_1.gridy = 4; connectionsPanel.add(toolBar_1, gbc_toolBar_1); myAddInboundConnectionButton = new JButton(""); myAddInboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addInboundConnection(); } }); myAddInboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); myAddInboundConnectionButton.setToolTipText("New Connection"); myAddInboundConnectionButton.setBorderPainted(false); myAddInboundConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddInboundConnectionButton)); toolBar_1.add(myAddInboundConnectionButton); myDeleteInboundConnectionButton = new JButton(""); myDeleteInboundConnectionButton.setToolTipText("Delete Selected Connection"); myDeleteInboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof InboundConnection) { myController.removeInboundConnection((InboundConnection) myController.getLeftSelectedItem()); } } }); myDeleteInboundConnectionButton.setBorderPainted(false); myDeleteInboundConnectionButton .addMouseListener(new HoverButtonMouseAdapter(myDeleteInboundConnectionButton)); myDeleteInboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png"))); toolBar_1.add(myDeleteInboundConnectionButton); myStartOneInboundButton = new JButton(""); myStartOneInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof InboundConnection) { myController.startInboundConnection((InboundConnection) myController.getLeftSelectedItem()); } } }); myStartOneInboundButton.setBorderPainted(false); myStartOneInboundButton.setToolTipText("Start selected connection"); myStartOneInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png"))); myStartOneInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneInboundButton)); toolBar_1.add(myStartOneInboundButton); myStartAllInboundButton = new JButton(""); myStartAllInboundButton.setBorderPainted(false); myStartAllInboundButton.setToolTipText("Start all receiving connections"); myStartAllInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png"))); myStartAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllInboundButton)); myStartAllInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent theE) { myController.startAllInboundConnections(); } }); toolBar_1.add(myStartAllInboundButton); myStopAllInboundButton = new JButton(""); myStopAllInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.stopAllInboundConnections(); } }); myStopAllInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png"))); myStopAllInboundButton.setToolTipText("Stop all receiving connections"); myStopAllInboundButton.setBorderPainted(false); myStopAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllInboundButton)); toolBar_1.add(myStopAllInboundButton); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBorder(null); GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints(); gbc_scrollPane_1.fill = GridBagConstraints.BOTH; gbc_scrollPane_1.gridx = 0; gbc_scrollPane_1.gridy = 5; connectionsPanel.add(scrollPane_1, gbc_scrollPane_1); myInboundConnectionsList = new JList(); myInboundConnectionsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myInboundConnectionsList.getSelectedIndex() >= 0) { ourLog.debug("New inbound connection selection " + myInboundConnectionsList.getSelectedIndex()); myController.setLeftSelectedItem(myInboundConnectionsList.getSelectedValue()); myMessagesList.clearSelection(); myMessagesList.repaint(); myOutboundConnectionsList.clearSelection(); myOutboundConnectionsList.repaint(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); scrollPane_1.setViewportView(myInboundConnectionsList); leftSplitPane.setDividerLocation(200); myWorkspacePanel = new JPanel(); myWorkspacePanel.setBorder(null); outerSplitPane.setRightComponent(myWorkspacePanel); myWorkspacePanel.setLayout(new BorderLayout(0, 0)); outerSplitPane.setDividerLocation(200); myLogScrollPane = new LogTable(); myLogScrollPane.setPreferredSize(new Dimension(454, 120)); myLogScrollPane.setMaximumSize(new Dimension(32767, 120)); myframe.getContentPane().add(myLogScrollPane, BorderLayout.SOUTH); updateLogScrollPaneVisibility(); updateLeftToolbarButtons(); }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/**This method initializes the Gui, by setting up the basic tabbedPanes.*/ public void init() { depMax = 1;/*from w w w . j ava2 s . c om*/ indMax = 1; chartTitle = this.getClass().getName(); chartTitle = chartTitle.substring(chartTitle.lastIndexOf(".") + 1); String fileName = "demo" + System.getProperty("file.separator") + chartTitle + ".html"; url = Chart.class.getResource(fileName); setName(chartTitle); //Get frame of the applet //frame = getFrame(this.getContentPane()); // Create the toolBar toolBar = new JToolBar(); createActionComponents(toolBar); this.getContentPane().add(toolBar, BorderLayout.NORTH); tabbedPanelContainer = new JTabbedPane(); dataObject = new Object[rowNumber][columnNumber]; columnNames = new String[columnNumber]; independentList = new ArrayList<Integer>(); dependentList = new ArrayList<Integer>(); for (int i = 0; i < columnNumber; i++) columnNames[i] = new String(DEFAULT_HEADER + (i + 1)); initTable(); initGraphPanel(); initMapPanel(); initMixPanel(); mixPanelContainer = new JScrollPane(mixPanel); mixPanelContainer.setPreferredSize(new Dimension(600, CHART_SIZE_Y + 100)); addTabbedPane(GRAPH, graphPanel); addTabbedPane(DATA, dataPanel); addTabbedPane(MAPPING, bPanel); addTabbedPane(ALL, mixPanelContainer); tabbedPanelContainer.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) { mixPanel.removeAll(); setMixPanel(); mixPanel.validate(); } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == GRAPH) { graphPanel.removeAll(); //setGraphPanel(); //graphPanel.validate(); setChart(); } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == DATA) { // setTablePane(); } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == MAPPING) { bPanel.removeAll(); mapPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y)); bPanel.add(mapPanel, BorderLayout.CENTER); bPanel.validate(); } } }); bPanel.addComponentListener(new ComponentListener() { public void componentResized(ComponentEvent e) { } public void componentMoved(ComponentEvent e) { } public void componentShown(ComponentEvent e) { // resultPanelTextArea.append("sucess"); // System.out.print("Success"); // Add code here for updating the Panel to show proper heading paintMappingLists(listIndex); } public void componentHidden(ComponentEvent e) { } }); // the right side (including top and bottom panels) statusTextArea = new JTextPane(); //right side lower statusTextArea.setEditable(false); JScrollPane statusContainer = new JScrollPane(statusTextArea); statusContainer.setPreferredSize(new Dimension(600, 140)); if (SHOW_STATUS_TEXTAREA) { JSplitPane container = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(tabbedPanelContainer), statusContainer); container.setContinuousLayout(true); container.setDividerLocation(0.6); this.getContentPane().add(container, BorderLayout.CENTER); } else { this.getContentPane().add(new JScrollPane(tabbedPanelContainer), BorderLayout.CENTER); } updateStatus(url); }
From source file:ch.fork.AdHocRailway.ui.AdHocRailway.java
private void initToolbar() { /* FILE *//*from ww w.j av a 2s. c o m*/ final JToolBar fileToolBar = new JToolBar(); final JButton newFileToolBarButton = new SmallToolbarButton(new NewFileAction()); final JButton openFileToolBarButton = new SmallToolbarButton(new OpenFileAction()); final JButton openDatabaseToolBarButton = new SmallToolbarButton(new OpenDatabaseAction()); final JButton saveToolBarButton = new SmallToolbarButton(new SaveAction()); final JButton exitToolBarButton = new SmallToolbarButton(new ExitAction()); fileToolBar.add(newFileToolBarButton); fileToolBar.add(openFileToolBarButton); fileToolBar.add(openDatabaseToolBarButton); fileToolBar.add(saveToolBarButton); fileToolBar.add(exitToolBarButton); /* DIGITAL */ final JToolBar digitalToolBar = new JToolBar(); turnoutsToolBarButton = new SmallToolbarButton(new TurnoutAction()); routesToolBarButton = new SmallToolbarButton(new RoutesAction()); locomotivesToolBarButton = new SmallToolbarButton(new LocomotivesAction()); preferencesToolBarButton = new SmallToolbarButton(new PreferencesAction()); digitalToolBar.add(turnoutsToolBarButton); digitalToolBar.add(routesToolBarButton); digitalToolBar.add(locomotivesToolBarButton); digitalToolBar.add(preferencesToolBarButton); /* SRCP / AdHoc-Brain */ final JToolBar daemonToolBar = new JToolBar(); railwayDeviceLabelLabel = new JLabel(); setRailwayDeviceLabelText(); connectToolBarButton = new SmallToolbarButton(new ConnectAction()); disconnectToolBarButton = new SmallToolbarButton(new DisconnectAction()); disconnectToolBarButton.setEnabled(false); daemonToolBar.add(railwayDeviceLabelLabel); daemonToolBar.addSeparator(); daemonToolBar.add(connectToolBarButton); daemonToolBar.add(disconnectToolBarButton); /* VIEWS */ final JToolBar viewToolBar = new JToolBar(); final JButton refreshButton = new SmallToolbarButton(new RefreshAction()); toggleFullscreenButton = new SmallToolbarButton(new ToggleFullscreenAction()); viewToolBar.add(refreshButton); viewToolBar.add(toggleFullscreenButton); /* ERROR */ final ErrorPanel errorPanel = new ErrorPanel(); ExceptionProcessor.getInstance(errorPanel); toolbarPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); addToolBar(fileToolBar); addToolBar(digitalToolBar); addToolBar(daemonToolBar); addToolBar(viewToolBar); final JPanel toolbarErrorPanel = new JPanel(new BorderLayout(10, 10)); toolbarErrorPanel.add(toolbarPanel, BorderLayout.WEST); toolbarErrorPanel.add(errorPanel, BorderLayout.EAST); add(toolbarErrorPanel, BorderLayout.PAGE_START); }
From source file:jmemorize.gui.swing.frames.MainFrame.java
private JPanel buildCategoryBar() { final JToolBar categoryToolbar = new JToolBar(); categoryToolbar.setFloatable(false); categoryToolbar.setMargin(new Insets(2, 2, 2, 2)); m_showTreeButton = new JButton(new ShowCategoryTreeAction()); m_showTreeButton.setPreferredSize(new Dimension(120, 21)); categoryToolbar.add(m_showTreeButton); final JLabel categoryLabel = new JLabel(Localization.get(LC.CATEGORY), SwingConstants.CENTER); categoryLabel.setPreferredSize(new Dimension(60, 15)); categoryToolbar.add(categoryLabel);/* www .j a v a 2 s .c o m*/ m_categoryBox = new CategoryComboBox(); m_categoryBox.setPreferredSize(new Dimension(24, 24)); m_categoryBox.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent evt) { categoryBoxActionPerformed(); } }); categoryToolbar.add(m_categoryBox); categoryToolbar.add(new JButton(new SplitMainFrameAction(this))); final JPanel categoryPanel = new JPanel(new BorderLayout()); categoryPanel.setBorder(new EtchedBorder()); categoryPanel.add(categoryToolbar, BorderLayout.NORTH); return categoryPanel; }
From source file:es.darkhogg.hazelnutt.EditorFrame.java
private void initializeGui() { setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(100, 100, 640, 480);// w w w . ja v a2 s. c o m addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { actionExit(); } }); fileChooser = new JFileChooser(); //fileChooser.setFileFilter( hlfFileFilter ); hlfFileChooser = new JFileChooser(); hlfFileChooser.setFileFilter(hlfFileFilter); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('F'); menuBar.add(mnFile); menuLoadRom = new JMenuItem("Load ROM..."); menuLoadRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); menuLoadRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionOpenRom(null); } }); menuLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png"))); menuLoadRom.setMnemonic('O'); mnFile.add(menuLoadRom); menuSaveRom = new JMenuItem("Save ROM"); menuSaveRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRom(); } }); menuSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png"))); menuSaveRom.setMnemonic('S'); menuSaveRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); mnFile.add(menuSaveRom); menuSaveRomAs = new JMenuItem("Save ROM As..."); menuSaveRomAs.setMnemonic('a'); menuSaveRomAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK)); menuSaveRomAs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRomAs(); } }); menuSaveRomAs .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_as.png"))); mnFile.add(menuSaveRomAs); mnFile.addSeparator(); menuLoadLevel = new JMenuItem("Load Level..."); menuLoadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); menuLoadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionLoadLevel(); } }); menuLoadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png"))); menuLoadLevel.setMnemonic('L'); mnFile.add(menuLoadLevel); menuReloadLevel = new JMenuItem("Reload Level"); menuReloadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0)); menuReloadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionReloadLevel(); } }); menuReloadLevel.setMnemonic('R'); menuReloadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png"))); mnFile.add(menuReloadLevel); menuSaveLevel = new JMenuItem("Save Level"); menuSaveLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0)); menuSaveLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveLevel(); } }); menuSaveLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png"))); menuSaveLevel.setMnemonic('v'); mnFile.add(menuSaveLevel); //* mnFile.addSeparator(); menuImportLevel = new JMenuItem("Import Level..."); menuImportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)); menuImportLevel.setMnemonic('i'); menuImportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionImportLevel(); } }); menuImportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png"))); mnFile.add(menuImportLevel); menuExportLevel = new JMenuItem("Export Level..."); menuExportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); menuExportLevel.setMnemonic('e'); menuExportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionExportLevel(); } }); menuExportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png"))); mnFile.add(menuExportLevel); //*/ mnFile.addSeparator(); menuExit = new JMenuItem("Exit"); menuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); menuExit.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_exit.png"))); menuExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { actionExit(); } }); menuRecentFiles = new JMenu("Recent Files..."); mnFile.add(menuRecentFiles); mnFile.addSeparator(); menuExit.setMnemonic('X'); mnFile.add(menuExit); JMenu mnEdit = new JMenu("Edit"); mnEdit.setMnemonic('E'); menuBar.add(mnEdit); menuViewSpawn = new JCheckBoxMenuItem("View Spawn Point"); menuViewSpawn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0)); menuViewSpawn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuClearLevel = new JMenuItem("Clear Level"); menuClearLevel.setMnemonic('c'); menuClearLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); menuClearLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionClearLevel(); } }); menuClearLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png"))); mnEdit.add(menuClearLevel); mnEdit.addSeparator(); menuViewSpawn .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png"))); menuViewSpawn.setMnemonic('S'); menuViewSpawn.setSelected(true); mnEdit.add(menuViewSpawn); menuViewItems = new JCheckBoxMenuItem("View Items"); menuViewItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0)); menuViewItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewItems.setSelected(true); menuViewItems .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png"))); menuViewItems.setMnemonic('I'); mnEdit.add(menuViewItems); menuViewDoorItems = new JCheckBoxMenuItem("View Door Items"); menuViewDoorItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0)); menuViewDoorItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewDoorItems.setSelected(true); menuViewDoorItems.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png"))); menuViewDoorItems.setMnemonic('D'); mnEdit.add(menuViewDoorItems); menuViewEnemies = new JCheckBoxMenuItem("View Enemies"); menuViewEnemies.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0)); menuViewEnemies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewEnemies.setSelected(true); menuViewEnemies .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png"))); menuViewEnemies.setMnemonic('E'); mnEdit.add(menuViewEnemies); menuViewTypes = new JCheckBoxMenuItem("View Combo Types"); menuViewTypes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_5, 0)); menuViewTypes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewTypes.setSelected(true); menuViewTypes.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png"))); menuViewTypes.setMnemonic('C'); mnEdit.add(menuViewTypes); mnEdit.addSeparator(); scaleMenuItem = new JCheckBoxMenuItem("Scale Level Display"); scaleMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_6, 0)); scaleMenuItem.setMnemonic('l'); scaleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionScale(false); } }); scaleMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png"))); mnEdit.add(scaleMenuItem); gridMenuItem = new JCheckBoxMenuItem("Display grid"); gridMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_7, 0)); gridMenuItem.setMnemonic('G'); gridMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionGrid(false); } }); gridMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png"))); mnEdit.add(gridMenuItem); //mnEdit.addSeparator(); mntmPreferences = new JMenuItem("Preferences..."); mntmPreferences.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionPreferences(); } }); mntmPreferences.setMnemonic('P'); mntmPreferences.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_preferences.png"))); //mnEdit.add(mntmPreferences); mnHelp = new JMenu("Help"); mnHelp.setMnemonic('H'); menuBar.add(mnHelp); mntmCheckUpdates = new JMenuItem("Check for Updates..."); mntmCheckUpdates.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK)); mntmCheckUpdates.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionCheckUpdates(); } }); mntmCheckUpdates.setMnemonic('c'); mntmCheckUpdates .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_update.png"))); mnHelp.add(mntmCheckUpdates); mntmAbout = new JMenuItem("Readme..."); mntmAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); mntmAbout.setMnemonic('r'); mntmAbout.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/about.png"))); mntmAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionAbout(); } }); mnHelp.addSeparator(); mnHelp.add(mntmAbout); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); toolBar.setFloatable(false); contentPane.add(toolBar, BorderLayout.NORTH); barLoadRom = new JButton(""); barLoadRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionOpenRom(null); } }); barLoadRom.setToolTipText("Open"); barLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png"))); toolBar.add(barLoadRom); barSaveRom = new JButton(""); barSaveRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRom(); } }); barSaveRom.setToolTipText("Save"); barSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png"))); toolBar.add(barSaveRom); toolBar.addSeparator(); barImportLevel = new JButton(""); barImportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionImportLevel(); } }); barImportLevel.setToolTipText("Import Level"); barImportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png"))); toolBar.add(barImportLevel); barExportLevel = new JButton(""); barExportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionExportLevel(); } }); barExportLevel.setToolTipText("Export Level"); barExportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png"))); toolBar.add(barExportLevel); toolBar.addSeparator(); barLoadLevel = new JButton(""); barLoadLevel.setToolTipText("Load Level"); barLoadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionLoadLevel(); } }); barLoadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png"))); toolBar.add(barLoadLevel); barReloadLevel = new JButton(""); barReloadLevel.setToolTipText("Reload Current Level"); barReloadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionReloadLevel(); } }); barReloadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png"))); toolBar.add(barReloadLevel); barSaveLevel = new JButton(""); barSaveLevel.setToolTipText("Save Level"); barSaveLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveLevel(); } }); barSaveLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png"))); toolBar.add(barSaveLevel); toolBar.addSeparator(); barViewItems = new JToggleButton(""); barViewItems.setToolTipText("Toggle View Items"); barViewItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewSpawn = new JToggleButton(""); barViewSpawn.setToolTipText("Toggle View Spawn"); barViewSpawn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barClearLevel = new JButton(""); barClearLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionClearLevel(); } }); barClearLevel.setToolTipText("Clear Level"); barClearLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png"))); toolBar.add(barClearLevel); toolBar.addSeparator(); barViewSpawn.setSelected(true); barViewSpawn.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png"))); toolBar.add(barViewSpawn); barViewItems.setSelected(true); barViewItems.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png"))); toolBar.add(barViewItems); barViewDoorItems = new JToggleButton(""); barViewDoorItems.setToolTipText("Toggle View Door Items"); barViewDoorItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewDoorItems.setSelected(true); barViewDoorItems.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png"))); toolBar.add(barViewDoorItems); barViewEnemies = new JToggleButton(""); barViewEnemies.setToolTipText("toggle View Enemies"); barViewEnemies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewEnemies.setSelected(true); barViewEnemies .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png"))); toolBar.add(barViewEnemies); barViewTypes = new JToggleButton(""); barViewTypes.setToolTipText("Toggle view Combo Help"); barViewTypes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewTypes.setSelected(true); barViewTypes.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png"))); toolBar.add(barViewTypes); barViewSpawn.setSelected(config.getBoolean("Hazelnutt.gui.viewSpawn", true)); barViewItems.setSelected(config.getBoolean("Hazelnutt.gui.viewItems", true)); barViewDoorItems.setSelected(config.getBoolean("Hazelnutt.gui.viewDoorItems", true)); barViewEnemies.setSelected(config.getBoolean("Hazelnutt.gui.viewEnemies", true)); barViewTypes.setSelected(config.getBoolean("Hazelnutt.gui.viewHelp", true)); panel = new JPanel(); contentPane.add(panel, BorderLayout.EAST); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); selectorPanel = new SelectorPanel(); selectorPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Combo & Entity Selector", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); panel.add(selectorPanel); propertiesPanel = new PropertiesPanel(null); propertiesPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level Properties", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); panel.add(propertiesPanel); toolBar.addSeparator(); scaleButton = new JToggleButton(""); scaleButton.setToolTipText("Toggle Scale Display"); scaleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionScale(true); } }); scaleButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png"))); toolBar.add(scaleButton); scaleButton.setSelected(config.getBoolean("Hazelnutt.gui.scaled", false)); gridButton = new JToggleButton(""); gridButton.setToolTipText("Display Grid"); gridButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionGrid(true); } }); gridButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png"))); toolBar.add(gridButton); gridButton.setSelected(config.getBoolean("Hazelnutt.gui.grid", false)); Component horizontalGlue = Box.createHorizontalGlue(); toolBar.add(horizontalGlue); Component verticalGlue = Box.createVerticalGlue(); panel.add(verticalGlue); levelWrapper = new JPanel(); levelWrapper.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); contentPane.add(levelWrapper, BorderLayout.CENTER); levelWrapper.setLayout(new BorderLayout(0, 0)); scrollPane = new JScrollPane(); scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); levelWrapper.add(scrollPane); levelDisplay = new LevelDisplay(); levelDisplay.addEditListener(new EditListener() { @Override public void leftPressed(int x, int y) { SelectionType st = selectorPanel.getSelectionType(); Object so = selectorPanel.getSelectedObject(); if (st == SelectionType.COMBO) { paintComboAt(x, y, ((Byte) so).byteValue()); } else if (st == SelectionType.SPAWN) { selectedLevel.getRomLevel().setSpawn(new IntVector(x, y)); levelHasChanged = true; } else if (st == SelectionType.ITEM) { Item ent = new Item((ItemType) so, x, y); EntityCollection<Item> ents = selectedLevel.getRomLevel().getItems(); for (Iterator<Item> it = ents.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } else if (st == SelectionType.DOOR_ITEM) { Item ent = new Item((ItemType) so, x, y); EntityCollection<Item> ents = selectedLevel.getRomLevel().getDoorItems(); for (Iterator<Item> it = ents.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } else if (st == SelectionType.ENEMY) { Enemy ent = new Enemy((EnemyType) so, x, y); EntityCollection<Enemy> ents = selectedLevel.getRomLevel().getEnemies(); for (Iterator<Enemy> it = ents.iterator(); it.hasNext();) { Enemy enem = it.next(); if (enem.getX() == x && enem.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } updateTitle(); levelDisplay.repaint(); levelHasChanged = true; } @Override public void centerPressed(int x, int y) { selectorPanel.forceComboSelection(selectedLevel.getRomLevel().getData()[x][y]); } @Override public void rightPressed(int x, int y) { deleteVisibleEntitiesAt(x, y); } @Override public void leftDragged(int x, int y) { if (selectorPanel.getSelectionType() == SelectionType.COMBO) { paintComboAt(x, y, ((Byte) selectorPanel.getSelectedObject()).byteValue()); } } @Override public void centerDragged(int x, int y) { // Nothing to de here } @Override public void rightDragged(int x, int y) { deleteVisibleEntitiesAt(x, y); } // Utility methods /*private void selectComboAt ( int x, int y ) { }/**/ private void paintComboAt(int x, int y, byte value) { selectedLevel.getRomLevel().getData()[x][y] = value; levelHasChanged = true; updateTitle(); levelDisplay.repaint(); } private void deleteVisibleEntitiesAt(int x, int y) { Collection<Item> items = selectedLevel.getRomLevel().getItems(); Collection<Item> doorItems = selectedLevel.getRomLevel().getDoorItems(); Collection<Enemy> enemies = selectedLevel.getRomLevel().getEnemies(); if (barViewItems.isSelected()) { for (Iterator<Item> it = items.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); levelHasChanged = true; } } } if (barViewDoorItems.isSelected()) { for (Iterator<Item> it = doorItems.iterator(); it.hasNext();) { Item doorItem = it.next(); if (doorItem.getX() == x && doorItem.getY() == y) { it.remove(); levelHasChanged = true; } } } if (barViewEnemies.isSelected()) { for (Iterator<Enemy> it = enemies.iterator(); it.hasNext();) { Enemy enem = it.next(); if (enem.getX() == x && enem.getY() == y) { it.remove(); levelHasChanged = true; } } } updateTitle(); levelDisplay.repaint(); } }); scrollPane.setViewportView(levelDisplay); updateTitle(); actionToggle(true); actionScale(true); actionGrid(true); setIconImage(Toolkit.getDefaultToolkit() .getImage(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/witch_hazel_big.png"))); setRomFeaturesEnabled(false); setLevelFeaturesEnabled(false); if (config.getBoolean("Hazelnutt.gui.maximum", false)) { setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); } else { int x = config.getInt("Hazelnutt.gui.location.x", Integer.MIN_VALUE); int y = config.getInt("Hazelnutt.gui.location.y", Integer.MIN_VALUE); int w = config.getInt("Hazelnutt.gui.size.width", Integer.MIN_VALUE); int h = config.getInt("Hazelnutt.gui.size.height", Integer.MIN_VALUE); if (x == Integer.MIN_VALUE || x == Integer.MIN_VALUE || w == Integer.MIN_VALUE || h == Integer.MIN_VALUE) { setLocationRelativeTo(null); } else { setLocation(x, y); setSize(w, h); } } propertiesPanel.addApplyListener(new PropertiesPanel.ApplyListener() { @Override public void apply() { levelHasChanged = true; updateTitle(); updateDisplay(); } }); if (config.containsKey("Hazelnutt.gui.lastDirectory")) { File lastDir = new File(config.getString("Hazelnutt.gui.lastDirectory")); if (lastDir.exists() && lastDir.isDirectory()) { //logger.debug( "Resetting the last directory: '" + lastDir + "'" ); fileChooser.setCurrentDirectory(lastDir); } } // Configure the PgUp and PgDn shortcuts InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PgUp"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PgDn"); ActionMap am = contentPane.getActionMap(); am.put("PgUp", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { actionLevelUp(); } }); am.put("PgDn", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { actionLevelDown(); } }); // Get the recent files recentFiles = new LinkedList<String>(Arrays.asList(config.getStringArray("Hazelnutt.gui.recentFiles"))); updateRecentFiles(); }
From source file:jmemorize.gui.swing.frames.MainFrame.java
private JPanel buildOperationsBar() { final JToolBar operationsToolbar = new JToolBar(); operationsToolbar.setFloatable(false); operationsToolbar.add(new JButton(new NewLessonAction())); operationsToolbar.add(new JButton(new OpenLessonAction(jMemorizeIO, this))); operationsToolbar.add(new JButton(new SaveLessonAction(jMemorizeIO))); operationsToolbar.add(new JButton(new AddCardAction(this))); operationsToolbar.add(new JButton(new EditCardAction(this))); operationsToolbar.add(new JButton(new ResetCardAction(this))); operationsToolbar.add(new JButton(new RemoveAction(this))); operationsToolbar.add(new JButton(new AddCategoryAction(this))); operationsToolbar.add(new JButton(new FindAction(this))); operationsToolbar.add(new JButton(new LearnAction(this))); final JPanel operationsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 1, 1)); operationsPanel.add(operationsToolbar); return operationsPanel; }
From source file:com.vgi.mafscaling.LogView.java
private void createToolBar(JPanel panel) { toolBar = new JToolBar(); panel.add(toolBar, BorderLayout.NORTH); loadButton = addToolbarButton("Load Log File", "/open.png"); toolBar.addSeparator();/*w w w .ja va2 s . co m*/ printButton = addToolbarButton("Print", "/print.png"); previewButton = addToolbarButton("Print Preview", "/print_preview.png"); findButton = addToolbarButton("Find", "/find.png"); replaceButton = addToolbarButton("Replace", "/replace.png"); toolBar.addSeparator(); viewButton = new JButton("Headers View"); viewButton.setMargin(new Insets(2, 7, 2, 7)); viewButton.addActionListener(this); toolBar.add(viewButton); toolBar.addSeparator(); logPlayButton = new JButton("Log Play"); logPlayButton.setMargin(new Insets(2, 7, 2, 7)); logPlayButton.addActionListener(this); toolBar.add(logPlayButton); toolBar.addSeparator(); toolBar.add(new JLabel("Filter ")); JPanel filterPanel = new JPanel(); GridBagLayout gbl_filterPanel = new GridBagLayout(); gbl_filterPanel.columnWidths = new int[] { 0, 0, 0, 0 }; gbl_filterPanel.rowHeights = new int[] { 0 }; gbl_filterPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 1.0 }; gbl_filterPanel.rowWeights = new double[] { 0.0 }; filterPanel.setLayout(gbl_filterPanel); GridBagConstraints gbc_filter = new GridBagConstraints(); gbc_filter.insets = insets3; gbc_filter.anchor = GridBagConstraints.WEST; gbc_filter.gridx = 0; gbc_filter.gridy = 0; selectionCombo = new JComboBox<String>(); selectionCombo.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXX"); selectionCombo.addActionListener(this); filterPanel.add(selectionCombo, gbc_filter); gbc_filter.gridx++; compareCombo = new JComboBox<String>(new String[] { "", "<", "<=", "=", ">=", ">" }); compareCombo.addActionListener(this); filterPanel.add(compareCombo, gbc_filter); gbc_filter.gridx++; filterText = new JTextField(); filterText.setColumns(5); filterPanel.add(filterText, gbc_filter); gbc_filter.gridx++; filterButton = new JButton("Set"); filterButton.addActionListener(this); filterPanel.add(filterButton, gbc_filter); toolBar.add(filterPanel); }
From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java
/** * DOCUMENT ME!// w w w . ja v a 2s. c om * * @return DOCUMENT ME! */ public JToolBar createDiscoveryToolBar() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(true); // Find URL findUrl = getClass().getClassLoader().getResource("icons/find.gif"); ImageIcon findIcon = new ImageIcon(findUrl); findButton = toolBar.add(new AbstractAction("", findIcon) { /** * */ private static final long serialVersionUID = 3307493586585435411L; public void actionPerformed(ActionEvent e) { findAction(); } }); findButton.setToolTipText(resourceBundle.getString("button.find")); // showSchemes URL showSchemesUrl = getClass().getClassLoader().getResource("icons/schemeViewer.gif"); ImageIcon showSchemesIcon = new ImageIcon(showSchemesUrl); showSchemesButton = toolBar.add(new AbstractAction("", showSchemesIcon) { /** * */ private static final long serialVersionUID = 1899451223510883277L; public void actionPerformed(ActionEvent e) { if (RegistryBrowser.client.connection == null) { displayUnconnectedError(); } else { ConceptsTreeDialog.showSchemes(RegistryBrowser.getInstance(), false, isAuthenticated()); } } }); showSchemesButton.setToolTipText(resourceBundle.getString("button.showSchemes")); // Re-authenticate URL authenticateUrl = getClass().getClassLoader().getResource("icons/authenticate.gif"); ImageIcon authenticateIcon = new ImageIcon(authenticateUrl); authenticateButton = toolBar.add(new AbstractAction("", authenticateIcon) { /** * */ private static final long serialVersionUID = 3469608949024981381L; public void actionPerformed(ActionEvent e) { authenticate(); } }); authenticateButton.setToolTipText(resourceBundle.getString("button.authenticate")); // Logout URL logoutUrl = getClass().getClassLoader().getResource("icons/logoff.gif"); ImageIcon logoutIcon = new ImageIcon(logoutUrl); logoutButton = toolBar.add(new AbstractAction("", logoutIcon) { /** * */ private static final long serialVersionUID = -293987897100997408L; public void actionPerformed(ActionEvent e) { logout(); } }); logoutButton.setToolTipText(resourceBundle.getString("button.logout")); logoutButton.setEnabled(false); // key registration URL keyRegUrl = getClass().getClassLoader().getResource("icons/keyReg.gif"); ImageIcon keyRegIcon = new ImageIcon(keyRegUrl); keyRegButton = toolBar.add(new AbstractAction("", keyRegIcon) { /** * */ private static final long serialVersionUID = -8988435962749097387L; public void actionPerformed(ActionEvent e) { RegistryBrowser.setWaitCursor(); // showKeyRegistrationWizard(); KeyManager keyMgr = KeyManager.getInstance(); try { keyMgr.registerNewKey(); } catch (Exception er) { RegistryBrowser.displayError(er); } RegistryBrowser.setDefaultCursor(); } }); keyRegButton.setToolTipText(resourceBundle.getString("button.keyReg")); // user registration URL userRegUrl = getClass().getClassLoader().getResource("icons/userReg.gif"); ImageIcon userRegIcon = new ImageIcon(userRegUrl); userRegButton = toolBar.add(new AbstractAction("", userRegIcon) { /** * */ private static final long serialVersionUID = 8890984621456210702L; public void actionPerformed(ActionEvent e) { RegistryBrowser.setWaitCursor(); // showUserRegistrationWizard(); if (RegistryBrowser.client.connection == null) { displayUnconnectedError(); } else { UserManager userMgr = UserManager.getInstance(); try { // Make sure you are logged off when registering new // user so new user is not owned by old user. logout(); userMgr.registerNewUser(); logout(); } catch (Exception er) { RegistryBrowser.displayError(er); } } RegistryBrowser.setDefaultCursor(); } }); userRegButton.setToolTipText(resourceBundle.getString("button.userReg")); // locale selection URL localeSelUrl = getClass().getClassLoader().getResource("icons/localeSel.gif"); ImageIcon localeSelIcon = new ImageIcon(localeSelUrl); localeSelButton = toolBar.add(new AbstractAction("", localeSelIcon) { /** * */ private static final long serialVersionUID = 6304340858289330717L; public void actionPerformed(ActionEvent e) { RegistryBrowser.setWaitCursor(); LocaleSelectorDialog dialog = getLocaleSelectorDialog(); @SuppressWarnings("unused") Locale oldSelectedLocale = getSelectedLocale(); dialog.setVisible(true); Locale selectedLocale = getSelectedLocale(); System.out.println(getLocale()); setLocale(selectedLocale); RegistryBrowser.setDefaultCursor(); } }); localeSelButton.setToolTipText(resourceBundle.getString("button.localeSel")); return toolBar; }
From source file:net.sf.nmedit.nomad.core.Nomad.java
private JToolBar createQuickActionToolbar() { JToolBar toolbar = new JToolBar(); toolbar.setBorderPainted(false);// www. j ava 2 s. c o m toolbar.setFloatable(false); toolbar.add(Factory.createToolBarButton(menuLayout.getEntry(MENU_FILE_OPEN))); toolbar.addSeparator(); toolbar.add(Factory.createToolBarButton(menuLayout.getEntry(MENU_FILE_SAVE))); toolbar.addSeparator(); JPopupMenu pop = new JPopupMenu(); Iterator<FileService> iter = ServiceRegistry.getServices(FileService.class); JRadioButtonMenuItem rfirst = null; SelectedAction sa = new SelectedAction(); sa.putValue(AbstractAction.SMALL_ICON, getImage("/icons/tango/16x16/actions/document-new.png")); while (iter.hasNext()) { FileService fs = iter.next(); if (fs.isNewFileOperationSupported()) { JRadioButtonMenuItem rb = new JRadioButtonMenuItem( new AHAction(fs.getName(), fs.getIcon(), fs, "newFile")); sa.add(rb); pop.add(rb); if (rfirst == null) rfirst = rb; } } JButton btn = Factory.createToolBarButton(sa); toolbar.add(btn); new JDropDownButtonControl(btn, pop); return toolbar; }