public void addButton(JToggleButton b) { imagePanel.add(b); b.setForeground(Color.black); b.setBackground(Color.white); b.setFocusable(false); b.addMouseListener(new PopupMouseListener(b)); b.addActionListener(new PopupActionListener(b)); }
private void jbInit() throws Exception { panel1.setLayout(xYLayout1); panel1.setBackground(new Color(251, 236, 175)); jToggleButton5.setText("Done"); jToggleButton5.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jToggleButton5_actionPerformed(e); } }); jLabel1.setToolTipText(""); jList1.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { jList1_mouseClicked(e); } }); HireFire.setText("Hire/Fire"); HireFire.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { HireFire_actionPerformed(e); } }); jButtonAdvertise.setText("Advertise"); jButtonAdvertise.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonAdvertise_actionPerformed(e); } }); jTextFieldWage.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jTextFieldWage_actionPerformed(e); } }); jLabel3.setHorizontalAlignment(SwingConstants.RIGHT); jLabel3.setText("Amount"); jLabel5.setText("jLabel5"); jTextFieldWage.setText("100"); panel1.add(jList1, new XYConstraints(9, 10, 206, 250)); panel1.add(jTextPane2, new XYConstraints(9, 262, 467, 109)); panel1.add(jLabel1, new XYConstraints(476, 9, 10, 226)); panel1.add(jLabel2, new XYConstraints(2, 454, 58, 12)); panel1.add(jToggleButton5, new XYConstraints(385, 397, 75, 26)); panel1.add(HireFire, new XYConstraints(9, 429, 134, 26)); panel1.add(jPanel1, new XYConstraints(217, 10, 259, 250)); this.getContentPane().add(panel1, BorderLayout.SOUTH); panel1.add(jButtonAdvertise, new XYConstraints(183, 401, 116, -1)); panel1.add(jTextFieldWage, new XYConstraints(69, 403, 102, 24)); panel1.add(jLabel3, new XYConstraints(19, 400, 46, 29)); panel1.add(jLabel4, new XYConstraints(155, 460, 44, 6)); panel1.add(jLabel5, new XYConstraints(507, 92, 5, 47)); this.setVisible(true); }
public GLDemo() { super(VNMRFrame.getVNMRFrame(), "Jogl Demo", false); DisplayOptions.addChangeListener(this); contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); gradientPanel = createGradientPanel(); contentPane.add(gradientPanel, BorderLayout.CENTER); checkBox = new JCheckBox("Transparent", true); checkBox.setActionCommand("transparancy"); checkBox.addActionListener(this); optionsPan = new JPanel(); optionsPan.setLayout(new SimpleH2Layout(SimpleH2Layout.LEFT, 5, 0, true, false)); optionsPan.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); optionsPan.add(checkBox); runButton = new JToggleButton("Run"); runButton.setActionCommand("run"); runButton.setSelected(false); runButton.addActionListener(this); optionsPan.add(runButton); getContentPane().add(optionsPan, BorderLayout.SOUTH); setSize(300, 300); setLocation(300, 300); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting new Thread( new Runnable() { public void run() { stop(); } }) .start(); } }); setVisible(false); }
public void addMoreRow() { final JToggleButton b = ViewUtil.getSoftToggleButton("MORE"); ViewUtil.makeMini(b); b.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { toggleMoreVisibility(); if (b.getText().equals("MORE")) { b.setText("LESS"); } else { b.setText("MORE"); } } }); /* * final JLabel keyLabel = new JLabel(); ViewUtil.makeMini(keyLabel); * keyLabel.setForeground(Color.darkGray); * keyLabel.setBorder(ViewUtil.getMediumBorder()); * * keyLabel.setText("▼ MORE ▼"); * * keyLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); * keyLabel.addMouseListener(new MouseAdapter() { @Override public void * mouseClicked(MouseEvent me) { toggleMoreVisibility(); * * if (keyLabel.getText().startsWith("▲")) { keyLabel.setText("▼ MORE * ▼"); } else { keyLabel.setText("▲ LESS ▲"); } * * } * }); */ toolbar.add(ViewUtil.getCenterAlignedComponent(b)); newRowsGoIntoMoreSection = true; }
private static void initGui() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception exception) { exception.printStackTrace(); } JFrame frame = new JFrame("DarkBot"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridBagLayout()); Insets noInsets = new Insets(0, 0, 0, 0); final JToggleButton sessionsButton = new JToggleButton("Login (0)"); frame.add( sessionsButton, new GridBagConstraints( 0, 0, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); sessionsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sessions.set(sessionsButton.isSelected()); synchronized (sessions) { sessions.notifyAll(); } } }); final JToggleButton joinsButton = new JToggleButton("Join (0)"); frame.add( joinsButton, new GridBagConstraints( 0, 1, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); joinsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { joins.set(joinsButton.isSelected()); synchronized (joins) { joins.notifyAll(); } } }); final JTextField field = new JTextField(); frame.add( field, new GridBagConstraints( 0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); final JButton button = new JButton("Start"); frame.add( button, new GridBagConstraints( 1, 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (button.getText().startsWith("Start")) { field.setEnabled(false); spamMessage = field.getText(); button.setText("Stop"); } else { spamMessage = null; button.setText("Start"); field.setEnabled(true); } } }); Timer timer = new Timer( 500, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sessionsButton.setText( sessionsButton.getText().split(" ")[0] + " (" + Integer.toString(sessionCount.get()) + ")"); joinsButton.setText( joinsButton.getText().split(" ")[0] + " (" + Integer.toString(amountJoined.get()) + ")"); } }); timer.setRepeats(true); timer.start(); frame.pack(); frame.setSize(500, frame.getHeight()); frame.setLocationRelativeTo(null); frame.setVisible(true); }
@Override public boolean onStart() { window = new JFrame("Interface Explorer"); treeModel = new InterfaceTreeModel(); treeModel.update(""); tree = new JTree(treeModel); tree.setRootVisible(false); tree.setEditable(false); renderer = new HighlightTreeCellRenderer(tree.getCellRenderer()); tree.setCellRenderer(renderer); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.addTreeSelectionListener( new TreeSelectionListener() { private void addInfo(final String key, final String value, final boolean highlight) { final JPanel row = new JPanel(); row.setAlignmentX(Component.LEFT_ALIGNMENT); row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS)); for (final String data : new String[] {key, value}) { final JLabel label = new JLabel(data); label.setAlignmentY(Component.TOP_ALIGNMENT); if (highlight) { label.setForeground(Color.magenta); } row.add(label); } infoArea.add(row); } public void valueChanged(final TreeSelectionEvent e) { final Object node = tree.getLastSelectedPathComponent(); if (node == null || node instanceof RSInterfaceWrap) { return; } infoArea.removeAll(); RSComponent iface = null; if (node instanceof RSComponentWrap) { iface = ((RSComponentWrap) node).wrapped; } if (iface == null) { return; } List<Integer> changes = new ArrayList<Integer>(); for (int i = 0; i < HighLightWraps.size(); i++) { if (iface.getParent() == null) { if (HighLightWraps.get(i).getChild().getIndex() == iface.getIndex() && HighLightWraps.get(i).getParent().getIndex() == iface.getInterface().getIndex()) { changes.add(HighLightWraps.get(i).getChange()); } } else { if (HighLightWraps.get(i).getChild().getIndex() == iface.getParent().getIndex() && HighLightWraps.get(i).getParent().getIndex() == iface.getParent().getInterface().getIndex()) { changes.add(HighLightWraps.get(i).getChange()); } } } addInfo("Type: ", "" + iface.getType(), changes.contains(1)); addInfo("SpecialType: ", "" + iface.getSpecialType(), changes.contains(2)); addInfo("Bounds Index: ", "" + iface.getBoundsArrayIndex(), changes.contains(3)); if (iface.getArea() != null) { Rectangle size = iface.getArea(); addInfo("Size: ", size.width + "," + size.height, changes.contains(15)); } addInfo("Model ID: ", "" + iface.getModelID(), changes.contains(4)); addInfo("Texture ID: ", "" + iface.getBackgroundColor(), changes.contains(5)); addInfo("Parent ID: ", "" + iface.getParentID(), changes.contains(6)); addInfo("Text: ", "" + iface.getText(), changes.contains(7)); addInfo("Tooltip: ", "" + iface.getTooltip(), changes.contains(8)); addInfo("SelActionName: ", "" + iface.getSelectedActionName(), changes.contains(9)); if (iface.getActions() != null) { String actions = ""; for (final String action : iface.getActions()) { if (!actions.equals("")) { actions += "\n"; } actions += action; } addInfo("Actions: ", actions, changes.contains(10)); } addInfo("Component ID: ", "" + iface.getComponentID(), changes.contains(11)); addInfo( "Component Stack Size: ", "" + iface.getComponentStackSize(), changes.contains(12)); addInfo( "Relative Location: ", "(" + iface.getRelativeX() + "," + iface.getRelativeY() + ")", changes.contains(13)); addInfo( "Absolute Location: ", "(" + iface.getAbsoluteX() + "," + iface.getAbsoluteY() + ")", changes.contains(14)); addInfo( "Rotation: ", "x: " + iface.getXRotation() + " y: " + iface.getYRotation() + " z: " + iface.getZRotation(), changes.contains(16)); setHighlightArea(iface.getArea()); infoArea.validate(); infoArea.repaint(); } }); final JDialog Help = new JDialog(); JScrollPane jScrollPane1; JTextArea jTextArea1; jScrollPane1 = new JScrollPane(); jTextArea1 = new JTextArea(); Help.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Help.setTitle("Help"); Help.setResizable(false); jTextArea1.setColumns(20); jTextArea1.setEditable(false); jTextArea1.setFont(new java.awt.Font("MS UI Gothic", 0, 12)); jTextArea1.setLineWrap(true); jTextArea1.setRows(5); jTextArea1.setText( "Once toggled the listener feature of the interface explorer will detect any changes made to Runescapes interfaces in realtime. If a change is found that interface and data will then be highlighted within the explorers tree model. To use the listener feature you would :\n\n1) Toggle the listener button as active\n2) Wait or commit changes in Runescape\n3) Repaint tree using repaint button or reclick interface folders in GUI\n\n\nTips : While listening for changes the tree model in the GUI will not update itself, changing colors. To refresh the GUI either use the repaint button or close and open Interface folder already within the tree model."); jTextArea1.setWrapStyleWord(true); jScrollPane1.setViewportView(jTextArea1); final GroupLayout layout = new GroupLayout(Help.getContentPane()); Help.getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE) .addContainerGap())); layout.setVerticalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addComponent( jScrollPane1, GroupLayout.PREFERRED_SIZE, 220, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); Help.pack(); JScrollPane scrollPane = new JScrollPane(tree); scrollPane.setPreferredSize(new Dimension(250, 500)); window.add(scrollPane, BorderLayout.WEST); infoArea = new JPanel(); infoArea.setLayout(new BoxLayout(infoArea, BoxLayout.Y_AXIS)); scrollPane = new JScrollPane(infoArea); scrollPane.setPreferredSize(new Dimension(250, 500)); window.add(scrollPane, BorderLayout.CENTER); final ActionListener actionListener = new ActionListener() { public void actionPerformed(final ActionEvent e) { treeModel.update(searchBox.getText()); infoArea.removeAll(); infoArea.validate(); infoArea.repaint(); } }; final ActionListener toggleListener = new ActionListener() { public void actionPerformed(final ActionEvent e) { if (listenerButton.isSelected()) { log("Cleared"); HighLightWraps.clear(); } check(); } }; final ActionListener repaintListener = new ActionListener() { public void actionPerformed(final ActionEvent e) { log("Refreshed Tree"); treeModel.fireTreeStructureChanged(treeModel.getRoot()); infoArea.removeAll(); infoArea.validate(); infoArea.repaint(); } }; final ActionListener helpListener = new ActionListener() { public void actionPerformed(final ActionEvent e) { Help.setVisible(true); } }; final JPanel toolArea = new JPanel(); toolArea.setLayout(new FlowLayout(FlowLayout.LEFT)); toolArea.add(new JLabel("Filter:")); searchBox = new JTextField(20); searchBox.addActionListener(actionListener); toolArea.add(searchBox); final JButton updateButton = new JButton("Update"); final JButton repaintButton = new JButton("Repaint"); final JButton helpButton = new JButton("Help"); helpButton.addActionListener(helpListener); listenerButton.addActionListener(toggleListener); updateButton.addActionListener(actionListener); repaintButton.addActionListener(repaintListener); toolArea.add(updateButton); toolArea.add(listenerButton); toolArea.add(repaintButton); toolArea.add(helpButton); window.add(toolArea, BorderLayout.NORTH); window.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); window.pack(); window.setVisible(true); return true; }
public JMovieControlAqua() { // Set the background color to the border color of the buttons. // This way the toolbar won't look too ugly when the buttons // are displayed before they have been loaded completely. // setBackground(new Color(118, 118, 118)); setBackground(Color.WHITE); Dimension buttonSize = new Dimension(16, 16); GridBagLayout gridbag = new GridBagLayout(); Insets margin = new Insets(0, 0, 0, 0); setLayout(gridbag); GridBagConstraints c; ResourceBundle labels = ResourceBundle.getBundle("org.monte.media.Labels"); colorCyclingButton = new JToggleButton(); colorCyclingButton.setToolTipText(labels.getString("colorCycling.toolTipText")); colorCyclingButton.addActionListener(this); colorCyclingButton.setPreferredSize(buttonSize); colorCyclingButton.setMinimumSize(buttonSize); colorCyclingButton.setVisible(false); colorCyclingButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 0; // c.gridy = 0; gridbag.setConstraints(colorCyclingButton, c); add(colorCyclingButton); audioButton = new JToggleButton(); audioButton.setToolTipText(labels.getString("audio.toolTipText")); audioButton.addActionListener(this); audioButton.setPreferredSize(buttonSize); audioButton.setMinimumSize(buttonSize); audioButton.setVisible(false); audioButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 0; // c.gridy = 0; gridbag.setConstraints(audioButton, c); add(audioButton); startButton = new JToggleButton(); startButton.setToolTipText(labels.getString("play.toolTipText")); startButton.addActionListener(this); startButton.setPreferredSize(buttonSize); startButton.setMinimumSize(buttonSize); startButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 1; // c.gridy = 0; gridbag.setConstraints(startButton, c); add(startButton); slider = new JMovieSliderAqua(); c = new GridBagConstraints(); // c.gridx = 2; // c.gridy = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; gridbag.setConstraints(slider, c); add(slider); rewindButton = new JButton(); rewindButton.setToolTipText(labels.getString("previous.toolTipText")); rewindButton.setPreferredSize(buttonSize); rewindButton.setMinimumSize(buttonSize); rewindButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 3; // c.gridy = 0; gridbag.setConstraints(rewindButton, c); add(rewindButton); rewindButton.addActionListener(this); forwardButton = new JButton(); forwardButton.setToolTipText(labels.getString("next.toolTipText")); buttonSize = new Dimension(17, 16); forwardButton.setPreferredSize(buttonSize); forwardButton.setMinimumSize(buttonSize); forwardButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 4; // c.gridy = 0; gridbag.setConstraints(forwardButton, c); add(forwardButton); forwardButton.addActionListener(this); // The spacer is used when the play controls are hidden spacer = new JPanel(new BorderLayout()); spacer.setVisible(false); spacer.setPreferredSize(new Dimension(16, 16)); spacer.setMinimumSize(new Dimension(16, 16)); spacer.setOpaque(false); c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; gridbag.setConstraints(spacer, c); add(spacer); Border border = new BackdropBorder( new ButtonStateBorder( new ImageBevelBorder( Images.createImage(getClass(), "images/Player.border.png"), new Insets(1, 1, 1, 1), new Insets(0, 4, 1, 4)), new ImageBevelBorder( Images.createImage(getClass(), "images/Player.borderP.png"), new Insets(1, 1, 1, 1), new Insets(0, 4, 1, 4)))); Border westBorder = new BackdropBorder( new ButtonStateBorder( new ImageBevelBorder( Images.createImage(getClass(), "images/Player.borderWest.png"), new Insets(1, 1, 1, 0), new Insets(0, 4, 1, 4)), new ImageBevelBorder( Images.createImage(getClass(), "images/Player.borderWestP.png"), new Insets(1, 1, 1, 0), new Insets(0, 4, 1, 4)))); startButton.setBorder(westBorder); colorCyclingButton.setBorder(westBorder); audioButton.setBorder(westBorder); rewindButton.setBorder(westBorder); forwardButton.setBorder(border); startButton.setUI((ButtonUI) CustomButtonUI.createUI(startButton)); colorCyclingButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton)); audioButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton)); rewindButton.setUI((ButtonUI) CustomButtonUI.createUI(rewindButton)); forwardButton.setUI((ButtonUI) CustomButtonUI.createUI(forwardButton)); colorCyclingButton.setIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png"))); colorCyclingButton.setSelectedIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png"))); colorCyclingButton.setDisabledIcon( new ImageIcon( Images.createImage(getClass(), "images/PlayerStartColorCycling.disabled.png"))); audioButton.setIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.png"))); audioButton.setSelectedIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStopAudio.png"))); audioButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.disabled.png"))); startButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.png"))); startButton.setSelectedIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStop.png"))); startButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.disabled.png"))); rewindButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.png"))); rewindButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.disabled.png"))); forwardButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.png"))); forwardButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.disabled.png"))); // Automatic scrolling scrollHandler = new ScrollHandler(); scrollTimer = new Timer(60, scrollHandler); scrollTimer.setInitialDelay(300); // default InitialDelay? forwardButton.addMouseListener(scrollHandler); rewindButton.addMouseListener(scrollHandler); }
/** * Конструктор * * @param mediator Посредник родитьельского окна */ public ButtonToolBar(final IGuiMediator mediator) { this.mediator = mediator; try { locale = ((WBDrawing) mediator).getLocalizer(); } catch (Exception e) { logger.debug(e.getMessage(), e); } mouseMenu = new JPopupMenu(); imagePanel = new JPanel(); imagePanel.setLayout(new GridLayout(4, 2)); mouseMenu.add(imagePanel); imagePanel.addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) { System.out.println("Focus Gained"); } public void focusLost(FocusEvent e) { mouseMenu.setVisible(false); System.out.println("Focus Lost"); } }); URL url = ClassLoader.getSystemResource("img/open.gif"); Icon iconOpen = new ImageIcon(url); JButton btnOpen = new JButton(iconOpen); btnOpen.setToolTipText(locale.getString("btntoolbar.open")); url = ClassLoader.getSystemResource("img/save.gif"); Icon iconSave = new ImageIcon(url); JButton btnSave = new JButton(iconSave); btnSave.setToolTipText(locale.getString("btntoolbar.save")); url = ClassLoader.getSystemResource("img/undo.gif"); Icon iconUndo = new ImageIcon(url); btnUndo = new JButton(iconUndo); btnUndo.setToolTipText(locale.getString("btntoolbar.undo")); url = ClassLoader.getSystemResource("img/redo.gif"); Icon iconRedo = new ImageIcon(url); btnRedo = new JButton(iconRedo); btnRedo.setToolTipText(locale.getString("btntoolbar.redo")); url = ClassLoader.getSystemResource("img/draw.gif"); Icon iconDraw = new ImageIcon(url); btnDraw = new JToggleButton(iconDraw, true); btnDraw.setToolTipText(locale.getString("btntoolbar.draw")); url = ClassLoader.getSystemResource("img/pen.gif"); Icon iconPen = new ImageIcon(url); btnPen = new JToggleButton(iconPen); btnPen.setToolTipText(locale.getString("btntoolbar.pen")); url = ClassLoader.getSystemResource("img/calibrate.gif"); Icon iconCalibrate = new ImageIcon(url); btnCalibrate = new JToggleButton(iconCalibrate); btnCalibrate.setToolTipText(locale.getString("btntoolbar.calibration")); url = ClassLoader.getSystemResource("img/gridMove.gif"); Icon iconGridMove = new ImageIcon(url); JToggleButton btnGrigMove = new JToggleButton(iconGridMove); url = ClassLoader.getSystemResource("img/hand.gif"); Icon iconHand = new ImageIcon(url); JToggleButton btnHand = new JToggleButton(iconHand); btnHand.setToolTipText(locale.getString("btntoolbar.hand")); url = ClassLoader.getSystemResource("img/selTool.gif"); Icon iconSelTool = new ImageIcon(url); JToggleButton btnSelTool = new JToggleButton(iconSelTool); url = ClassLoader.getSystemResource("img/spline.gif"); Icon iconQuadTool = new ImageIcon(url); btnSpline = new JToggleButton(iconQuadTool); btnSpline.setToolTipText(locale.getString("btntoolbar.spline")); btnTools = new JToggleButton("T"); btnTextTool = new JToggleButton("A"); url = ClassLoader.getSystemResource("img/ruler.gif"); Icon iconRulerTool = new ImageIcon(url); btnRulerTool = new JToggleButton(iconRulerTool); url = ClassLoader.getSystemResource("img/sendFile.gif"); Icon iconSendFile = new ImageIcon(url); JToggleButton btnFileTransmit = new JToggleButton(iconSendFile); btnFileTransmit.setToolTipText(locale.getString("btntoolbar.fileTransmit")); url = ClassLoader.getSystemResource("img/nodesEdit.gif"); Icon iconNodesEdit = new ImageIcon(url); JToggleButton btnNodesEdit = new JToggleButton(iconNodesEdit); btnNodesEdit.setToolTipText(locale.getString("btntoolbar.nodeEdit")); JButton btnTest = new JButton(locale.getString("btntoolbar.button.Test")); btnTest.setEnabled(false); url = ClassLoader.getSystemResource("img/send.gif"); Icon iconSend = new ImageIcon(url); JButton btnSendArq = new JButton(iconSend); btnSendArq.setToolTipText(locale.getString("btntoolbar.send")); url = ClassLoader.getSystemResource("img/clear.gif"); Icon iconClear = new ImageIcon(url); JButton btnClearTab = new JButton(iconClear); btnClearTab.setToolTipText(locale.getString("btntoolbar.clear")); JButton btnRequestModel = new JButton(locale.getString("btntoolbar.button.RequestModel")); btnRequestModel.setEnabled(false); JComboBox cmbTools = new JComboBox(); cmbTools.addItem("Thick Line"); cmbTools.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean selected = btnTools.getModel().isSelected(); if (selected) { mode = getToolsMode(); guiChanged(); } } }); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(btnDraw); buttonGroup.add(btnPen); buttonGroup.add(btnCalibrate); buttonGroup.add(btnGrigMove); buttonGroup.add(btnHand); buttonGroup.add(btnSelTool); buttonGroup.add(btnSpline); buttonGroup.add(btnTextTool); buttonGroup.add(btnRulerTool); buttonGroup.add(btnNodesEdit); // buttonGroup.add( btnTools ); btnDraw.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_DRAWING; } guiChanged(); } }); btnPen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_PEN; } guiChanged(); } }); btnCalibrate.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_CALIBRATING; } guiChanged(); } }); btnGrigMove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_GRID_MOVING; } guiChanged(); } }); btnHand.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_HAND_MAP; } guiChanged(); } }); btnSelTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_SELECT_TOOL; } guiChanged(); } }); btnSpline.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_QUAD_TOOL; } guiChanged(); } }); btnTextTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_TEXT_TOOL; } guiChanged(); } }); btnRulerTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_RULER_TOOL; } guiChanged(); } }); btnNodesEdit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_NODES_EDIT; } guiChanged(); } }); btnTools.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mode = getToolsMode(); guiChanged(); } }); btnOpen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnOpenPressed(); } }); btnSave.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSavePressed(); } }); btnUndo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnUndoPressed(); } }); btnRedo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnRedoPressed(); } }); btnTest.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnTestPressed(); } }); btnSendArq.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSendModelPressed(); } }); btnSendArq.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSendArqModelPressed(); } }); btnClearTab.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnClearTabPressed(); } }); btnRequestModel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnFileTransmitPressed(); } }); btnFileTransmit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnFileTransmitPressed(); } }); add(btnOpen); add(btnSave); // add( btnUndo ); // add( btnRedo ); addSeparator(); // add(lblMode); actionButton = new JToggleButton(btnDraw.getIcon()); actionButton.setToolTipText(btnDraw.getToolTipText()); actionButton.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { mouseMenu.show(e.getComponent(), e.getX(), e.getY()); } }); addButton(btnDraw); addButton(btnPen); addButton(btnCalibrate); // add( btnGrigMove ); addButton(btnHand); // add(btnSelTool); addButton(btnSpline); addButton(btnNodesEdit); // add( btnTextTool ); addButton(btnRulerTool); // addSeparator(); // add(cmbTools); add(actionButton); cmbScale = new JComboBox(); cmbScale.setEditable(true); cmbScale.addItem("1:1000"); cmbScale.addItem("1:2000"); cmbScale.addItem("1:5000"); cmbScale.addItem("1:10000"); cmbScale.addItem("1:25000"); cmbScale.addItem("1:50000"); cmbScale.addItem("1:100000"); cmbScale.setSelectedIndex(3); cmbScale.setToolTipText(locale.getString("btntoolbar.scale")); cmbScale.setPreferredSize(cmbScale.getMinimumSize()); cmbScale.setMaximumSize(cmbScale.getMinimumSize()); cmbScale.addItemListener(new ZoomListener()); addSeparator(); chbVisibleGrid = new JCheckBox(); chbVisibleGrid.setSelected(true); chbVisibleGrid.setToolTipText(locale.getString("btntoolbar.grid")); // addSeparator(); chbVisibleGrid.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { guiChanged(); } }); add(btnFileTransmit); add(btnSendArq); add(btnClearTab); add(chbVisibleGrid); add(cmbScale); // addSeparator(); // add( lblControl ); // add( btnSend ); // add( btnRequestModel ); // add( btnTest ); }
public void setToolbarButton(JToggleButton tb) { this.toolbarButton = tb; tb.addActionListener(this); }
private void initComponents() { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // If Nimbus is not available, you can set the GUI to another look and feel. } usernameLabel = new JLabel(); usernameField = new JTextField(); chatroomScrollPane = new JScrollPane(); chatroomArea = new JTextArea(); chatMsgLabel = new JLabel(); chatMsgField = new JTextField(); chatIPLabel = new JLabel(); chatIPField = new JTextField(); portLabel = new JLabel(); portField = new JTextField(); joinButton = new JToggleButton(); sendButton = new JButton(); leaveButton = new JButton(); exitButton = new JButton(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); usernameLabel.setText("Username:"******" "); chatroomArea.setEditable(false); chatroomArea.setColumns(20); chatroomArea.setRows(5); chatroomScrollPane.setViewportView(chatroomArea); chatMsgLabel.setText("Chat Message:"); chatIPLabel.setText("Chat Group IP"); chatIPField.setText("224.27.43.188"); portLabel.setText("Port"); portField.setText("4001"); joinButton.setText("JOIN CHAT"); joinButton.addActionListener(this); sendButton.setText("SEND MESSAGE"); sendButton.addActionListener(this); leaveButton.setText("LEAVE CHAT"); leaveButton.addActionListener(this); exitButton.setText("EXIT"); exitButton.addActionListener(this); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(usernameLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent( usernameField, GroupLayout.PREFERRED_SIZE, 83, GroupLayout.PREFERRED_SIZE)) .addComponent(chatroomScrollPane) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addComponent(chatMsgLabel) .addPreferredGap( LayoutStyle.ComponentPlacement.RELATED) .addComponent( chatMsgField, GroupLayout.PREFERRED_SIZE, 296, GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup( GroupLayout.Alignment.TRAILING, false) .addComponent( chatIPField, GroupLayout.Alignment.LEADING) .addComponent( chatIPLabel, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup( layout .createParallelGroup( GroupLayout.Alignment.LEADING, false) .addComponent( portField, GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE) .addComponent( portLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup( layout .createParallelGroup( GroupLayout.Alignment.LEADING, false) .addGroup( layout .createSequentialGroup() .addComponent(leaveButton) .addGap(18, 18, 18) .addComponent( exitButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup( layout .createSequentialGroup() .addComponent( joinButton, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(sendButton))))) .addGap(0, 8, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(usernameField) .addComponent( usernameLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(3, 3, 3) .addComponent( chatroomScrollPane, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent( chatMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( chatMsgField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(chatIPLabel) .addComponent(portLabel)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent( chatIPField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( portField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGroup( layout .createSequentialGroup() .addGap(16, 16, 16) .addGroup( layout .createParallelGroup( GroupLayout.Alignment.LEADING, false) .addComponent( joinButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( sendButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(8, 8, 8) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(leaveButton) .addComponent(exitButton)))) .addGap(17, 17, 17))); pack(); setVisible(true); }
/** Initialiser. */ private void init() { invokePopupButton = new JToggleButton("Show popup"); invokePopupButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // set popup window visibility if (!popupWindow.isVisible()) { // set location relative to button Point location = invokePopupButton.getLocation(); SwingUtilities.convertPointToScreen(location, invokePopupButton.getParent()); location.translate( 0, invokePopupButton.getHeight() + (invokePopupButton.getBorder() == null ? 0 : invokePopupButton .getBorder() .getBorderInsets(invokePopupButton) .bottom)); popupWindow.setLocation(location); // show the popup if not visible invokePopupButton.setText("Hide popup"); popupWindow.setVisible(true); popupWindow.requestFocus(); } else { // hide it otherwise invokePopupButton.setText("Show popup"); popupWindow.setVisible(false); } } }); // add components to main panel this.setLayout(new BorderLayout()); this.add(invokePopupButton, BorderLayout.CENTER); // use frame popupWindow = new JFrame(); popupWindow.setUndecorated(true); popupWindow.addWindowFocusListener( new WindowFocusListener() { public void windowGainedFocus(WindowEvent e) {} public void windowLostFocus(WindowEvent e) { SwingUtilities.invokeLater( new Runnable() { public void run() { if (popupWindow.isVisible()) invokePopupButton.doClick(); } }); } }); // add some components to window popupWindow.getContentPane().setLayout(new BorderLayout()); ((JComponent) popupWindow.getContentPane()).setBorder(BorderFactory.createEtchedBorder()); JTextField aTextField = new JTextField(10); popupWindow.getContentPane().add(new JLabel("Text:"), BorderLayout.WEST); popupWindow.getContentPane().add(aTextField); popupWindow.pack(); }
public LJ3MDApp() { tNum.setHorizontalAlignment(JTextField.CENTER); tTemp.setHorizontalAlignment(JTextField.CENTER); tRho.setHorizontalAlignment(JTextField.CENTER); tSpeed.setHorizontalAlignment(JTextField.CENTER); tAvK.setHorizontalAlignment(JTextField.RIGHT); tAvU.setHorizontalAlignment(JTextField.RIGHT); tAvp.setHorizontalAlignment(JTextField.RIGHT); float[] aveKing = new float[501]; float[] avePot = new float[501]; float[] aveEn = new float[501]; JFrame box = new JFrame(); box.setLayout(new BorderLayout()); box.setSize(1000, 1000); box.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); cpnl = new JPanel(); // create a panel for controls cpnl.setLayout(new GridLayout(18, 2)); box.add(cpnl, BorderLayout.EAST); // add controls cpnl.add(bStart); bStart.addActionListener(this); cpnl.add(bReset); bReset.addActionListener(this); cpnl.add(new JLabel(" N:")); tNum.addActionListener(this); cpnl.add(tNum); cpnl.add(new JLabel(" Density (\u03c1):")); tRho.addActionListener(this); cpnl.add(tRho); cpnl.add(new JLabel(" Steps/frame:")); tSpeed.addActionListener(this); cpnl.add(tSpeed); cpnl.add(bTstat); bTstat.addActionListener(this); cpnl.add(bPot); bPot.addActionListener(this); cpnl.add(new JLabel(" < K/N > :")); tAvK.setEditable(false); cpnl.add(tAvK); cpnl.add(new JLabel(" Temperature:")); tTemp.setEditable(false); cpnl.add(tTemp); cpnl.add(new JLabel(" < U/N > :")); tAvU.setEditable(false); cpnl.add(tAvU); cpnl.add(new JLabel(" < pressure > :")); tAvp.setEditable(false); cpnl.add(tAvp); cpnl.add(bRetime); bRetime.addActionListener(this); spnl = new JPanel(); // create a panel for status box.add(spnl, BorderLayout.SOUTH); lStatus.setFont(new Font("Courier", 0, 12)); spnl.add(lStatus); canvas = new XYZCanvas(); box.add(canvas, BorderLayout.CENTER); timer = new Timer(delay, this); timer.start(); // timer.stop(); box.setVisible(true); }
public PanelSpec(SmedAction dia) { dlg = dia; setLayout(null); add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSPP)); add(getShapeButton(sparButton, 34, 0, 34, 32, "Spar", Shp.SPAR, Obj.BOYSPP)); add(getShapeButton(canButton, 68, 0, 34, 32, "Can", Shp.CAN, Obj.BOYSPP)); add(getShapeButton(coneButton, 102, 0, 34, 32, "Cone", Shp.CONI, Obj.BOYSPP)); add(getShapeButton(sphereButton, 0, 32, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSPP)); add(getShapeButton(barrelButton, 34, 32, 34, 32, "Barrel", Shp.BARREL, Obj.BOYSPP)); add(getShapeButton(superButton, 68, 32, 34, 32, "Super", Shp.SUPER, Obj.BOYSPP)); add(getShapeButton(floatButton, 102, 32, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT)); add(getShapeButton(beaconButton, 0, 64, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSPP)); add(getShapeButton(towerButton, 34, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNSPP)); add(getShapeButton(stakeButton, 68, 64, 34, 32, "Stake", Shp.STAKE, Obj.BCNSPP)); add(getShapeButton(cairnButton, 102, 64, 34, 32, "CairnB", Shp.CAIRN, Obj.BCNSPP)); categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER); categoryLabel.setBounds(new Rectangle(5, 125, 160, 18)); add(categoryLabel); categoryBox = new JComboBox(); categoryBox.setBounds(new Rectangle(5, 142, 160, 18)); add(categoryBox); categoryBox.setVisible(true); categoryBox.addActionListener(alCategoryBox); addCatItem("", Cat.NOCAT); addCatItem(Messages.getString("UKPurpose"), Cat.SPM_UNKN); addCatItem(Messages.getString("Warning"), Cat.SPM_WARN); addCatItem(Messages.getString("ChanSeparation"), Cat.SPM_CHBF); addCatItem(Messages.getString("Yachting"), Cat.SPM_YCHT); addCatItem(Messages.getString("Cable"), Cat.SPM_CABL); addCatItem(Messages.getString("Outfall"), Cat.SPM_OFAL); addCatItem(Messages.getString("ODAS"), Cat.SPM_ODAS); addCatItem(Messages.getString("RecreationZone"), Cat.SPM_RECN); addCatItem(Messages.getString("Mooring"), Cat.SPM_MOOR); addCatItem(Messages.getString("LANBY"), Cat.SPM_LNBY); addCatItem(Messages.getString("Leading"), Cat.SPM_LDNG); addCatItem(Messages.getString("Notice"), Cat.SPM_NOTC); addCatItem(Messages.getString("TSS"), Cat.SPM_TSS); addCatItem(Messages.getString("FoulGround"), Cat.SPM_FOUL); addCatItem(Messages.getString("Diving"), Cat.SPM_DIVE); addCatItem(Messages.getString("FerryCross"), Cat.SPM_FRRY); addCatItem(Messages.getString("Anchorage"), Cat.SPM_ANCH); mooringBox = new JComboBox(); mooringBox.setBounds(new Rectangle(5, 142, 160, 18)); add(mooringBox); mooringBox.setVisible(false); mooringBox.addActionListener(alMooringBox); addMorItem("", Cat.NOCAT); addMorItem(Messages.getString("Dolphin"), Cat.MOR_DLPN); addMorItem(Messages.getString("DevDolphin"), Cat.MOR_DDPN); addMorItem(Messages.getString("Bollard"), Cat.MOR_BLRD); addMorItem(Messages.getString("Wall"), Cat.MOR_WALL); addMorItem(Messages.getString("Post"), Cat.MOR_POST); addMorItem(Messages.getString("Chain"), Cat.MOR_CHWR); addMorItem(Messages.getString("Rope"), Cat.MOR_ROPE); addMorItem(Messages.getString("Automatic"), Cat.MOR_AUTO); addMorItem(Messages.getString("MooringBuoy"), Cat.MOR_BUOY); addMorItem(Messages.getString("CALM"), Cat.INB_CALM); addMorItem(Messages.getString("SBM"), Cat.INB_SBM); topmarkButton.setBounds(new Rectangle(136, 0, 34, 32)); topmarkButton.setToolTipText(Messages.getString("Topmark")); topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); topmarkButton.addActionListener(alTop); add(topmarkButton); // noticeButton.setBounds(new Rectangle(136, 32, 34, 32)); // noticeButton.setToolTipText(Messages.getString("Notice")); // noticeButton.setBorder(BorderFactory.createLoweredBevelBorder()); // noticeButton.addActionListener(alNotice); // add(noticeButton); mooringButton.setBounds(new Rectangle(136, 64, 34, 32)); mooringButton.setToolTipText(Messages.getString("Mooring")); mooringButton.setBorder(BorderFactory.createLoweredBevelBorder()); mooringButton.addActionListener(alMooring); add(mooringButton); }
private void jbInit() throws Exception { border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); border2 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); border3 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder1 = new TitledBorder(border3, "Subject"); border4 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder2 = new TitledBorder(border4, "Message"); border5 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder3 = new TitledBorder(border5, "Subject"); border6 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); titledBorder4 = new TitledBorder(border6, "Message"); border7 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); titledBorder5 = new TitledBorder(border7, "Messages"); border8 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); titledBorder6 = new TitledBorder(border8, "Online Users"); border9 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder7 = new TitledBorder(border9, "Send Message"); this.getContentPane().setLayout(borderLayout1); jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT); jSplitPane1.setBorder(border1); jSplitPane1.setLastDividerLocation(250); jSplitPane1.setResizeWeight(1.0); jLabelServer.setRequestFocusEnabled(true); jLabelServer.setText("Server"); jLabelUserId.setText("User Id"); jTextFieldServer.setPreferredSize(new Dimension(75, 20)); jTextFieldServer.setText(""); jTextFieldUser.setPreferredSize(new Dimension(75, 20)); jTextFieldUser.setText(""); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setJMenuBar(jMenuBarMain); this.setTitle("Message Client"); jLabeltargetUser.setText("Target"); jTextFieldTargetUser.setPreferredSize(new Dimension(75, 20)); jTextFieldTargetUser.setText(""); jPanelSendMessages.setBorder(border2); jPanelSendMessages.setMaximumSize(new Dimension(32767, 32767)); jPanelSendMessages.setOpaque(false); jPanelSendMessages.setPreferredSize(new Dimension(96, 107)); jPanelSendMessages.setRequestFocusEnabled(true); jPanelSendMessages.setToolTipText(""); jPanelSendMessages.setLayout(verticalFlowLayout1); jTextFieldSendSubject.setBorder(titledBorder3); jTextFieldSendSubject.setText(""); jTextFieldSendSubject.addKeyListener(new Client_jTextFieldSendSubject_keyAdapter(this)); jSplitPane2.setOrientation(JSplitPane.HORIZONTAL_SPLIT); jScrollPane1.setBorder(titledBorder5); jScrollPane2.setBorder(titledBorder6); jToggleButtonRegister.setText("Register"); jToggleButtonRegister.addActionListener(new Client_jToggleButtonRegister_actionAdapter(this)); jButtonMultiConnect.setText("Multi-Connect"); jButtonMultiConnect.addActionListener(new Client_jButtonMultiConnect_actionAdapter(this)); jListOnlineUsers.addMouseListener(new Client_jListOnlineUsers_mouseAdapter(this)); jToggleButtonConnect.setText("Connect"); jToggleButtonConnect.addActionListener(new Client_jToggleButtonConnect_actionAdapter(this)); jTextPaneDisplayMessages.setEditable(false); jTextPaneDisplayMessages.addMouseListener( new Client_jTextPaneDisplayMessages_mouseAdapter(this)); jTextFieldSendMessages.setBorder(titledBorder7); jTextFieldSendMessages.setToolTipText(""); jTextFieldSendMessages.addKeyListener(new Client_jTextFieldSendMessages_keyAdapter(this)); jButtonMessageStresser.setText("Msg Stresser"); jButtonMessageStresser.addActionListener( new Client_jToggleButtonMessageStresser_actionAdapter(this)); jMenuItemClearMessages.setText("Clear Messages"); jMenuItemClearMessages.addActionListener(new Client_jMenuItemClearMessages_actionAdapter(this)); jMenuServer.setText("Server"); jMenuItemServerConnect.setText("Connect"); jMenuItemServerConnect.addActionListener(new Client_jMenuItemServerConnect_actionAdapter(this)); jMenuItemServerDisconnect.setText("Disconnect"); jMenuItemServerDisconnect.addActionListener( new Client_jMenuItemServerDisconnect_actionAdapter(this)); jMenuOptions.setText("Options"); jMenuTest.setText("Test"); jMenuItemOptionsRegister.setText("Register"); jMenuItemOptionsRegister.addActionListener( new Client_jMenuItemOptionsRegister_actionAdapter(this)); jMenuItemOptionsDeregister.setText("Deregister"); jMenuItemOptionsDeregister.addActionListener( new Client_jMenuItemOptionsDeregister_actionAdapter(this)); jMenuItemOptionsEavesdrop.setText("Eavesdrop"); jMenuItemOptionsEavesdrop.addActionListener( new Client_jMenuItemOptionsEavesdrop_actionAdapter(this)); jMenuItemOptionsUneavesdrop.setText("Uneavesdrop"); jMenuItemOptionsUneavesdrop.addActionListener( new Client_jMenuItemOptionsUneavesdrop_actionAdapter(this)); jMenuItemTestMulticonnect.setText("Multiconnect"); jMenuItemTestMulticonnect.addActionListener( new Client_jMenuItemTestMulticonnect_actionAdapter(this)); jMenuItemTestMessageStresser.setText("Message Stresser"); jMenuItemTestMessageStresser.addActionListener( new Client_jMenuItemTestMessageStresser_actionAdapter(this)); jMenuItemTestMultidisconnect.setText("Multidisconnect"); jMenuItemTestMultidisconnect.addActionListener( new Client_jMenuItemTestMultidisconnect_actionAdapter(this)); jMenuItemOptionsGlobalEavesdrop.setText("Global Eavesdrop"); jMenuItemOptionsGlobalEavesdrop.addActionListener( new Client_jMenuItemOptionsGlobalEavesdrop_actionAdapter(this)); jMenuItemOptionsGlobalUneavesdrop.setEnabled(false); jMenuItemOptionsGlobalUneavesdrop.setText("Global Uneavesdrop"); jMenuItemOptionsGlobalUneavesdrop.addActionListener( new Client_jMenuItemOptionsGlobalUneavesdrop_actionAdapter(this)); jLabelPwd.setText("Pwd"); jPasswordFieldPwd.setMinimumSize(new Dimension(11, 20)); jPasswordFieldPwd.setPreferredSize(new Dimension(75, 20)); jPasswordFieldPwd.setText(""); jMenuItemScheduleCommand.setText("Schedule Command"); jMenuItemScheduleCommand.addActionListener( new Client_jMenuItemScheduleCommand_actionAdapter(this)); jMenuItemEditScheduledCommands.setText("Edit Scheduled Commands"); jMenuItemEditScheduledCommands.addActionListener( new Client_jMenuItemEditScheduledCommands_actionAdapter(this)); jPanelSendMessages.add(jTextFieldSendSubject, null); jPanelSendMessages.add(jTextFieldSendMessages, null); jSplitPane1.add(jSplitPane2, JSplitPane.TOP); jSplitPane2.add(jScrollPane1, JSplitPane.TOP); jScrollPane1.getViewport().add(jTextPaneDisplayMessages, null); jSplitPane2.add(jScrollPane2, JSplitPane.BOTTOM); jScrollPane2.getViewport().add(jListOnlineUsers, null); this.getContentPane().add(jSplitPane1, BorderLayout.CENTER); jSplitPane1.add(jPanelSendMessages, JSplitPane.BOTTOM); this.getContentPane().add(jPanel1, BorderLayout.NORTH); jPanel1.add(jLabelServer, null); jPanel1.add(jTextFieldServer, null); jPanel1.add(jLabelUserId, null); jPanel1.add(jTextFieldUser, null); jPanel1.add(jLabelPwd, null); jPanel1.add(jPasswordFieldPwd, null); jPanel1.add(jLabeltargetUser, null); jPanel1.add(jTextFieldTargetUser, null); jPanel1.add(jToggleButtonConnect, null); jPanel1.add(jToggleButtonRegister, null); jPanel1.add(jButtonMultiConnect, null); jPanel1.add(jButtonMessageStresser, null); jPopupMenuMessageArea.add(jMenuItemClearMessages); jMenuBarMain.add(jMenuServer); jMenuBarMain.add(jMenuOptions); jMenuBarMain.add(jMenuTest); jMenuServer.add(jMenuItemServerConnect); jMenuServer.add(jMenuItemServerDisconnect); jMenuOptions.add(jMenuItemOptionsRegister); jMenuOptions.add(jMenuItemOptionsDeregister); jMenuOptions.add(jMenuItemOptionsEavesdrop); jMenuOptions.add(jMenuItemOptionsUneavesdrop); jMenuOptions.add(jMenuItemOptionsGlobalEavesdrop); jMenuOptions.add(jMenuItemOptionsGlobalUneavesdrop); jMenuTest.add(jMenuItemTestMulticonnect); jMenuTest.add(jMenuItemTestMultidisconnect); jMenuTest.add(jMenuItemTestMessageStresser); jMenuTest.add(jMenuItemScheduleCommand); jMenuTest.add(jMenuItemEditScheduledCommands); jSplitPane1.setDividerLocation(200); jSplitPane2.setDividerLocation(600); jListOnlineUsers.setCellRenderer(new OnlineListCellRenderer()); jListOnlineUsers.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); jMenuItemTestMulticonnect.setEnabled(true); jMenuItemTestMultidisconnect.setEnabled(false); jMenuItemServerConnect.setEnabled(true); jMenuItemServerDisconnect.setEnabled(false); jMenuItemOptionsRegister.setEnabled(true); jMenuItemOptionsDeregister.setEnabled(false); }
public void jbInit() throws Exception { this.setLayout(null); fContractPriceTextField.setFont(new java.awt.Font("Dialog", 1, 11)); fContractPriceTextField.setDisabledTextColor(Color.black); fContractPriceTextField.setEditable(false); fContractPriceTextField.setHorizontalAlignment(SwingConstants.RIGHT); fContractPriceTextField.setBounds(new java.awt.Rectangle(285, 182, 55, 21)); fContractVolumeTextField.setFont(new java.awt.Font("Dialog", 1, 11)); fContractVolumeTextField.setDisabledTextColor(Color.black); fContractVolumeTextField.setEditable(false); fContractVolumeTextField.setHorizontalAlignment(SwingConstants.RIGHT); fContractVolumeTextField.setBounds(new java.awt.Rectangle(285, 238, 55, 21)); fContractVolumeLabel.setText(fRb.getString("CONTRACT_VOLUME")); fContractVolumeLabel.setForeground(Color.black); fContractVolumeLabel.setBounds(new java.awt.Rectangle(272, 218, 99, 17)); fContractPriceLabel.setBounds(new java.awt.Rectangle(272, 160, 92, 17)); fContractPriceLabel.setText(fRb.getString("CONTRACT_PRICE")); fContractPriceLabel.setForeground(Color.black); fBoardGraph.setLayout(borderLayout1); fDay.setBounds(new java.awt.Rectangle(337, 87, 42, 21)); fDayLabel.setText(fRb.getString("DAY") + ":"); fDayLabel.setForeground(Color.black); fDayLabel.setBounds(new java.awt.Rectangle(267, 89, 67, 17)); fBoardLabel.setText(fRb.getString("SESSION") + ":"); fBoardLabel.setForeground(Color.black); fBoardLabel.setBounds(new java.awt.Rectangle(267, 121, 68, 17)); fBoard.setBounds(new java.awt.Rectangle(337, 119, 42, 22)); fPreviousBoardLabel.setFont(new java.awt.Font("Dialog", 1, 12)); fPreviousBoardLabel.setText(fRb.getString("PREVIOUS_PRICING")); fPreviousBoardLabel.setForeground(Color.black); fPreviousBoardLabel.setBounds(new java.awt.Rectangle(85, 4, 99, 17)); fXYToggleButton.setBorder(BorderFactory.createRaisedBevelBorder()); fXYToggleButton.setText("Exchange X-Y"); fXYToggleButton.setBounds(new java.awt.Rectangle(268, 43, 114, 25)); fXYToggleButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { fIsExchangeXY = fXYToggleButton.isSelected(); fIsUpdated = true; gUpdate(); } }); this.setBorder(BorderFactory.createEtchedBorder()); this.setBounds(new java.awt.Rectangle(325, 7, 387, 283)); this.setLayout(null); fBoardGraph.setBorder(BorderFactory.createEtchedBorder()); fBoardGraph.setBounds(new java.awt.Rectangle(5, 26, 257, 243)); fBoardGraph.getGraph().add(new UGraphData(fSellName, fSellColor)); fBoardGraph.getGraph().add(new UGraphData(fBuyName, fBuyColor)); fBoardGraph.setLeftMargin(60); this.add(fBoardGraph, null); this.add(fContractVolumeTextField, null); this.add(fContractVolumeLabel, null); this.add(fContractPriceTextField, null); this.add(fContractPriceLabel, null); this.add(fBoardLabel, null); this.add(fDayLabel, null); this.add(fXYToggleButton, null); this.add(fPreviousBoardLabel, null); this.add(fDay, null); this.add(fBoard, null); fBoardGraph.setBackground(Color.white); fBoardGraph.setNumOfHorizontalLine(0); fBoardGraph.setNumOfVerticalLine(0); fBoardGraph.setFixedMaxX(1); fBoardGraph.setFixedMinX(0); fBoardGraph.setFixedMaxY(1); fBoardGraph.setFixedMinY(0); addComponentListener( new ComponentAdapter() { public void componentShown(ComponentEvent ce) { gUpdate(); } }); }
private void setupRightSideToolBar() { JToolBar fixedTools = new JToolBar(); fixedTools.setOrientation(JToolBar.HORIZONTAL); JButton cutB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "cut.png").getImage())); cutB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); cutB.setToolTipText("Cut selected (Ctrl+X)"); JButton copyB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "page_copy.png").getImage())); copyB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); copyB.setToolTipText("Copy selected (Ctrl+C)"); JButton pasteB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "paste_plain.png").getImage())); pasteB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); pasteB.setToolTipText("Paste from clipboard (Ctrl+V)"); JButton deleteB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "delete.png").getImage())); deleteB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); deleteB.setToolTipText("Delete selected (DEL)"); final JToggleButton snapToGridB = new JToggleButton(new ImageIcon(loadIcon(ICON_PATH + "shape_handles.png").getImage())); // m_snapToGridB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); snapToGridB.setToolTipText("Snap to grid (Ctrl+G)"); JButton saveB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "disk.png").getImage())); saveB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); saveB.setToolTipText("Save layout (Ctrl+S)"); JButton saveBB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "disk_multiple.png").getImage())); saveBB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); saveBB.setToolTipText("Save layout with new name"); JButton loadB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "folder_add.png").getImage())); loadB.setToolTipText("Open (Ctrl+O)"); loadB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); JButton newB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "page_add.png").getImage())); newB.setToolTipText("New layout (Ctrl+N)"); newB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); newB.setEnabled(m_mainPerspective.getAllowMultipleTabs()); final JButton helpB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "help.png").getImage())); helpB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); helpB.setToolTipText("Display help (Ctrl+H)"); JButton togglePerspectivesB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "cog_go.png").getImage())); togglePerspectivesB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); togglePerspectivesB.setToolTipText("Show/hide perspectives toolbar (Ctrl+P)"); final JButton templatesB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "application_view_tile.png").getImage())); templatesB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); templatesB.setToolTipText("Load a template layout"); JButton noteB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "note_add.png").getImage())); noteB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); noteB.setToolTipText("Add a note to the layout (Ctrl+I)"); JButton selectAllB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "shape_group.png").getImage())); selectAllB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); selectAllB.setToolTipText("Select all (Ctrl+A)"); final JButton zoomInB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "zoom_in.png").getImage())); zoomInB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); zoomInB.setToolTipText("Zoom in (Ctrl++)"); final JButton zoomOutB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "zoom_out.png").getImage())); zoomOutB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); zoomOutB.setToolTipText("Zoom out (Ctrl+-)"); JButton undoB = new JButton(new ImageIcon(loadIcon(ICON_PATH + "arrow_undo.png").getImage())); undoB.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); undoB.setToolTipText("Undo (Ctrl+U)"); // actions final Action saveAction = new AbstractAction("Save") { @Override public void actionPerformed(ActionEvent e) { if (m_mainPerspective.getCurrentTabIndex() >= 0) { m_mainPerspective.saveLayout(m_mainPerspective.getCurrentTabIndex(), false); } } }; KeyStroke saveKey = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("Save", saveAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(saveKey, "Save"); saveB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveAction.actionPerformed(e); } }); KeyStroke saveAsKey = KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK); final Action saveAsAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { m_mainPerspective.saveLayout(m_mainPerspective.getCurrentTabIndex(), true); } }; m_mainPerspective.getActionMap().put("SaveAS", saveAsAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(saveAsKey, "SaveAS"); saveBB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveAsAction.actionPerformed(e); } }); final Action openAction = new AbstractAction("Open") { @Override public void actionPerformed(ActionEvent e) { m_mainPerspective.loadLayout(); } }; KeyStroke openKey = KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("Open", openAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(openKey, "Open"); loadB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openAction.actionPerformed(e); } }); final Action newAction = new AbstractAction("New") { @Override public void actionPerformed(ActionEvent e) { m_mainPerspective.addUntitledTab(); } }; KeyStroke newKey = KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("New", newAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(newKey, "New"); newB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { newAction.actionPerformed(ae); } }); final Action selectAllAction = new AbstractAction("SelectAll") { @Override public void actionPerformed(ActionEvent e) { if (m_mainPerspective.getCurrentLayout() != null && m_mainPerspective.getCurrentLayout().numSteps() > 0) { List<StepVisual> newSelected = newSelected = new ArrayList<StepVisual>(); newSelected.addAll(m_mainPerspective.getCurrentLayout().getRenderGraph()); // toggle if (newSelected.size() == m_mainPerspective.getCurrentLayout().getSelectedSteps().size()) { // unselect all m_mainPerspective.getCurrentLayout().setSelectedSteps(new ArrayList<StepVisual>()); } else { // select all m_mainPerspective.getCurrentLayout().setSelectedSteps(newSelected); } m_mainPerspective.revalidate(); m_mainPerspective.repaint(); m_mainPerspective.notifyIsDirty(); } } }; KeyStroke selectAllKey = KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("SelectAll", selectAllAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(selectAllKey, "SelectAll"); selectAllB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectAllAction.actionPerformed(e); } }); final Action zoomInAction = new AbstractAction("ZoomIn") { @Override public void actionPerformed(ActionEvent e) { if (m_mainPerspective.getCurrentLayout() != null) { int z = m_mainPerspective.getCurrentLayout().getZoomSetting(); z += 25; zoomOutB.setEnabled(true); if (z >= 200) { z = 200; zoomInB.setEnabled(false); } m_mainPerspective.getCurrentLayout().setZoomSetting(z); m_mainPerspective.revalidate(); m_mainPerspective.repaint(); m_mainPerspective.notifyIsDirty(); } } }; KeyStroke zoomInKey = KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("ZoomIn", zoomInAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(zoomInKey, "ZoomIn"); zoomInB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { zoomInAction.actionPerformed(e); } }); final Action zoomOutAction = new AbstractAction("ZoomOut") { @Override public void actionPerformed(ActionEvent e) { if (m_mainPerspective.getCurrentLayout() != null) { int z = m_mainPerspective.getCurrentLayout().getZoomSetting(); z -= 25; zoomInB.setEnabled(true); if (z <= 50) { z = 50; zoomOutB.setEnabled(false); } m_mainPerspective.getCurrentLayout().setZoomSetting(z); m_mainPerspective.revalidate(); m_mainPerspective.repaint(); m_mainPerspective.notifyIsDirty(); } } }; KeyStroke zoomOutKey = KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("ZoomOut", zoomOutAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(zoomOutKey, "ZoomOut"); zoomOutB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { zoomOutAction.actionPerformed(e); } }); final Action cutAction = new AbstractAction("Cut") { @Override public void actionPerformed(ActionEvent e) { if (m_mainPerspective.getCurrentLayout() != null && m_mainPerspective.getCurrentLayout().getSelectedSteps().size() > 0) { try { m_mainPerspective.getCurrentLayout().copySelectedStepsToClipboard(); m_mainPerspective.getCurrentLayout().removeSelectedSteps(); } catch (WekaException e1) { m_mainPerspective.showErrorDialog(e1); } } } }; KeyStroke cutKey = KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("Cut", cutAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(cutKey, "Cut"); cutB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cutAction.actionPerformed(e); } }); final Action deleteAction = new AbstractAction("Delete") { @Override public void actionPerformed(ActionEvent e) { if (m_mainPerspective.getCurrentLayout() != null) { try { m_mainPerspective.getCurrentLayout().removeSelectedSteps(); } catch (WekaException e1) { m_mainPerspective.showErrorDialog(e1); } } } }; KeyStroke deleteKey = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0); m_mainPerspective.getActionMap().put("Delete", deleteAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(deleteKey, "Delete"); deleteB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteAction.actionPerformed(e); } }); final Action copyAction = new AbstractAction("Copy") { @Override public void actionPerformed(ActionEvent e) { if (m_mainPerspective.getCurrentLayout() != null && m_mainPerspective.getCurrentLayout().getSelectedSteps().size() > 0) { try { m_mainPerspective.getCurrentLayout().copySelectedStepsToClipboard(); m_mainPerspective.getCurrentLayout().setSelectedSteps(new ArrayList<StepVisual>()); } catch (WekaException e1) { m_mainPerspective.showErrorDialog(e1); } } } }; KeyStroke copyKey = KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("Copy", copyAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(copyKey, "Copy"); copyB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { copyAction.actionPerformed(e); } }); final Action pasteAction = new AbstractAction("Paste") { @Override public void actionPerformed(ActionEvent e) { if (m_mainPerspective.getCurrentLayout() != null && m_mainPerspective.getPasteBuffer().length() > 0) { m_mainPerspective.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); m_mainPerspective .getCurrentLayout() .setFlowLayoutOperation(VisibleLayout.LayoutOperation.PASTING); } } }; KeyStroke pasteKey = KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("Paste", pasteAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(pasteKey, "Paste"); pasteB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteAction.actionPerformed(e); } }); final Action snapAction = new AbstractAction("Snap") { @Override public void actionPerformed(ActionEvent e) { // toggle first // snapToGridB.setSelected(!snapToGridB.isSelected()); if (snapToGridB.isSelected()) { if (m_mainPerspective.getCurrentLayout() != null) { m_mainPerspective.getCurrentLayout().snapSelectedToGrid(); } } } }; KeyStroke snapKey = KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("Snap", snapAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(snapKey, "Snap"); snapToGridB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (snapToGridB.isSelected()) { snapAction.actionPerformed(e); } } }); final Action noteAction = new AbstractAction("Note") { @Override public void actionPerformed(ActionEvent e) { if (m_mainPerspective.getCurrentLayout() != null) { m_mainPerspective.getCurrentLayout().initiateAddNote(); } } }; KeyStroke noteKey = KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("Note", noteAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(noteKey, "Note"); noteB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { noteAction.actionPerformed(e); } }); final Action undoAction = new AbstractAction("Undo") { @Override public void actionPerformed(ActionEvent e) { if (m_mainPerspective.getCurrentLayout() != null) { m_mainPerspective.getCurrentLayout().popAndLoadUndo(); } } }; KeyStroke undoKey = KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("Undo", undoAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(undoKey, "Undo"); undoB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { undoAction.actionPerformed(e); } }); final Action helpAction = new AbstractAction("Help") { @Override public void actionPerformed(ActionEvent e) { popupHelp(helpB); } }; KeyStroke helpKey = KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("Help", helpAction); m_mainPerspective.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(helpKey, "Help"); helpB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { helpAction.actionPerformed(ae); } }); templatesB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // createTemplateMenuPopup(); PopupMenu popupMenu = new PopupMenu(); List<String> builtinTemplates = m_mainPerspective.getTemplateManager().getBuiltinTemplateDescriptions(); List<String> pluginTemplates = m_mainPerspective.getTemplateManager().getPluginTemplateDescriptions(); for (final String desc : builtinTemplates) { MenuItem menuItem = new MenuItem(desc); menuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Flow templateFlow = m_mainPerspective.getTemplateManager().getTemplateFlow(desc); m_mainPerspective.addTab(desc); m_mainPerspective.getCurrentLayout().setFlow(templateFlow); } catch (WekaException ex) { m_mainPerspective.showErrorDialog(ex); } } }); popupMenu.add(menuItem); } if (builtinTemplates.size() > 0 && pluginTemplates.size() > 0) { popupMenu.addSeparator(); } for (final String desc : pluginTemplates) { MenuItem menuItem = new MenuItem(desc); menuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Flow templateFlow = m_mainPerspective.getTemplateManager().getTemplateFlow(desc); m_mainPerspective.addTab(desc); m_mainPerspective.getCurrentLayout().setFlow(templateFlow); } catch (WekaException ex) { m_mainPerspective.showErrorDialog(ex); } } }); popupMenu.add(menuItem); } templatesB.add(popupMenu); popupMenu.show(templatesB, 0, 0); } }); templatesB.setEnabled(m_mainPerspective.getTemplateManager().numTemplates() > 0); final Action togglePerspectivesAction = new AbstractAction("Toggle perspectives") { @Override public void actionPerformed(ActionEvent e) { if (!Utils.getDontShowDialog("weka.gui.knowledgeflow.PerspectiveInfo")) { JCheckBox dontShow = new JCheckBox("Do not show this message again"); Object[] stuff = new Object[2]; stuff[0] = "Perspectives are environments that take over the\n" + "Knowledge Flow UI and provide major additional functionality.\n" + "Many perspectives will operate on a set of instances. Instances\n" + "Can be sent to a perspective by placing a DataSource on the\n" + "layout canvas, configuring it and then selecting \"Send to perspective\"\n" + "from the contextual popup menu that appears when you right-click on\n" + "it. Several perspectives are built in to the Knowledge Flow, others\n" + "can be installed via the package manager.\n"; stuff[1] = dontShow; JOptionPane.showMessageDialog( m_mainPerspective, stuff, "Perspective information", JOptionPane.OK_OPTION); if (dontShow.isSelected()) { try { Utils.setDontShowDialog("weka.gui.Knowledgeflow.PerspectiveInfo"); } catch (Exception ex) { // quietly ignore } } } if (m_mainPerspective.getMainApplication().isPerspectivesToolBarVisible()) { m_mainPerspective.getMainApplication().hidePerspectivesToolBar(); } else { m_mainPerspective.getMainApplication().showPerspectivesToolBar(); } m_mainPerspective.revalidate(); m_mainPerspective.notifyIsDirty(); } }; KeyStroke togglePerspectivesKey = KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK); m_mainPerspective.getActionMap().put("Toggle perspectives", togglePerspectivesAction); m_mainPerspective .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(togglePerspectivesKey, "Toggle perspectives"); togglePerspectivesB.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { togglePerspectivesAction.actionPerformed(e); } }); addWidgetToToolBar(fixedTools, Widgets.ZOOM_IN_BUTTON.toString(), zoomInB); addMenuItemToMenu("View", Widgets.ZOOM_IN_BUTTON.toString(), zoomInAction, zoomInKey); addWidgetToToolBar(fixedTools, Widgets.ZOOM_OUT_BUTTON.toString(), zoomOutB); addMenuItemToMenu("View", Widgets.ZOOM_OUT_BUTTON.toString(), zoomOutAction, zoomOutKey); fixedTools.addSeparator(); addWidgetToToolBar(fixedTools, Widgets.SELECT_ALL_BUTTON.toString(), selectAllB); addWidgetToToolBar(fixedTools, Widgets.CUT_BUTTON.toString(), cutB); addMenuItemToMenu("Edit", Widgets.CUT_BUTTON.toString(), cutAction, cutKey); addWidgetToToolBar(fixedTools, Widgets.COPY_BUTTON.toString(), copyB); addMenuItemToMenu("Edit", Widgets.COPY_BUTTON.toString(), copyAction, copyKey); addMenuItemToMenu("Edit", Widgets.PASTE_BUTTON.toString(), pasteAction, pasteKey); addWidgetToToolBar(fixedTools, Widgets.DELETE_BUTTON.toString(), deleteB); addMenuItemToMenu("Edit", Widgets.DELETE_BUTTON.toString(), deleteAction, deleteKey); addWidgetToToolBar(fixedTools, Widgets.PASTE_BUTTON.toString(), pasteB); addWidgetToToolBar(fixedTools, Widgets.UNDO_BUTTON.toString(), undoB); addMenuItemToMenu("Edit", Widgets.UNDO_BUTTON.toString(), undoAction, undoKey); addWidgetToToolBar(fixedTools, Widgets.NOTE_BUTTON.toString(), noteB); addMenuItemToMenu("Insert", Widgets.NOTE_BUTTON.toString(), noteAction, noteKey); fixedTools.addSeparator(); addWidgetToToolBar(fixedTools, Widgets.SNAP_TO_GRID_BUTTON.toString(), snapToGridB); fixedTools.addSeparator(); addWidgetToToolBar(fixedTools, Widgets.NEW_FLOW_BUTTON.toString(), newB); addMenuItemToMenu("File", Widgets.NEW_FLOW_BUTTON.toString(), newAction, newKey); addWidgetToToolBar(fixedTools, Widgets.SAVE_FLOW_BUTTON.toString(), saveB); addMenuItemToMenu("File", Widgets.LOAD_FLOW_BUTTON.toString(), openAction, openKey); addMenuItemToMenu("File", Widgets.SAVE_FLOW_BUTTON.toString(), saveAction, saveKey); addWidgetToToolBar(fixedTools, Widgets.SAVE_FLOW_AS_BUTTON.toString(), saveBB); addMenuItemToMenu("File", Widgets.SAVE_FLOW_AS_BUTTON.toString(), saveAction, saveAsKey); addWidgetToToolBar(fixedTools, Widgets.LOAD_FLOW_BUTTON.toString(), loadB); addWidgetToToolBar(fixedTools, Widgets.TEMPLATES_BUTTON.toString(), templatesB); fixedTools.addSeparator(); addWidgetToToolBar( fixedTools, Widgets.TOGGLE_PERSPECTIVES_BUTTON.toString(), togglePerspectivesB); addWidgetToToolBar(fixedTools, Widgets.HELP_BUTTON.toString(), helpB); Dimension d = undoB.getPreferredSize(); Dimension d2 = fixedTools.getMinimumSize(); Dimension d3 = new Dimension(d2.width, d.height + 4); fixedTools.setPreferredSize(d3); fixedTools.setMaximumSize(d3); fixedTools.setFloatable(false); add(fixedTools, BorderLayout.EAST); }