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

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

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

JButton.setIcon介绍

暂无

代码示例

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

  1. JButton button = new JButton();
  2. try {
  3. Image img = ImageIO.read(getClass().getResource("resources/water.bmp"));
  4. button.setIcon(new ImageIcon(img));
  5. } catch (Exception ex) {
  6. System.out.println(ex);
  7. }

代码示例来源:origin: skylot/jadx

  1. label.setIcon(node.getIcon());
  2. final JButton button = new JButton();
  3. button.setIcon(ICON_CLOSE_INACTIVE);
  4. button.setRolloverIcon(ICON_CLOSE);
  5. button.setRolloverEnabled(true);

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

  1. JButton newButton = new JButton("Clear Log Table");
  2. newButton.setIcon(newIcon);

代码示例来源:origin: stanfordnlp/CoreNLP

  1. buttonsAndFilePanel = new javax.swing.JPanel();
  2. loadButtonPanel = new javax.swing.JPanel();
  3. loadFileButton = new javax.swing.JButton();
  4. loadParserButton = new javax.swing.JButton();
  5. saveOutputButton = new javax.swing.JButton();
  6. buttonPanel = new javax.swing.JPanel();
  7. backButton = new javax.swing.JButton();
  8. if (getClass().getResource("/edu/stanford/nlp/parser/ui/leftarrow.gif") != null) {
  9. backButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/stanford/nlp/parser/ui/leftarrow.gif")));
  10. } else {
  11. backButton.setText("< Prev");
  12. forwardButton = new javax.swing.JButton();
  13. if (getClass().getResource("/edu/stanford/nlp/parser/ui/rightarrow.gif") != null) {
  14. forwardButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/stanford/nlp/parser/ui/rightarrow.gif")));
  15. } else {
  16. forwardButton.setText("Next >");

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

  1. private JButton createButton(Lecture lecture, Color color, String toolTip) {
  2. JButton button = SwingUtils.makeSmallButton(new JButton(new LectureAction(lecture)));
  3. button.setBackground(color);
  4. if (lecture.isPinned()) {
  5. button.setIcon(CommonIcons.PINNED_ICON);
  6. }
  7. button.setToolTipText(toolTip);
  8. return button;
  9. }

代码示例来源:origin: skylot/jadx

  1. add(searchField);
  2. JButton prevButton = new JButton(NLS.str("search.previous"));
  3. prevButton.setIcon(ICON_UP);
  4. prevButton.addActionListener(new ActionListener() {
  5. @Override
  6. add(prevButton);
  7. JButton nextButton = new JButton(NLS.str("search.next"));
  8. nextButton.setIcon(ICON_DOWN);
  9. nextButton.addActionListener(new ActionListener() {
  10. @Override
  11. add(wholeWordCB);
  12. JButton closeButton = new JButton();
  13. closeButton.setIcon(ICON_CLOSE);
  14. closeButton.addActionListener(l -> toggle());
  15. closeButton.setBorderPainted(false);

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

  1. private JButton createButton(TeamAssignment teamAssignment, Color color) {
  2. JButton button = SwingUtils.makeSmallButton(new JButton(new TeamAssignmentAction(teamAssignment)));
  3. button.setBackground(color);
  4. if (teamAssignment.isPinned()) {
  5. button.setIcon(CommonIcons.PINNED_ICON);
  6. }
  7. return button;
  8. }

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

  1. : navigationButton.getIcon();
  2. final JButton button = new JButton();
  3. button.setSize(scaledImage.getWidth(), scaledImage.getHeight());
  4. button.setToolTipText(navigationButton.getTooltip());
  5. button.setIcon(new ImageIcon(scaledImage));
  6. button.putClientProperty(SubstanceSynapse.FLAT_LOOK, Boolean.TRUE);
  7. button.setFocusable(false);

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

  1. private JButton createButton(Match match, Team team, Team otherTeam, String toolTip) {
  2. Color color = determinePlanningEntityColor(match, otherTeam);
  3. String label = otherTeam.getLabel();
  4. JButton button = SwingUtils.makeSmallButton(new JButton(new MatchAction(match, label)));
  5. if (match.getAwayTeam() == team) {
  6. button.setIcon(awayMatchIcon);
  7. }
  8. button.setBackground(color);
  9. button.setToolTipText(toolTip);
  10. return button;
  11. }

代码示例来源:origin: RipMeApp/ripme

  1. ripTextfield.addMouseListener(new ContextMenuMouseListener());
  2. ImageIcon ripIcon = new ImageIcon(mainIcon);
  3. ripButton = new JButton("<html><font size=\"5\"><b>Rip</b></font></html>", ripIcon);
  4. stopButton = new JButton("<html><font size=\"5\"><b>Stop</b></font></html>");
  5. stopButton.setEnabled(false);
  6. try {
  7. Image stopIcon = ImageIO.read(getClass().getClassLoader().getResource("stop.png"));
  8. stopButton.setIcon(new ImageIcon(stopIcon));
  9. } catch (Exception ignored) { }
  10. JPanel ripPanel = new JPanel(new GridBagLayout());
  11. openButton = new JButton();
  12. openButton.setVisible(false);
  13. JPanel statusPanel = new JPanel(new GridBagLayout());
  14. Image icon;
  15. icon = ImageIO.read(getClass().getClassLoader().getResource("comment.png"));
  16. optionLog.setIcon(new ImageIcon(icon));
  17. icon = ImageIO.read(getClass().getClassLoader().getResource("time.png"));
  18. optionHistory.setIcon(new ImageIcon(icon));
  19. icon = ImageIO.read(getClass().getClassLoader().getResource("list.png"));
  20. optionQueue.setIcon(new ImageIcon(icon));
  21. icon = ImageIO.read(getClass().getClassLoader().getResource("gear.png"));
  22. optionConfiguration.setIcon(new ImageIcon(icon));
  23. } catch (Exception e) { }
  24. gbc.gridx = 0; optionsPanel.add(optionLog, gbc);

代码示例来源:origin: redwarp/9-Patch-Resizer

  1. new JButton(String.format(Locale.getDefault(), Localization.get("xhdpi"),
  2. Configuration.getSettings().getDefaultInputDensity().getName()));
  3. this.xhdpiButton.addActionListener(new ActionListener() {
  4. this.xhdpiButton.setHorizontalTextPosition(SwingConstants.CENTER);
  5. this.xhdpiButton.setHorizontalAlignment(SwingConstants.CENTER);
  6. this.xhdpiButton.setIcon(this.blueArrow);
  7. this.xhdpiButton.setSelectedIcon(this.redArrow);
  8. this.xhdpiButton.setBorder(null);

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

  1. jLabel_VersionNum = new javax.swing.JLabel();
  2. jLabel_DFKILogo = new javax.swing.JLabel();
  3. jButton_OK = new javax.swing.JButton();
  4. jLabel_ToolIcon = new javax.swing.JLabel();
  5. jLabel_CopyrightDate = new javax.swing.JLabel();
  6. jButton_OK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/ok_16x16.png")));
  7. jButton_OK.setText("OK");
  8. jButton_OK.setPreferredSize(new java.awt.Dimension(95, 25));

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

  1. jCheckBox_PlayBackRec = new javax.swing.JCheckBox();
  2. jCheckBox_ContinueWithNext = new javax.swing.JCheckBox();
  3. jButton_Record = new javax.swing.JButton();
  4. jButton_Play = new javax.swing.JButton();
  5. jSeparator_MessageBar = new javax.swing.JSeparator();
  6. jLabel_MessageBar = new javax.swing.JLabel();
  7. jCheckBox_PlayClosingBeep = new javax.swing.JCheckBox();
  8. jLabel_MessageBarIcon = new javax.swing.JLabel();
  9. jButton_Display = new javax.swing.JButton();
  10. jMenuBar_AdminWindow = new javax.swing.JMenuBar();
  11. jMenu_File = new javax.swing.JMenu();
  12. jButton_Record.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/recording_16x16.png")));
  13. jButton_Record.setText("Record");
  14. jButton_Record.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
  15. jButton_Play.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/playing_16x16.png")));
  16. jButton_Play.setText("Play");
  17. jButton_Play.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

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

  1. jButton_SaveOptions = new javax.swing.JButton();
  2. jButton_CancelOptions = new javax.swing.JButton();
  3. jTabbedPane_Options = new javax.swing.JTabbedPane();
  4. jPanel_AudioOptions = new javax.swing.JPanel();
  5. jLabel_AudioMixer = new javax.swing.JLabel();
  6. cbAudioSource = new javax.swing.JComboBox();
  7. jButton_Record = new javax.swing.JButton();
  8. jButton_Play = new javax.swing.JButton();
  9. jProgressBar_Amplitude = new javax.swing.JProgressBar();
  10. jButton_SaveOptions.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/ok_16x16.png")));
  11. jButton_SaveOptions.setText("Save");
  12. jButton_SaveOptions.addActionListener(new java.awt.event.ActionListener() {
  13. jButton_CancelOptions.setIcon(new javax.swing.ImageIcon(getClass()
  14. .getResource("/marytts/tools/redstart/cancel_16x16.png")));
  15. jButton_CancelOptions.setText("Cancel");
  16. jButton_Record.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/recording_16x16.png")));
  17. jButton_Record.setText("Record");
  18. jButton_Record.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
  19. jButton_Play.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marytts/tools/redstart/playing_16x16.png")));
  20. jButton_Play.setText("Play");
  21. jButton_Play.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

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

  1. private void setTypeIcon(BufferedImage bufferedImage, String toolTipText) {
  2. iconPanel = new JPanel();
  3. iconPanel.setLayout(null);
  4. iconPanel.setOpaque(false);
  5. add(iconPanel);
  6. typeButton = new JButton("");
  7. typeButton.setLocation(2, 2);
  8. typeButton.setSize(25, 25);
  9. iconPanel.setVisible(true);
  10. typeButton.setIcon(new ImageIcon(bufferedImage));
  11. if (toolTipText != null) {
  12. typeButton.setToolTipText(toolTipText);
  13. }
  14. iconPanel.add(typeButton);
  15. }

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

  1. JButton button = new JButton();
  2. button.setBorderPainted(false);
  3. button.setBorder(null);
  4. //button.setFocusable(false);
  5. button.setMargin(new Insets(0, 0, 0, 0));
  6. button.setContentAreaFilled(false);
  7. button.setIcon(myIcon1);
  8. button.setRolloverIcon(myIcon2);
  9. button.setPressedIcon(myIcon3);
  10. button.setDisabledIcon(myIcon4);

代码示例来源:origin: haraldk/TwelveMonkeys

  1. private static void addImage(final Container pParent, final ImageReader pReader, final int pImageNo) throws IOException {
  2. final JButton button = new JButton();
  3. button.setIcon(new ImageIcon(image) {
  4. TexturePaint texture;

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

  1. setPanel.add(pack);
  2. JButton searchButton = new JButton();
  3. searchButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_24.png")));
  4. searchButton.setToolTipText("Search and select from list");
  5. searchButton.setAlignmentX(1.0F);

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

  1. jButton2 = new javax.swing.JButton();
  2. jLabel1 = new javax.swing.JLabel();
  3. lblLandSet = new javax.swing.JLabel();
  4. lblDeckSize = new javax.swing.JLabel();
  5. spnDeckSize = new javax.swing.JSpinner();
  6. btnAutoAdd = new javax.swing.JButton();
  7. btnAdd = new javax.swing.JButton();
  8. btnCancel = new javax.swing.JButton();
  9. panelSet = new javax.swing.JPanel();
  10. panelSet.add(cbLandSet);
  11. btnSetFastSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_24.png"))); // NOI18N
  12. btnSetFastSearch.setToolTipText("Search for set");
  13. btnSetFastSearch.setAlignmentX(1.0F);

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

  1. fillerGlobal1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5));
  2. labelGlobal = new javax.swing.JLabel();
  3. buttonStop = new javax.swing.JButton();
  4. fillerglobal2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 5), new java.awt.Dimension(0, 5), new java.awt.Dimension(32767, 5));
  5. tabsList = new javax.swing.JTabbedPane();
  6. comboSets = new javax.swing.JComboBox<>();
  7. fillerMode1 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 32767));
  8. buttonSearchSet = new javax.swing.JButton();
  9. panelRedownload = new javax.swing.JPanel();
  10. checkboxRedownload = new javax.swing.JCheckBox();
  11. tabCustom = new javax.swing.JPanel();
  12. panelCommands = new javax.swing.JPanel();
  13. buttonOK = new javax.swing.JButton();
  14. buttonCancel = new javax.swing.JButton();
  15. panelModeSelect.add(fillerMode1);
  16. buttonSearchSet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_24.png"))); // NOI18N
  17. buttonSearchSet.setToolTipText("Fast search your flag");
  18. buttonSearchSet.setAlignmentX(1.0F);

相关文章

JButton类方法