private void listPeople() { try { jScrollPane1.getViewport().setView(null); JFlowPanel jPeople = new JFlowPanel(); jPeople.applyComponentOrientation(getComponentOrientation()); java.util.List people = m_dlSystem.listPeopleVisible(); for (int i = 0; i < people.size(); i++) { AppUser user = (AppUser) people.get(i); JButton btn = new JButton(new AppUserAction(user)); btn.applyComponentOrientation(getComponentOrientation()); btn.setFocusPainted(false); btn.setFocusable(false); btn.setRequestFocusEnabled(false); btn.setHorizontalAlignment(SwingConstants.LEADING); btn.setMaximumSize(new Dimension(150, 50)); btn.setPreferredSize(new Dimension(150, 50)); btn.setMinimumSize(new Dimension(150, 50)); jPeople.add(btn); } jScrollPane1.getViewport().setView(jPeople); } catch (BasicException ee) { ee.printStackTrace(); } }
public ButtonsPanel() { super(); setOpaque(true); for (JButton b : buttons) { b.setFocusable(false); b.setRolloverEnabled(false); add(b); } }
/* * We do custom rendering of the arrow button because there are too many * hacks in each theme's combobox UI. * We also cannot forward paint of the arrow button to a stock combobox * because each LAF and theme may render different parts of the * arrow button with different sizes. For example, in Mac, the arrow button is * drawn with a border (the responsibility of the border * near the arrow button belongs to the button). However in IntelliJ and Darcula, * the arrow button is drawn without a border and it's the responsibility of the * outer control to draw a border. In addition, darcula renders part of the arrow * button outside the button. That is, the arrow button looks like it's about 20x20, * but actually, it's only 16x16, with part of the rendering done via paint on the combobox itself. * So while this creates some small inconsistencies, * it reduces the chance of a major UI issue such as a completely poorly drawn button with a double border. */ private JButton createArrowButton() { final Color bg = getBackground(); final Color fg = getForeground(); JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) { @Override public void paint(Graphics g2) { final Graphics2D g = (Graphics2D) g2; final GraphicsConfig config = new GraphicsConfig(g); final int w = getWidth(); final int h = getHeight(); g.setColor(getButtonBackgroundColor()); g.fillRect(0, 0, w, h); g.setColor(getArrowColor()); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); final int midx = (int) Math.ceil((w - 1) / 2.0) + 1; final int midy = (int) Math.ceil(h / 2.0); final Path2D.Double path = new Path2D.Double(); path.moveTo(midx - 4, midy - 2); path.lineTo(midx + 4, midy - 2); path.lineTo(midx, midy + 4); path.lineTo(midx - 4, midy - 2); path.closePath(); g.fill(path); g.setColor(getBorderColor()); if (UIUtil.isUnderGTKLookAndFeel()) { g.drawLine(0, 1, 0, h - 2); g.drawLine(0, 1, w - 2, 1); g.drawLine(0, h - 2, w - 2, h - 2); g.drawLine(w - 2, 1, w - 2, h - 2); } else { g.drawLine(0, 0, 0, h); } config.restore(); } @Override public Dimension getPreferredSize() { int newSize = CustomizableComboBox.this.getHeight() - (CustomizableComboBox.this.getInsets().bottom + CustomizableComboBox.this.getInsets().top); return new Dimension(newSize, newSize); } }; button.setOpaque(false); button.setFocusable(false); button.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 1)); return button; }
public ButtonsRenderer(RemoveButtonComboBox<E> comboBox) { super(new BorderLayout(0, 0)); this.comboBox = comboBox; label.setOpaque(false); setOpaque(true); add(label); deleteButton.setBorder(BorderFactory.createEmptyBorder()); deleteButton.setFocusable(false); deleteButton.setRolloverEnabled(false); deleteButton.setContentAreaFilled(false); add(deleteButton, BorderLayout.EAST); }
private void initComponents() { btLogin.setFocusable(false); // Fókusz letiltása btSettings.setFocusable(false); // Fókusz letiltása btLogin.setBackground(Color.lightGray); // A "bejelentkezés" gomb háttérszínének beállítása btSettings.setBackground( pnLogin.getBackground()); // A "Beállítások" gomb háttérszínének beállítása tfUsername.setPreferredSize(new Dimension(120, 25)); // Szövegmező átméretezése pfPassword.setPreferredSize(new Dimension(120, 25)); // Jelszómező átméretezése tfUsername.addKeyListener(btEnabler); // A figyelő hozzáadása a felhasználónév mezőhőz pfPassword.addKeyListener(btEnabler); // A figyelő hozzáadása a jelszó mezőhőz }
/** * The class constructor. * * <p>Adds and creates a message saying bye. */ public Instruction2() { setLayout(null); JButton back = new JButton(new ImageIcon("Back.png")); back.setOpaque(false); back.setContentAreaFilled(false); back.setBorderPainted(false); back.setFocusable(false); back.setRolloverIcon(new ImageIcon("Backrollover.png")); back.setActionCommand("Back"); back.addActionListener(this); JLabel pic = new JLabel(new ImageIcon("Instructions2.png")); pic.setBounds(0, 0, pic.getPreferredSize().width, pic.getPreferredSize().height); back.setBounds(5, 200, back.getPreferredSize().width, back.getPreferredSize().height); add(pic); add(back); }
public ButtonsRenderer(DefaultListModel<E> model) { super(new BorderLayout()); this.model = model; setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0)); setOpaque(true); label.setLineWrap(true); label.setOpaque(false); add(label); Box box = Box.createHorizontalBox(); for (JButton b : Arrays.asList(deleteButton, copyButton)) { b.setFocusable(false); b.setRolloverEnabled(false); box.add(b); box.add(Box.createHorizontalStrut(5)); } add(box, BorderLayout.EAST); }
private static JButton createButton(String accessibleName, Icon icon, Action action) { JButton button = new JButton() { boolean mouseOverButton = false; { enableEvents(AWTEvent.MOUSE_EVENT_MASK); addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { mouseOverButton = true; repaint(); } @Override public void mouseExited(MouseEvent e) { mouseOverButton = false; repaint(); } }); } @Override protected void paintComponent(Graphics g) { final Window window = SwingUtilities.windowForComponent(this); float alpha = window.isActive() && mouseOverButton ? 1f : 0.5f; final GraphicsConfig config = GraphicsUtil.paintWithAlpha(g, alpha); getIcon().paintIcon(this, g, 0, 0); config.restore(); } }; button.setFocusPainted(false); button.setFocusable(false); button.setOpaque(false); button.putClientProperty("paintActive", Boolean.TRUE); button.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName); button.setBorder(JBUI.Borders.empty()); button.setText(null); button.setAction(action); button.setIcon(icon); return button; }
private void initToolbar() { JToolBar tbTraceFilters = new JToolBar(); tbTraceFilters.setFloatable(false); tbTraceFilters.setRollover(true); tbTraceFilters.add(new JLabel("Min time:")); txtMinTime = new JTextField(4); tbTraceFilters.add(txtMinTime); JButton btnFilterByTime = new JButton(new FilterByTimeAction()); btnFilterByTime.setFocusable(false); btnFilterByTime.setToolTipText("Filter by trace execution time"); tbTraceFilters.add(btnFilterByTime); tbTraceFilters.addSeparator(); btnFilterErrors = new JToggleButton(new FilterByErrorAction()); btnFilterErrors.setFocusable(false); btnFilterErrors.setToolTipText("Show only traces with errors"); tbTraceFilters.add(btnFilterErrors); tbTraceFilters.addSeparator(); cmbTraceType = new JComboBox(); cmbTraceType.addItem("*"); cmbTraceType.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { String item = (String) e.getItem(); traceLabel = "*".equals(item) ? null : item; tbmTraces.setDataSet(dataSet, traceFilter); } } }); tbTraceFilters.add(cmbTraceType); add(tbTraceFilters, BorderLayout.NORTH); }
Spacer(ZoneModel model, int index, SpacerHandle knobHandle) { this.model = model; this.index = index; this.knobHandle = knobHandle; knobPainter = new KnobPainter(this); setOpaque(false); setCursor(SliderCursor); initKeyMaps(); Icon icon = getIcon("unstick"); Icon pressedIcon = getIcon("unstickPressed"); Icon highlightIcon = getIcon("unstickHighlight"); unstickButton = new JButton(icon); unstickButton.setSize(icon.getIconWidth(), icon.getIconHeight()); unstickButton.setPressedIcon(pressedIcon); unstickButton.setRolloverEnabled(true); unstickButton.setRolloverIcon(highlightIcon); unstickButton.setBorder(null); unstickButton.putClientProperty(SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, Boolean.TRUE); unstickButton.setBorderPainted(false); unstickButton.setRolloverEnabled(true); unstickButton.setOpaque(false); unstickButton.setCursor(ClickCursor); unstickButton.setFocusable(false); unstickButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { Spacer.this.model.removePoint(Spacer.this.index); } }); if (model.containsPoint(index)) { add(unstickButton); } model.addZoneModelListener(this); setFocusable(true); addFocusListener(this); addMouseListener(this); }
// Takes resource name and returns button public JButton createButton(String name, String toolTip) { // load the image String imagePath = "./resources/" + name + ".png"; ImageIcon iconRollover = new ImageIcon(imagePath); int w = iconRollover.getIconWidth(); int h = iconRollover.getIconHeight(); // get the cursor for this button Cursor cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); // make translucent default image Image image = createCompatibleImage(w, h, Transparency.TRANSLUCENT); Graphics2D g = (Graphics2D) image.getGraphics(); Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f); g.setComposite(alpha); g.drawImage(iconRollover.getImage(), 0, 0, null); g.dispose(); ImageIcon iconDefault = new ImageIcon(image); // make a pressed image image = createCompatibleImage(w, h, Transparency.TRANSLUCENT); g = (Graphics2D) image.getGraphics(); g.drawImage(iconRollover.getImage(), 2, 2, null); g.dispose(); ImageIcon iconPressed = new ImageIcon(image); // create the button JButton button = new JButton(); button.addActionListener(this); button.setIgnoreRepaint(true); button.setFocusable(false); button.setToolTipText(toolTip); button.setBorder(null); button.setContentAreaFilled(false); button.setCursor(cursor); button.setIcon(iconDefault); button.setRolloverIcon(iconRollover); button.setPressedIcon(iconPressed); return button; }
public void addButtonRunnable(int index, final Runnable runnable, String text) { if (getBorder() == null) setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); final JButton button = new JButton(UIUtil.replaceMnemonicAmpersand(text)); DialogUtil.registerMnemonic(button); button.setFocusable(false); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { runnable.run(); } }); add(button, index); invalidate(); if (getParent() != null) { getParent().validate(); } }
private JComponent buildTopPanel(boolean enablePipette) throws ParseException { final JPanel result = new JPanel(new BorderLayout()); final JPanel previewPanel = new JPanel(new BorderLayout()); if (enablePipette && myPicker != null) { final JButton pipette = new JButton(); pipette.setUI(new BasicButtonUI()); pipette.setRolloverEnabled(true); pipette.setIcon(AllIcons.Ide.Pipette); pipette.setBorder(IdeBorderFactory.createEmptyBorder()); pipette.setRolloverIcon(AllIcons.Ide.Pipette_rollover); pipette.setFocusable(false); pipette.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myPicker.setInitialColor(getColor()); myPicker.show(); } }); previewPanel.add(pipette, BorderLayout.WEST); } myPreviewComponent = new ColorPreviewComponent(); previewPanel.add(myPreviewComponent, BorderLayout.CENTER); result.add(previewPanel, BorderLayout.NORTH); final JPanel rgbPanel = new JPanel(); rgbPanel.setLayout(new BoxLayout(rgbPanel, BoxLayout.X_AXIS)); if (!UIUtil.isUnderAquaLookAndFeel()) { myR_after.setPreferredSize(new Dimension(14, -1)); myG_after.setPreferredSize(new Dimension(14, -1)); myB_after.setPreferredSize(new Dimension(14, -1)); } rgbPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); rgbPanel.add(myR); rgbPanel.add(myRed); if (!UIUtil.isUnderAquaLookAndFeel()) rgbPanel.add(myR_after); rgbPanel.add(Box.createHorizontalStrut(2)); rgbPanel.add(myG); rgbPanel.add(myGreen); if (!UIUtil.isUnderAquaLookAndFeel()) rgbPanel.add(myG_after); rgbPanel.add(Box.createHorizontalStrut(2)); rgbPanel.add(myB); rgbPanel.add(myBlue); if (!UIUtil.isUnderAquaLookAndFeel()) rgbPanel.add(myB_after); rgbPanel.add(Box.createHorizontalStrut(2)); rgbPanel.add(myFormat); result.add(rgbPanel, BorderLayout.WEST); final JPanel hexPanel = new JPanel(); hexPanel.setLayout(new BoxLayout(hexPanel, BoxLayout.X_AXIS)); hexPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); hexPanel.add(new JLabel("#")); hexPanel.add(myHex); result.add(hexPanel, BorderLayout.EAST); return result; }
private void initComponents() { setPreferredSize(new java.awt.Dimension(420, 65)); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); JPanel textPanel = new JPanel(); SpringLayout textLayout = new SpringLayout(); textPanel.setLayout(textLayout); this.add(buttonPanel); this.add(textPanel); // button area abortButton_ = new JButton(); abortButton_.setBackground(new java.awt.Color(255, 255, 255)); abortButton_.setIcon( new javax.swing.ImageIcon( getClass().getResource("/org/micromanager/icons/cancel.png"))); // NOI18N abortButton_.setToolTipText("Abort acquisition"); abortButton_.setFocusable(false); abortButton_.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); abortButton_.setMaximumSize(new java.awt.Dimension(30, 28)); abortButton_.setMinimumSize(new java.awt.Dimension(30, 28)); abortButton_.setPreferredSize(new java.awt.Dimension(30, 28)); abortButton_.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); abortButton_.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { JavaUtils.invokeRestrictedMethod(vad_, VirtualAcquisitionDisplay.class, "abort"); } catch (Exception ex) { ReportingUtils.showError( "Couldn't abort. Try pressing stop on Multi-Dimensional acquisition Window"); } } }); buttonPanel.add(abortButton_); pauseButton_ = new JButton(); pauseButton_.setIcon( new javax.swing.ImageIcon( getClass().getResource("/org/micromanager/icons/control_pause.png"))); // NOI18N pauseButton_.setToolTipText("Pause acquisition"); pauseButton_.setFocusable(false); pauseButton_.setMargin(new java.awt.Insets(0, 0, 0, 0)); pauseButton_.setMaximumSize(new java.awt.Dimension(30, 28)); pauseButton_.setMinimumSize(new java.awt.Dimension(30, 28)); pauseButton_.setPreferredSize(new java.awt.Dimension(30, 28)); pauseButton_.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { try { JavaUtils.invokeRestrictedMethod(vad_, VirtualAcquisitionDisplay.class, "pause"); } catch (Exception ex) { ReportingUtils.showError("Couldn't pause"); } if (eng_.isPaused()) { pauseButton_.setIcon( new javax.swing.ImageIcon( getClass() .getResource("/org/micromanager/icons/resultset_next.png"))); // NOI18N } else { pauseButton_.setIcon( new javax.swing.ImageIcon( getClass() .getResource("/org/micromanager/icons/control_pause.png"))); // NOI18N } } }); buttonPanel.add(pauseButton_); gridXSpinner_ = new JSpinner(); gridXSpinner_.setModel(new SpinnerNumberModel(2, 1, 1000, 1)); gridXSpinner_.setPreferredSize(new Dimension(35, 24)); gridYSpinner_ = new JSpinner(); gridYSpinner_.setModel(new SpinnerNumberModel(2, 1, 1000, 1)); gridYSpinner_.setPreferredSize(new Dimension(35, 24)); gridXSpinner_.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { gridSizeChanged(); } }); gridYSpinner_.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { gridSizeChanged(); } }); final JLabel gridLabel = new JLabel(" grid"); final JLabel byLabel = new JLabel("by"); gridLabel.setEnabled(false); byLabel.setEnabled(false); gridXSpinner_.setEnabled(false); gridYSpinner_.setEnabled(false); final JButton createGridButton = new JButton("Create"); createGridButton.setEnabled(false); createGridButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { createGrid(); } }); newGridButton_ = new JToggleButton("New grid"); buttonPanel.add(new JLabel(" ")); buttonPanel.add(newGridButton_); newGridButton_.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newGridButton_.isSelected()) { makeGridOverlay( vad_.getImagePlus().getWidth() / 2, vad_.getImagePlus().getHeight() / 2); newGridButton_.setText("Cancel"); gridLabel.setEnabled(true); byLabel.setEnabled(true); gridXSpinner_.setEnabled(true); gridYSpinner_.setEnabled(true); createGridButton.setEnabled(true); } else { vad_.getImagePlus().getOverlay().clear(); vad_.getImagePlus().getCanvas().repaint(); newGridButton_.setText("New grid"); gridLabel.setEnabled(false); byLabel.setEnabled(false); gridXSpinner_.setEnabled(false); gridYSpinner_.setEnabled(false); createGridButton.setEnabled(false); } } }); buttonPanel.add(gridXSpinner_); buttonPanel.add(byLabel); buttonPanel.add(gridYSpinner_); buttonPanel.add(gridLabel); buttonPanel.add(createGridButton); // text area zPosLabel_ = new JLabel("Z position: "); textPanel.add(zPosLabel_); timeStampLabel_ = new JLabel("Elapsed time: "); textPanel.add(timeStampLabel_); fpsField_ = new JTextField(); fpsField_.setText("7"); fpsField_.setToolTipText("Set the speed at which the acquisition is played back."); fpsField_.setPreferredSize(new Dimension(25, 18)); fpsField_.addFocusListener( new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { updateFPS(); } }); fpsField_.addKeyListener( new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { updateFPS(); } }); JLabel fpsLabel = new JLabel("Animation playback FPS: "); textPanel.add(fpsLabel); textPanel.add(fpsField_); textLayout.putConstraint(SpringLayout.WEST, textPanel, 0, SpringLayout.WEST, zPosLabel_); textLayout.putConstraint( SpringLayout.EAST, zPosLabel_, 0, SpringLayout.WEST, timeStampLabel_); textLayout.putConstraint(SpringLayout.EAST, timeStampLabel_, 0, SpringLayout.WEST, fpsLabel); textLayout.putConstraint(SpringLayout.EAST, fpsLabel, 0, SpringLayout.WEST, fpsField_); textLayout.putConstraint(SpringLayout.EAST, fpsField_, 0, SpringLayout.EAST, textPanel); textLayout.putConstraint(SpringLayout.NORTH, fpsField_, 0, SpringLayout.NORTH, textPanel); textLayout.putConstraint(SpringLayout.NORTH, zPosLabel_, 3, SpringLayout.NORTH, textPanel); textLayout.putConstraint( SpringLayout.NORTH, timeStampLabel_, 3, SpringLayout.NORTH, textPanel); textLayout.putConstraint(SpringLayout.NORTH, fpsLabel, 3, SpringLayout.NORTH, textPanel); }
public p2() throws Exception { // setBorder(BorderFactory.createEtchedBorder(Color.lightGray, Color.DARK_GRAY)); p = new JPanel(); // setBackground(Color.white); p.setLayout(new GridLayout(11, 3)); p.setBounds(0, 20, 309, 130); un = new JLabel("* Username"); ps1 = new JLabel("* Password"); ps2 = new JLabel("* Confirm Password"); fn = new JLabel("* First Name"); ln = new JLabel(" Last Name"); eid = new JLabel("* Email ID"); mb = new JLabel("* Mobile"); cct = new JLabel("* Current City"); hquali = new JLabel("* Highest Qualification"); dob = new JLabel(" DOB"); dober = new JLabel(); dd = new JLabel("DD"); mm = new JLabel("MM"); yy = new JLabel("YY"); member = new Label(" already a member?"); member.addMouseListener(this); er1 = new Label(""); er2 = new Label(""); er3 = new Label(""); er4 = new Label(""); er5 = new Label(""); er6 = new Label(""); er7 = new Label(""); er8 = new Label(""); er9 = new Label(""); er10 = new Label(""); un1 = new JTextField(15); ps11 = new JPasswordField(15); ps21 = new JPasswordField(15); fn1 = new JTextField(15); ln1 = new JTextField(15); eid1 = new JTextField(15); mb1 = new JTextField(15); cct1 = new JTextField(15); hquali1 = new JTextField(15); dober1 = new JTextField(2); dober2 = new JTextField(2); dober3 = new JTextField(2); sub = new JButton("Sign up"); sub.setBorderPainted(false); sub.setFocusable(true); sub.addActionListener(this); dober.setLayout(new FlowLayout()); dober.add(dober1); dober.add(dd); dober.add(dober2); dober.add(mm); dober.add(dober3); dober.add(yy); p.add(fn); p.add(fn1); p.add(er1); p.add(ln); p.add(ln1); p.add(er2); p.add(un); p.add(un1); p.add(er3); p.add(ps1); p.add(ps11); p.add(er4); p.add(ps2); p.add(ps21); p.add(er5); p.add(eid); p.add(eid1); p.add(er6); p.add(mb); p.add(mb1); p.add(er7); p.add(cct); p.add(cct1); p.add(er8); p.add(hquali); p.add(hquali1); p.add(er9); p.add(dob); p.add(dober); p.add(er10); p.add(sub); p.add(member); add(p); }
private void initReplaceToolBars() { DefaultActionGroup actionGroup1 = new DefaultActionGroup("replace bar 1", false); myReplaceActionsToolbar1 = (ActionToolbarImpl) ActionManager.getInstance() .createActionToolbar(ActionPlaces.EDITOR_TOOLBAR, actionGroup1, true); myReplaceActionsToolbar1.setForceMinimumSize(true); final JButton myReplaceButton = new JButton("Replace"); myReplaceButton.setFocusable(false); myReplaceButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { replaceCurrent(); } }); final JButton myReplaceAllButton = new JButton("Replace all"); myReplaceAllButton.setFocusable(false); myReplaceAllButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { myLivePreviewController.performReplaceAll(); } }); final JButton myExcludeButton = new JButton(""); myExcludeButton.setFocusable(false); myExcludeButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { myLivePreviewController.exclude(); moveCursor(SearchResults.Direction.DOWN); } }); if (!UISettings.getInstance().DISABLE_MNEMONICS_IN_CONTROLS) { myReplaceButton.setMnemonic('p'); myReplaceAllButton.setMnemonic('a'); myExcludeButton.setMnemonic('l'); } actionGroup1.addAction( new DefaultCustomComponentAction(myReplaceButton) { @Override public void update(AnActionEvent e) { myReplaceButton.setEnabled(canReplaceCurrent()); } }); actionGroup1.addAction( new DefaultCustomComponentAction(myReplaceAllButton) { @Override public void update(AnActionEvent e) { myReplaceAllButton.setEnabled(mySearchResults != null && mySearchResults.hasMatches()); } }); actionGroup1.addAction( new DefaultCustomComponentAction(myExcludeButton) { @Override public void update(AnActionEvent e) { FindResult cursor = mySearchResults != null ? mySearchResults.getCursor() : null; myExcludeButton.setEnabled(cursor != null); myExcludeButton.setText( cursor != null && mySearchResults.isExcluded(cursor) ? "Include" : "Exclude"); } }); myReplaceActionsToolbar1.setLayoutPolicy(ActionToolbar.AUTO_LAYOUT_POLICY); myReplaceActionsToolbar1.setBorder(null); myReplaceActionsToolbar1.setOpaque(false); DefaultActionGroup actionGroup2 = new DefaultActionGroup("replace bar 2", false); myReplaceActionsToolbar2 = (ActionToolbarImpl) ActionManager.getInstance() .createActionToolbar(ActionPlaces.EDITOR_TOOLBAR, actionGroup2, true); actionGroup2.addAction(new TogglePreserveCaseAction(this)); actionGroup2.addAction(new ToggleSelectionOnlyAction(this)); myReplaceActionsToolbar2.setLayoutPolicy(ActionToolbar.AUTO_LAYOUT_POLICY); myReplaceActionsToolbar2.setBorder(null); myReplaceActionsToolbar2.setOpaque(false); Utils.setSmallerFontForChildren(myReplaceActionsToolbar1); Utils.setSmallerFontForChildren(myReplaceActionsToolbar2); }
public void initUI(int x, int y) { setVisible(true); loadIcons(); dx = x; dy = y; text_height = getFontMetrics(getFont()).getHeight(); plane_width = icon_size; plane_height = icon_size + text_height + text_gap; radar_area_width = grid_size * dx; radar_area_height = grid_size * dy; getContentPane().setLayout(new BorderLayout()); radarArea = new RadarPane(); radarArea.setMinimumSize(new Dimension(radar_area_width, radar_area_height)); radarArea.setPreferredSize(new Dimension(radar_area_width, radar_area_height)); getContentPane().add(radarArea, BorderLayout.CENTER); radarArea.backImage = new BufferedImage(radar_area_width, radar_area_height, BufferedImage.TYPE_INT_RGB); Graphics2D g = radarArea.backImage.createGraphics(); g.setBackground(back_color); g.setColor(rim_color); g.fillRect(0, 0, radar_area_width, radar_area_height); g.setColor(back_color); g.fillRect(convPos(0), convPos(0), radar_area_width - grid_size, radar_area_height - grid_size); g.setColor(line_color); int i, j; for (i = 0; i < dx; i++) for (j = 0; j < dy; j++) g.draw(new Rectangle(convPos(i) - 1, convPos(j) - 1, 1, 1)); radarArea.backIcon = new ImageIcon(radarArea.backImage); radarArea.back = new JLabel(radarArea.backIcon); radarArea.back.setBounds(0, 0, radar_area_width, radar_area_height); radarArea.add(radarArea.back, new Integer(0)); infoArea = new JPanel(); infoArea.setMinimumSize(new Dimension(info_area_width, radar_area_height)); infoArea.setPreferredSize(new Dimension(info_area_width, radar_area_height)); infoArea.setLayout(new GridLayout(27, 1)); infoTopLine = new Label(" "); infoArea.add(infoTopLine); getContentPane().add(infoArea, BorderLayout.EAST); inputArea = new JLabel(" "); getContentPane().add(inputArea, BorderLayout.SOUTH); controlArea = new JPanel(); newButton = new JButton("New"); newButton.setActionCommand("New"); newButton.addActionListener(this); newButton.setEnabled(false); newButton.setFocusable(false); exitButton = new JButton("Exit"); exitButton.setActionCommand("Exit"); exitButton.addActionListener(this); exitButton.setFocusable(false); controlArea.add(newButton); controlArea.add(exitButton); getContentPane().add(controlArea, BorderLayout.NORTH); pack(); }
// Here some legacy code makes use of generics. They are tested, so there // is no risk of an actual error, but Java issues a warning. @SuppressWarnings("unchecked") public DialogParameters( JFrame parent, Vector<ParameterDescription> vec, boolean strict, Vector<LayerDesc> layers) { super(parent, Globals.messages.getString("Param_opt"), true); keyb1 = new OSKeybPanel(KEYBMODES.GREEK); keyb2 = new OSKeybPanel(KEYBMODES.MISC); keyb1.setField(this); keyb2.setField(this); keyb.addTab("Greek", keyb1); keyb.addTab("Misc", keyb2); keyb.setVisible(false); v = vec; int ycount = 0; // We create dynamically all the needed elements. // For this reason, we work on arrays of the potentially useful Swing // objects. jtf = new JTextField[MAX_ELEMENTS]; jcb = new JCheckBox[MAX_ELEMENTS]; jco = new JComboBox[MAX_ELEMENTS]; active = false; addComponentListener(this); GridBagLayout bgl = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); Container contentPane = getContentPane(); contentPane.setLayout(bgl); boolean extStrict = strict; ParameterDescription pd; int top = 0; JLabel lab; tc = 0; cc = 0; co = 0; // We process all parameter passed. Depending on its type, a // corresponding interface element will be created. // A symmetrical operation is done when validating parameters. for (ycount = 0; ycount < v.size(); ++ycount) { if (ycount > MAX) break; pd = (ParameterDescription) v.elementAt(ycount); // We do not need to store label objects, since we do not need // to retrieve data from them. lab = new JLabel(pd.description); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 1; constraints.gridy = ycount; constraints.gridwidth = 1; constraints.gridheight = 1; // The first element needs a little bit more space at the top. if (ycount == 0) top = 10; else top = 0; // Here we configure the grid layout constraints.insets = new Insets(top, 20, 0, 6); constraints.fill = GridBagConstraints.VERTICAL; constraints.anchor = GridBagConstraints.EAST; lab.setEnabled(!(pd.isExtension && extStrict)); if (!(pd.parameter instanceof Boolean)) contentPane.add(lab, constraints); constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(top, 0, 0, 0); constraints.fill = GridBagConstraints.HORIZONTAL; // Now, depending on the type of parameter we create interface // elements and we populate the dialog. if (pd.parameter instanceof PointG) { jtf[tc] = new JTextField(10); jtf[tc].setText("" + ((PointG) (pd.parameter)).x); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 1; constraints.gridheight = 1; // Disable FidoCadJ extensions in the strict compatibility mode jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); jtf[tc] = new JTextField(10); jtf[tc].setText("" + ((PointG) (pd.parameter)).y); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 3; constraints.gridy = ycount; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.insets = new Insets(top, 6, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof String) { jtf[tc] = new JTextField(24); jtf[tc].setText((String) (pd.parameter)); // If we have a String text field in the first position, its // contents should be evidenced, since it is supposed to be // the most important field (e.g. for the AdvText primitive) if (ycount == 0) jtf[tc].selectAll(); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof Boolean) { jcb[cc] = new JCheckBox(pd.description); jcb[cc].setSelected(((Boolean) (pd.parameter)).booleanValue()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jcb[cc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jcb[cc++], constraints); } else if (pd.parameter instanceof Integer) { jtf[tc] = new JTextField(24); jtf[tc].setText(((Integer) pd.parameter).toString()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof Float) { // TODO. // WARNING: (DB) this is supposed to be temporary. In fact, I // am planning to upgrade some of the parameters from int // to float. But for a few months, the users should not be // aware of that, even if the internal representation is // slowing being adapted. jtf[tc] = new JTextField(24); int dummy = java.lang.Math.round((Float) pd.parameter); jtf[tc].setText("" + dummy); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof FontG) { GraphicsEnvironment gE; gE = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] s = gE.getAvailableFontFamilyNames(); jco[co] = new JComboBox(); for (int i = 0; i < s.length; ++i) { jco[co].addItem(s[i]); if (s[i].equals(((FontG) pd.parameter).getFamily())) jco[co].setSelectedIndex(i); } constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } else if (pd.parameter instanceof LayerInfo) { jco[co] = new JComboBox(new Vector<LayerDesc>(layers)); jco[co].setSelectedIndex(((LayerInfo) pd.parameter).layer); jco[co].setRenderer(new LayerCellRenderer()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } else if (pd.parameter instanceof ArrowInfo) { jco[co] = new JComboBox<ArrowInfo>(); jco[co].addItem(new ArrowInfo(0)); jco[co].addItem(new ArrowInfo(1)); jco[co].addItem(new ArrowInfo(2)); jco[co].addItem(new ArrowInfo(3)); jco[co].setSelectedIndex(((ArrowInfo) pd.parameter).style); jco[co].setRenderer(new ArrowCellRenderer()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } else if (pd.parameter instanceof DashInfo) { jco[co] = new JComboBox<DashInfo>(); for (int k = 0; k < Globals.dashNumber; ++k) { jco[co].addItem(new DashInfo(k)); } jco[co].setSelectedIndex(((DashInfo) pd.parameter).style); jco[co].setRenderer(new DashCellRenderer()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } } // Put the OK and Cancel buttons and make them active. JButton ok = new JButton(Globals.messages.getString("Ok_btn")); JButton cancel = new JButton(Globals.messages.getString("Cancel_btn")); JButton keybd = new JButton("\u00B6\u2211\u221A"); // phylum keybd.setFocusable(false); keybd.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // If at this point, the keyboard is not visible, this means // that it will become visible in a while. It is better to // resize first and then show up the keyboard. if (keyb.isVisible()) { MIN_WIDTH = 400; MIN_HEIGHT = 350; } else { MIN_WIDTH = 400; MIN_HEIGHT = 500; } // setSize(MIN_WIDTH, MIN_HEIGHT); keyb.setVisible(!keyb.isVisible()); pack(); } }); constraints.gridx = 0; constraints.gridy = ycount++; constraints.gridwidth = 4; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(6, 20, 20, 20); // Put the OK and Cancel buttons and make them active. Box b = Box.createHorizontalBox(); b.add(keybd); // phylum b.add(Box.createHorizontalGlue()); ok.setPreferredSize(cancel.getPreferredSize()); if (Globals.okCancelWinOrder) { b.add(ok); b.add(Box.createHorizontalStrut(12)); b.add(cancel); } else { b.add(cancel); b.add(Box.createHorizontalStrut(12)); b.add(ok); } // b.add(Box.createHorizontalStrut(12)); contentPane.add(b, constraints); constraints.gridx = 0; constraints.gridy = ycount; constraints.gridwidth = 4; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(6, 20, 20, 20); contentPane.add(keyb, constraints); ok.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { try { int ycount; ParameterDescription pd; tc = 0; cc = 0; co = 0; // Here we read all the contents of the interface and we // update the contents of the parameter description array. for (ycount = 0; ycount < v.size(); ++ycount) { if (ycount > MAX) break; pd = (ParameterDescription) v.elementAt(ycount); if (pd.parameter instanceof PointG) { ((PointG) (pd.parameter)).x = Integer.parseInt(jtf[tc++].getText()); ((PointG) (pd.parameter)).y = Integer.parseInt(jtf[tc++].getText()); } else if (pd.parameter instanceof String) { pd.parameter = jtf[tc++].getText(); } else if (pd.parameter instanceof Boolean) { pd.parameter = Boolean.valueOf(jcb[cc++].isSelected()); } else if (pd.parameter instanceof Integer) { pd.parameter = Integer.valueOf(Integer.parseInt(jtf[tc++].getText())); } else if (pd.parameter instanceof Float) { pd.parameter = Float.valueOf(Float.parseFloat(jtf[tc++].getText())); } else if (pd.parameter instanceof FontG) { pd.parameter = new FontG((String) jco[co++].getSelectedItem()); } else if (pd.parameter instanceof LayerInfo) { pd.parameter = new LayerInfo(jco[co++].getSelectedIndex()); } else if (pd.parameter instanceof ArrowInfo) { pd.parameter = new ArrowInfo(jco[co++].getSelectedIndex()); } else if (pd.parameter instanceof DashInfo) { pd.parameter = new DashInfo(jco[co++].getSelectedIndex()); } } } catch (NumberFormatException E) { // Error detected. Probably, the user has entered an // invalid string when FidoCadJ was expecting a numerical // input. JOptionPane.showMessageDialog( null, Globals.messages.getString("Format_invalid"), "", JOptionPane.INFORMATION_MESSAGE); return; } active = true; // Globals.activeWindow.setEnabled(true); setVisible(false); keyb.setVisible(false); } }); cancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { // Globals.activeWindow.setEnabled(true); setVisible(false); keyb.setVisible(false); } }); // Here is an action in which the dialog is closed AbstractAction cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { // Globals.activeWindow.setEnabled(true); setVisible(false); keyb.setVisible(false); } }; DialogUtil.addCancelEscape(this, cancelAction); this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // Globals.activeWindow.setEnabled(true); keyb.setVisible(false); } }); pack(); DialogUtil.center(this); getRootPane().setDefaultButton(ok); }