javax.swing.JButton.setForeground()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中javax.swing.JButton.setForeground()方法的一些代码示例,展示了JButton.setForeground()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.setForeground()方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:setForeground

JButton.setForeground介绍

暂无

代码示例

代码示例来源:origin: runelite/runelite

  1. @Override
  2. public void mouseExited(MouseEvent mouseEvent)
  3. {
  4. clearButton.setForeground(ColorScheme.PROGRESS_ERROR_COLOR);
  5. textField.dispatchEvent(mouseEvent);
  6. }
  7. });

代码示例来源:origin: runelite/runelite

  1. @Override
  2. public void mouseEntered(MouseEvent mouseEvent)
  3. {
  4. clearButton.setForeground(Color.PINK);
  5. textField.dispatchEvent(mouseEvent);
  6. }

代码示例来源:origin: kiegroup/optaplanner

  1. private JButton createButton(Exam exam, Color color, String toolTip) {
  2. JButton button = SwingUtils.makeSmallButton(new JButton(new ExamAction(exam)));
  3. button.setBackground(color);
  4. button.setToolTipText(toolTip);
  5. if (exam instanceof FollowingExam) {
  6. button.setForeground(TangoColorFactory.ALUMINIUM_5);
  7. }
  8. return button;
  9. }

代码示例来源:origin: wildfly/wildfly

  1. public void go() throws Exception {
  2. if(!no_channel && !use_state)
  3. channel.connect(cluster_name);
  4. mainFrame=new JFrame();
  5. mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  6. panel=new DrawPanel(use_state);
  7. panel.setBackground(background_color);
  8. sub_panel=new JPanel();
  9. mainFrame.getContentPane().add("Center", panel);
  10. clear_button=new JButton("Clear");
  11. clear_button.setFont(default_font);
  12. clear_button.addActionListener(this);
  13. leave_button=new JButton("Leave");
  14. leave_button.setFont(default_font);
  15. leave_button.addActionListener(this);
  16. sub_panel.add("South", clear_button);
  17. sub_panel.add("South", leave_button);
  18. mainFrame.getContentPane().add("South", sub_panel);
  19. mainFrame.setBackground(background_color);
  20. clear_button.setForeground(Color.blue);
  21. leave_button.setForeground(Color.blue);
  22. mainFrame.pack();
  23. mainFrame.setLocation(15, 25);
  24. mainFrame.setBounds(new Rectangle(250, 250));
  25. if(!no_channel && use_state) {
  26. channel.connect(cluster_name, null, state_timeout);
  27. }
  28. mainFrame.setVisible(true);
  29. setTitle();
  30. }

代码示例来源:origin: wildfly/wildfly

  1. mainFrame.getContentPane().add("South", sub_panel);
  2. mainFrame.setBackground(background_color);
  3. clear_button.setForeground(Color.blue);
  4. leave_button.setForeground(Color.blue);
  5. mainFrame.pack();
  6. mainFrame.setLocation(15, 25);

代码示例来源:origin: kiegroup/optaplanner

  1. public void addShiftAssignment(ShiftAssignment shiftAssignment) {
  2. Shift shift = shiftAssignment.getShift();
  3. JPanel shiftPanel = shiftPanelMap.get(shift);
  4. JButton shiftAssignmentButton = SwingUtils.makeSmallButton(new JButton(new ShiftAssignmentAction(shiftAssignment)));
  5. shiftAssignmentButton.setEnabled(shiftPanel.isEnabled());
  6. if (employee != null) {
  7. if (employee.getDayOffRequestMap().containsKey(shift.getShiftDate())
  8. || employee.getShiftOffRequestMap().containsKey(shift)) {
  9. shiftAssignmentButton.setForeground(TangoColorFactory.SCARLET_1);
  10. }
  11. }
  12. Color color = nurseRosteringPanel.determinePlanningEntityColor(shiftAssignment, shift.getShiftType());
  13. shiftAssignmentButton.setBackground(color);
  14. String toolTip = nurseRosteringPanel.determinePlanningEntityTooltip(shiftAssignment);
  15. shiftAssignmentButton.setToolTipText(toolTip);
  16. shiftPanel.add(shiftAssignmentButton);
  17. shiftPanel.repaint();
  18. shiftAssignmentButtonMap.put(shiftAssignment, shiftAssignmentButton);
  19. }

代码示例来源:origin: runelite/runelite

  1. clearButton.setPreferredSize(new Dimension(30, 0));
  2. clearButton.setFont(FontManager.getRunescapeBoldFont());
  3. clearButton.setForeground(ColorScheme.PROGRESS_ERROR_COLOR);
  4. clearButton.setBorder(null);
  5. clearButton.setBorderPainted(false);

代码示例来源:origin: stackoverflow.com

  1. for(int i=1;i<=9;i++)
  2. {
  3. JButton btn = new JButton(String.valueOf(i));
  4. btn.setBackground(Color.BLACK);
  5. btn.setForeground(Color.GRAY);
  6. p3.add(btn);
  7. }

代码示例来源:origin: stackoverflow.com

  1. private static JButton createSimpleButton(String text) {
  2. JButton button = new JButton(text);
  3. button.setForeground(Color.BLACK);
  4. button.setBackground(Color.WHITE);
  5. Border line = new LineBorder(Color.BLACK);
  6. Border margin = new EmptyBorder(5, 15, 5, 15);
  7. Border compound = new CompoundBorder(line, margin);
  8. button.setBorder(compound);
  9. return button;
  10. }

代码示例来源:origin: stackoverflow.com

  1. JButton addBtn = new JButton("+");
  2. addBtn.setBounds(x_pos, y_pos, 30, 25);
  3. addBtn.setBorder(new RoundedBorder(10)); //10 is the radius
  4. addBtn.setForeground(Color.BLUE);

代码示例来源:origin: magefree/mage

  1. @Override
  2. public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  3. if (hasFocus) {
  4. renderButton.setForeground(table.getForeground());
  5. renderButton.setBackground(UIManager.getColor("Button.background"));
  6. } else if (isSelected) {
  7. renderButton.setForeground(table.getSelectionForeground());
  8. renderButton.setBackground(table.getSelectionBackground());
  9. } else {
  10. renderButton.setForeground(table.getForeground());
  11. renderButton.setBackground(UIManager.getColor("Button.background"));
  12. }
  13. renderButton.setText((value == null) ? "" : value.toString());
  14. return renderButton;
  15. }

代码示例来源:origin: nodebox/nodebox

  1. public DataControl(String nodePath, Port port) {
  2. super(nodePath, port);
  3. setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
  4. clearDataButton = new JButton("Clear");
  5. clearDataButton.setMargin(new Insets(1, 0, 0, 0));
  6. clearDataButton.putClientProperty("JButton.buttonType", "textured");
  7. clearDataButton.putClientProperty("JComponent.sizeVariant", "small");
  8. clearDataButton.setFont(Theme.SMALL_BOLD_FONT);
  9. clearDataButton.setForeground(Theme.TEXT_NORMAL_COLOR);
  10. clearDataButton.addActionListener(this);
  11. add(clearDataButton);
  12. /*showDataButton = new JButton("Show Data...");
  13. showDataButton.setMargin(new Insets(1, 0, 0, 0));
  14. showDataButton.putClientProperty("JButton.buttonType", "textured");
  15. showDataButton.putClientProperty("JComponent.sizeVariant", "small");
  16. showDataButton.setFont(Theme.SMALL_BOLD_FONT);
  17. showDataButton.setForeground(Theme.TEXT_NORMAL_COLOR);
  18. showDataButton.addActionListener(this);
  19. add(showDataButton);*/
  20. add(Box.createHorizontalGlue());
  21. }

代码示例来源:origin: com.jidesoft/jide-oss

  1. @Override
  2. public void setForeground(Color fg) {
  3. if (fg instanceof ColorUIResource) {
  4. return;
  5. }
  6. super.setForeground(fg);
  7. }
  8. }

代码示例来源:origin: com.jalalkiswani/jk-desktop

  1. @Override
  2. public void setForeground(Color fg) {
  3. if (fg != null) {
  4. super.setForeground(fg);
  5. }
  6. }

代码示例来源:origin: stackoverflow.com

  1. JButton aButton ...
  2. aButton.setBackground(new Color(...));
  3. aButton.setForeground(new Color(...));
  4. aButton.setFont(new Font(...));
  5. aButton.setBorder(null);

代码示例来源:origin: org.biojava.thirdparty/forester

  1. void deactivateButtonToReturnToSuperTree() {
  2. _return_to_super_tree.setText( RETURN_TO_SUPER_TREE_TEXT );
  3. _return_to_super_tree.setForeground( getConfiguration().getGuiButtonTextColor() );
  4. _return_to_super_tree.setEnabled( false );
  5. }

代码示例来源:origin: com.github.tornaia/aott-desktop-client-core

  1. private void styleDatePickerArrowButtons(JButton jButton) {
  2. jButton.setFont(new JButton("").getFont().deriveFont(Font.PLAIN, 24));
  3. jButton.setBackground(ColorConst.CONTENT_BACKGROUND);
  4. jButton.setForeground(ColorConst.SIDENAV_TITLE_FOREGROUND);
  5. jButton.setOpaque(false);
  6. jButton.setBorder(BorderFactory.createLineBorder(ColorConst.CONTENT_BACKGROUND));
  7. jButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  8. jButton.setPreferredSize(new Dimension(26, 26));
  9. jButton.setFocusable(false);
  10. }
  11. }

代码示例来源:origin: MarginallyClever/Makelangelo-software

  1. protected void openConnection() {
  2. NetworkConnection s = gui.requestNewConnection();
  3. if(s!=null) {
  4. buttonConnect.setText(Translator.get("ButtonDisconnect"));
  5. buttonConnect.setForeground(Color.RED);
  6. robot.openConnection( s );
  7. //updateMachineNumberPanel();
  8. //updateButtonAccess();
  9. isConnected=true;
  10. }
  11. }

代码示例来源:origin: freeplane/freeplane

  1. private void updatePickColorButton() {
  2. Color color = colors.get(index);
  3. pickColor.setBackground(ColorUtils.makeNonTransparent(color));
  4. final Color textColor = UITools.getTextColorForBackground(color);
  5. pickColor.setForeground(textColor);
  6. pickColor.setText(ColorUtils.colorToString(color));
  7. }
  8. private void removeFromPanel() {

代码示例来源:origin: jrtom/jung

  1. public void actionPerformed(ActionEvent e) {
  2. Color color =
  3. JColorChooser.showDialog(
  4. colorChooser, "Annotation Color", colorChooser.getForeground());
  5. annotatingPlugin.setAnnotationColor(color);
  6. colorChooser.setForeground(color);
  7. }
  8. });

相关文章

JButton类方法