/** * <pre> * 重写下拉按钮,增加焦点颜色 * * Rewrite the drop-down button to increase the focus color * </pre> * * @return arrow button info */ protected JButton createArrowButton() { JButton button = new LuckComboBoxButton(BasicArrowButton.SOUTH) { private static final long serialVersionUID = -7259590635997077859L; @Override public LuckBorderField getBorderField() { return LuckComboBoxUI.this; } @Override public JComponent getParentComp() { return LuckComboBoxUI.this.comboBox; } }; button.setName("ComboBox.arrowButton"); return button; }
public DatePicker(Date date) { selectedDay = null; selectedDate = null; originalDate = null; backButton = new BasicArrowButton(BasicArrowButton.WEST);//new JButton(); monthAndYear = new JLabel(); forwardButton = new BasicArrowButton(BasicArrowButton.EAST);//new JButton(); todayButton = new JButton(); cancelButton = new JButton(); if (date == null) { selectedDate = getToday(); } else { selectedDate = new GregorianCalendar(); selectedDate.setTime(date); } originalDate = new GregorianCalendar(selectedDate.get(Calendar.YEAR), selectedDate.get(Calendar.MONTH), selectedDate.get(Calendar.DAY_OF_MONTH)); init(); }
public JDropDownButton(String text) { super(text); buttonPopupMenu = new JPopupMenu(); arrowButton = new BasicArrowButton(SwingConstants.SOUTH, null, null, Color.BLACK, null); arrowButton.setBorder(BorderFactory.createEmptyBorder()); arrowButton.setFocusable(false); setHorizontalAlignment(SwingConstants.LEFT); setLayout(new BorderLayout()); add(arrowButton, BorderLayout.EAST); arrowButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Rectangle r = getBounds(); buttonPopupMenu.show(JDropDownButton.this, r.x, r.y + r.height); } }); }
/** * Instantiates a new arrow column. * * @param table the table * @param column the column * @param direction the direction */ public ArrowColumn(JTable table, int column, int direction){ super(table, column); renderButton = new BasicArrowButton(direction); editButton = new BasicArrowButton(direction); editButton.setText("arrow"); setButtons(renderButton, editButton); }
/** * Instantiates a new image table. */ public ImageTable() { super(); Object[][] data = new Object[defaultDomtype.length][columnNames.length]; for (int i = 0; i < defaultDomtype.length; i++) { data[i][0] = defaultDomtype[i]; } // table tableModel = new MyTableModel(data, columnNames); setModel(tableModel); setBackground(new Color(169,169,169)); getTableHeader().setReorderingAllowed(false); // mouse addMouseListener(this); setCellSelectionEnabled(true); new ArrowColumn(this, colUpButton, BasicArrowButton.NORTH); new ArrowColumn(this, colDownButton, BasicArrowButton.SOUTH); new AddingColumn(this, colAddImage); TableColumn column = (TableColumn) this.getColumnModel().getColumn(colAddImage); column.setMaxWidth(50); column = (TableColumn) getColumnModel().getColumn(colDownButton); column.setMaxWidth(50); column = (TableColumn) getColumnModel().getColumn(colUpButton); column.setMaxWidth(50); setVisible(true); }
@Override public Class<?> getColumnClass(int Column) { switch (Column) { case 0: case 1: return String.class; case 2: return JButton.class; case 3: case 4: return BasicArrowButton.class; default: return Boolean.class; } }
@Override protected JButton createDecreaseButton(int orientation) { BasicArrowButton button = new BasicArrowButton(orientation, UIManager.getColor("ScrollBar.thumb"), UIManager.getColor("ScrollBar.thumbShadow"), Color.WHITE, UIManager.getColor("ScrollBar.thumbHighlight")); button.setBackground(GUI.COLOR_UI_ELEMENT); button.setForeground(Color.WHITE); return button; }
@Override protected JButton createIncreaseButton(int orientation) { JButton button = new BasicArrowButton(orientation, UIManager.getColor("ScrollBar.thumb"), UIManager.getColor("ScrollBar.thumbShadow"), Color.WHITE, UIManager.getColor("ScrollBar.thumbHighlight")); button.setBackground(GUI.COLOR_UI_ELEMENT); button.setForeground(Color.WHITE); return button; }
/** * Instantiates a new arrow icon. * * @param iconSize the icon size * @param direction the direction * @param isEnabled the is enabled */ public ArrowIcon(int iconSize, int direction, boolean isEnabled) { this.size = iconSize / 2; this.iconSize = iconSize; this.direction = direction; this.isEnabled = isEnabled; iconRenderer = new BasicArrowButton(direction); }
@Override protected JButton createArrowButton() { return new MyBasicArrowButton( BasicArrowButton.SOUTH, basicArrowButton_Background, //UIManager.getColor("ScrollBar.thumb"), //Background basicArrowButton_Background, //UIManager.getColor("ScrollBar.thumbShadow"), basicArrowButton_Foreground, //UIManager.getColor("ScrollBar.thumbDarkShadow"), //Rand unten Rechts , Pfeilfarbe basicArrowButton_Background); //UIManager.getColor("ScrollBar.thumbHighlight")); }
public DatePicker() { selectedDay = null; selectedDate = null; originalDate = null; backButton = new BasicArrowButton(BasicArrowButton.WEST);//JButton(); monthAndYear = new JLabel(); forwardButton = new BasicArrowButton(BasicArrowButton.EAST);//new JButton(); todayButton = new JButton(); cancelButton = new JButton(); selectedDate = getToday(); init(); }
public ArrowIcon(int iconSize, int direction, boolean isEnabled) { this.size = iconSize / 2; this.iconSize = iconSize; this.direction = direction; this.isEnabled = isEnabled; iconRenderer = new BasicArrowButton(direction); }
@Override protected JButton createArrowButton() { final JButton button = new BasicArrowButton(SwingConstants.SOUTH, WidgetColors.COLOR_ENCLOSURE_BG, WidgetColors.COLOR_ENCLOSURE_BG, WidgetColors.COLOR_LIST_FG, WidgetColors.COLOR_ENCLOSURE_BG); button.setName("ComboBox.arrowButton"); return button; }
@Override public boolean isSupportedBy(ComponentModel model) { // skip fileChooser dialog. WindowModel winModel = GUIModelExtractor.getWindowModel(model); if (winModel != null && winModel.get("windowlisteners") != null && winModel.get("windowlisteners").indexOf("javax.swing.JFileChooser") >= 0) { return false; } AccessibleAction aAction = JFCUtil.getAccessibleContext(model).getAccessibleAction(); Accessible accessibleObj = (Accessible) model.getRef(); if (aAction == null) return false; if (aAction.getAccessibleActionCount() == 0) return false; if (accessibleObj instanceof JMenuItem) { return false; // should be handled by SelectionMenuEvent } if (accessibleObj instanceof JTextComponent) { return false; // should be handled by EditableTextEvent } if (accessibleObj instanceof BasicArrowButton) { return false; // should be handled by ValueEvnet } if (accessibleObj instanceof JComboBox) { return false; // should be handled by SelectionEvent } if (accessibleObj instanceof JSpinner) { return false; // should be handled by SelectionEvent } return true; }
private ComponentModel findTargetBtnComponent(GUIModel root) { for (Enumeration<GUIModel> enumuration = (Enumeration<GUIModel>) root.depthFirstEnumeration(); enumuration .hasMoreElements();) { GUIModel node = enumuration.nextElement(); Object userObj = node.getUserObject(); if (userObj instanceof ComponentModel) { ComponentModel model = (ComponentModel) userObj; AccessibleAction aAction = JFCUtil.getAccessibleContext(model).getAccessibleAction(); Accessible accessibleObj = (Accessible) model.getRef(); if (aAction == null) continue; if (aAction.getAccessibleActionCount() == 0) continue; if (accessibleObj instanceof JMenuItem) { continue; // should be handled by SelectionMenuEvent } if (accessibleObj instanceof JTextComponent) { continue; // should be handled by EditableTextEvent } if (accessibleObj instanceof BasicArrowButton) { continue; // should be handled by ValueEvnet } if (accessibleObj instanceof JComboBox) { continue; // should be handled by SelectionEvent } if (accessibleObj instanceof JSpinner) { continue; // should be handled by SelectionEvent } String title = model.get("title"); if (title.equalsIgnoreCase(targetBtnName)) { return model; } } } return null; }
@Override protected JButton createArrowButton() { final Color bg = myComboBox.getBackground(); final Color fg = myComboBox.getForeground(); JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) { @Override public void paint(Graphics g) { Color borderColor = ModernUIUtil.getBorderColor(myComboBox); GraphicsConfig config = new GraphicsConfig(g); final int w = getWidth(); final int h = getHeight(); g.setColor(UIUtil.getControlColor()); g.fillRect(0, 0, w, h); g.setColor(myComboBox.isEnabled() ? getForeground() : borderColor); GraphicsUtil.setupAAPainting(g); g.drawLine(JBUI.scale(3), JBUI.scale(7), JBUI.scale(7), JBUI.scale(11)); g.drawLine(JBUI.scale(7), JBUI.scale(11), JBUI.scale(11), JBUI.scale(7)); config.restore(); } @Override public Dimension getPreferredSize() { int size = getFont().getSize() + JBUI.scale(4); if (size % 2 == 1) size += JBUI.scale(1); return new DimensionUIResource(size, size); } }; button.setBorder(BorderFactory.createEmptyBorder()); button.setOpaque(false); return button; }
private void doButtonsLayout(JPanel buttonPanel) { buttonPanel.setBorder(BorderFactory.createLoweredBevelBorder()); GridBagConstraints gc = new GridBagConstraints(); gc.gridx=0; buttonUp = new BasicArrowButtonFixedSize(BasicArrowButton.NORTH); buttonDown = new BasicArrowButtonFixedSize(BasicArrowButton.SOUTH); buttonPanel.add(buttonUp, gc); buttonPanel.add(buttonDown, gc); }
protected Component createNextButton() { JButton c = new BasicArrowButton(SwingConstants.NORTH); c.setName("Spinner.nextButton"); installNextButtonListeners(c); return c; }
protected Component createPreviousButton() { Component c = new BasicArrowButton(SwingConstants.SOUTH); c.setName("Spinner.previousButton"); installPreviousButtonListeners(c); return c; }
protected Component createNextButton() { BasicArrowButton c = new BasicArrowButton(1); c.setName("Spinner.nextButton"); this.installNextButtonListeners(c); return c; }
protected Component createPreviousButton() { BasicArrowButton c = new BasicArrowButton(5); c.setName("Spinner.previousButton"); this.installPreviousButtonListeners(c); return c; }
@Override protected void paintArrowButton(Graphics g, BasicArrowButton button, @MagicConstant(intValues = {SwingConstants.NORTH, SwingConstants.SOUTH}) int direction) { }
protected JButton createArrowButton() { final Color bg = myComboBox.getBackground(); final Color fg = myComboBox.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(); if (!isTableCellEditor(myComboBox)) { g.setColor(getArrowButtonFillColor(UIUtil.getControlColor())); g.fillRect(0, 0, w, h); } g.setColor(comboBox.isEnabled() ? new JBColor(Gray._255, getForeground()) : new JBColor(Gray._255, getBorderColor())); 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 tW = JBUI.scale(8); final int tH = JBUI.scale(6); final int xU = (w - tW) / 2; final int yU = (h - tH) / 2; g.translate(JBUI.scale(2), JBUI.scale(1)); final Path2D.Double path = new Path2D.Double(); path.moveTo(xU, yU); path.lineTo(xU + tW, yU); path.lineTo(xU + tW/2, yU + tH); path.lineTo(xU, yU); //path.moveTo(xU + 1, yU + 2); //path.lineTo(3 * xU + 1, yU + 2); //path.lineTo(2 * xU + 1, 3 * yU); //path.lineTo(xU + 1, yU + 2); path.closePath(); g.fill(path); g.translate(-JBUI.scale(2), -JBUI.scale(1)); if (!isTableCellEditor(myComboBox)) { g.setColor(getArrowButtonFillColor(getBorderColor())); g.drawLine(0, -1, 0, h); } config.restore(); } @Override public Dimension getPreferredSize() { int size = getFont().getSize() + 4; if (size%2==1) size++; return new DimensionUIResource(size, size); } }; button.setBorder(BorderFactory.createEmptyBorder()); button.setOpaque(false); return button; }
protected void paintArrowButton(Graphics g, BasicArrowButton button, @MagicConstant(intValues = {SwingConstants.NORTH, SwingConstants.SOUTH}) int direction) { int y = direction == SwingConstants.NORTH ? button.getHeight() - 6 : 2; button.paintTriangle(g, (button.getWidth() - 8)/2 - 1, y, 0, direction, spinner.isEnabled()); }
@Override protected JButton createArrowButton(){ return new AccountSelectionArrowButton(BasicArrowButton.SOUTH); }
public DateField() { dateText = new JTextField(); dateDropdownButton = new BasicArrowButton(BasicArrowButton.SOUTH); init(); }
public DateField(Date date) { dateText = new JTextField(); dateDropdownButton = new BasicArrowButton(BasicArrowButton.SOUTH); init(); dateText.setText(dateToDateString(date)); }
public TimeField() { timeText = new JTextField(); timeDropdownButton = new BasicArrowButton(BasicArrowButton.SOUTH); init(); }
public TimeField(Date date) { timeText = new JTextField(); timeDropdownButton = new BasicArrowButton(BasicArrowButton.SOUTH); init(); timeText.setText(dateToTimeString(date)); }
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; }
protected void paintArrowButton(final Graphics g, final BasicArrowButton button, @MagicConstant(intValues = {SwingConstants.NORTH, SwingConstants.SOUTH}) final int direction) { int y = direction == SwingConstants.NORTH ? button.getHeight() - 6 : 2; button.paintTriangle(g, (button.getWidth() - 8) / 2 - 1, y, 0, direction, spinner.isEnabled()); }
public BasicArrowButton getIncButton() { return this.incButton; }
public BasicArrowButton getDecButton() { return this.decButton; }
private void uiStyle() { nameText.setCaretColor(Color.WHITE); packageText.setCaretColor(Color.WHITE); gameClassText.setCaretColor(Color.WHITE); destinationText.setCaretColor(Color.WHITE); sdkLocationText.setCaretColor(Color.WHITE); nameLabel.setForeground(Color.WHITE); packageLabel.setForeground(Color.WHITE); gameClassLabel.setForeground(Color.WHITE); destinationLabel.setForeground(Color.WHITE); sdkLocationLabel.setForeground(Color.WHITE); sdkLocationText.setDisabledTextColor(Color.BLACK); versionLabel.setForeground(new Color(255, 20, 20)); UIManager.put("ComboBox.selectionBackground", new ColorUIResource(new Color(70, 70, 70))); UIManager.put("ComboBox.selectionForeground", new ColorUIResource(Color.WHITE)); versionButton.updateUI(); versionButton.setForeground(new Color(255, 255, 255)); versionButton.setBackground(new Color(20, 20, 20)); versionButton.setPrototypeDisplayValue("I am a prototype"); versionButton.setUI(new BasicComboBoxUI() { @Override protected JButton createArrowButton () { return new BasicArrowButton( BasicArrowButton.SOUTH, new Color(0, 0, 0), new Color(0, 0, 0), new Color(100, 100, 100), new Color(100, 100, 100)); } }); projectsLabel.setForeground(new Color(200, 20, 20)); extensionsLabel.setForeground(new Color(200, 20, 20)); subProjectsPanel.setOpaque(true); subProjectsPanel.setBackground(new Color(46, 46, 46)); for (JPanel extensionPanel : extensionsPanels) { extensionPanel.setOpaque(true); extensionPanel.setBackground(new Color(46, 46, 46)); } }
@Override protected JButton createArrowButton() { JButton button = new ScrollbarUiButton(BasicArrowButton.SOUTH, UIDefaults.ARROW_COLOR); button.setName("ComboBox.arrowButton"); return button; }
protected JButton createArrowButton() { final Color bg = myComboBox.getBackground(); final Color fg = myComboBox.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(UIUtil.getControlColor()); g.fillRect(0, 0, w, h); g.setColor(myComboBox.isEnabled() ? getForeground() : getForeground().darker()); 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 xU = w / 4; final int yU = h / 4; final Path2D.Double path = new Path2D.Double(); g.translate(2, 0); path.moveTo(xU + 1, yU + 2); path.lineTo(3 * xU + 1, yU + 2); path.lineTo(2 * xU + 1, 3 * yU); path.lineTo(xU + 1, yU + 2); path.closePath(); g.fill(path); g.translate(-2, 0); g.setColor(getBorderColor()); g.drawLine(0, -1, 0, h); config.restore(); } @Override public Dimension getPreferredSize() { int size = getFont().getSize() + 4; if (size%2==1) size++; return new DimensionUIResource(size, size); } }; button.setBorder(BorderFactory.createEmptyBorder()); button.setOpaque(false); return button; }
public final BasicArrowButton getMoveUpButton() { return this.moveUp; }
public final BasicArrowButton getMoveDownButton() { return this.moveDown; }
protected JButton createArrowButton() { final Color bg = myComboBox.getBackground(); final Color fg = myComboBox.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(); if (!isTableCellEditor(myComboBox)) { g.setColor(getArrowButtonFillColor(UIUtil.getControlColor())); g.fillRect(0, 0, w, h); } g.setColor(comboBox.isEnabled() ? new DoubleColor(Gray._255, getForeground()) : new DoubleColor(Gray._255, getForeground().darker())); 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 xU = w / 4; final int yU = h / 4; final Path2D.Double path = new Path2D.Double(); g.translate(2, 0); path.moveTo(xU + 1, yU + 2); path.lineTo(3 * xU + 1, yU + 2); path.lineTo(2 * xU + 1, 3 * yU); path.lineTo(xU + 1, yU + 2); path.closePath(); g.fill(path); g.translate(-2, 0); if (!isTableCellEditor(myComboBox)) { g.setColor(getArrowButtonFillColor(getBorderColor())); g.drawLine(0, -1, 0, h); } config.restore(); } @Override public Dimension getPreferredSize() { int size = getFont().getSize() + 4; if (size%2==1) size++; return new DimensionUIResource(size, size); } }; button.setBorder(BorderFactory.createEmptyBorder()); button.setOpaque(false); return button; }