/** Add FocusListener. */ public void addFocusListener(FocusListener listener) { if (moneyField != null) { moneyField.addFocusListener(listener); } super.addFocusListener(listener); }
/** @param buttonPanel */ protected void installFocusHandlers(JPanel buttonPanel) { // disable buttons when this "frame" is defocused FocusListener focusListener = new FocusListener() { public void focusGained(FocusEvent e) { moveButton.setEnabled(true); closeButton.setEnabled(true); } public void focusLost(FocusEvent e) { moveButton.setEnabled(false); closeButton.setEnabled(false); } }; textarea.addFocusListener(focusListener); // have to put the focus listener on every component else it doesn't work every time buttonPanel.addFocusListener(focusListener); moveButton.addFocusListener(focusListener); closeButton.addFocusListener(focusListener); }
public XLightBreakpointPropertiesPanel( Project project, XBreakpointManager breakpointManager, B breakpoint, boolean showAllOptions) { myBreakpoint = breakpoint; XBreakpointType<B, ?> breakpointType = XBreakpointUtil.getType(breakpoint); mySuspendPolicyPanel.init(project, breakpointManager, breakpoint); mySuspendPolicyPanel.setDelegate(this); mySubPanels.add(mySuspendPolicyPanel); myMasterBreakpointPanel.init(project, breakpointManager, breakpoint); mySubPanels.add(myMasterBreakpointPanel); XDebuggerEditorsProvider debuggerEditorsProvider = breakpointType.getEditorsProvider(breakpoint, project); myActionsPanel.init(project, breakpointManager, breakpoint, debuggerEditorsProvider); mySubPanels.add(myActionsPanel); if (debuggerEditorsProvider != null) { myConditionComboBox = new XDebuggerExpressionComboBox( project, debuggerEditorsProvider, "breakpointCondition", myBreakpoint.getSourcePosition()); JComponent conditionComponent = myConditionComboBox.getComponent(); myConditionExpressionPanel.add(conditionComponent, BorderLayout.CENTER); } else { myConditionPanel.setVisible(false); } myShowMoreOptions = false; for (XBreakpointPropertiesSubPanel<B> panel : mySubPanels) { if (panel.lightVariant(showAllOptions)) { myShowMoreOptions = true; } } myCustomPanels = new ArrayList<XBreakpointCustomPropertiesPanel<B>>(); XBreakpointCustomPropertiesPanel<B> customPropertiesPanel = breakpointType.createCustomPropertiesPanel(); if (customPropertiesPanel != null) { myCustomPropertiesPanelWrapper.add(customPropertiesPanel.getComponent(), BorderLayout.CENTER); myCustomPanels.add(customPropertiesPanel); } XBreakpointCustomPropertiesPanel<B> customConditionPanel = breakpointType.createCustomConditionsPanel(); if (customConditionPanel != null) { myCustomConditionsPanelWrapper.add(customConditionPanel.getComponent(), BorderLayout.CENTER); myCustomPanels.add(customConditionPanel); } myMainPanel.addFocusListener( new FocusAdapter() { @Override public void focusGained(FocusEvent event) { if (myConditionComboBox != null) { IdeFocusManager.findInstance() .requestFocus(myConditionComboBox.getComponent(), false); } } }); myEnabledCheckbox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { myBreakpoint.setEnabled(myEnabledCheckbox.isSelected()); } }); }
/** * Конструктор * * @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 ); }
/** creates a JTextfield with JLabel (contains labelText) and an identifier id */ public TLangTextField(String labelText, int id, FieldPopup popup) { super(); // this.setOpaque( false ) ; this.setLayout(new OverlayLayout(this)); // this.setBorder( BorderFactory.createEtchedBorder()); listenerList = new EventListenerList(); // build the labeled textfield -------------------------------------------- textField = new IDTextField(id, popup) { public void paint(Graphics g) { super.paint(g); if (currentImage != null) { Graphics2D g2 = (Graphics2D) g; g2.drawImage(currentImage, -8, -2, this); } // System.out.println( "paint " +(counter++) ) ; } }; textField.addKeyListener(this); textField.addFocusListener(this); textField.setPopupName(labelText); textField.setMaximumSize(new Dimension(2000, 30)); textField.setFont(GUIGlobals.defaultLanguageFont); // charat position leerInsets = textField.getMargin(); label = new JLabel(labelText, JLabel.TRAILING); label.setLabelFor(textField); label.addFocusListener(this); // insert label and textfield layout = new SpringLayout(); bigPanel = new JPanel(layout); // bigPanel.setOpaque( false ) ; bigPanel.add(label); bigPanel.add(textField); // Adjust constraints for the label so it's at (5,5). layout.putConstraint(SpringLayout.WEST, label, 10, SpringLayout.WEST, bigPanel); layout.putConstraint(SpringLayout.NORTH, label, 6, SpringLayout.NORTH, bigPanel); // Adjust constraints for the text field so it's at // (<label's right edge> + 5, 5). layout.putConstraint(SpringLayout.WEST, textField, 10, SpringLayout.EAST, label); layout.putConstraint(SpringLayout.NORTH, textField, -2, SpringLayout.NORTH, label); // Adjust constraints for the content pane: Its right // edge should be 5 pixels beyond the text field's right // edge, and its bottom edge should be 5 pixels beyond // the bottom edge of the tallest component (which we'll // assume is textField). layout.putConstraint(SpringLayout.EAST, bigPanel, 5, SpringLayout.EAST, textField); layout.putConstraint( SpringLayout.SOUTH, bigPanel, // 8, // SpringLayout.SOUTH, label ) ; 5, SpringLayout.SOUTH, textField); // build image section ---------------------------------------------------- imageLabel = new JLabel(); imageLabel.setOpaque(false); fieldState = REQUIRE_STATE; setImage(); textField.other = imageLabel; // insert image and labeled-field ----------------------------------------- this.add(imageLabel); this.add(bigPanel); // pipe all focus events to local class methods super.addFocusListener(this); }