/** * Adds a new ChatRoomButton the CommandBar. * * @param button the button. */ public void addChatRoomButton(ChatRoomButton button) { buttonPanel.add(button); // Make all JButtons the same size Component[] comps = buttonPanel.getComponents(); final int no = comps != null ? comps.length : 0; final List<Component> buttons = new ArrayList<>(); for (int i = 0; i < no; i++) { try { Component component = comps[i]; if (component instanceof JButton) { buttons.add(component); } } catch (NullPointerException e) { Log.error(e); } } GraphicUtils.makeSameSize(buttons.toArray(new JComponent[buttons.size()])); }
/** * Default Constructor */ public AvatarPanel() { setLayout(new GridBagLayout()); final JLabel photo = new JLabel(Res.getString("label.avatar")); avatar = new JLabel(); add(photo, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(avatar, new GridBagConstraints(1, 0, 1, 2, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(browseButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(clearButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); browseButton.addActionListener(this); // Add ResourceUtils ResourceUtils.resButton(browseButton, Res.getString("button.browse")); ResourceUtils.resButton(clearButton, Res.getString("button.clear")); clearButton.addActionListener( actionEvent -> { avatar.setIcon(null); bytes = null; avatarFile = null; avatar.setBorder(null); } ); avatar.setText(Res.getString("message.no.avatar.found")); GraphicUtils.makeSameSize(browseButton, clearButton); }
activeButton.addActionListener(showActiveAction); GraphicUtils.makeSameSize(allButton, activeButton);
private void browseItem(DiscoverItems.Item discoveredItem) { addAddress(discoveredItem.getEntityID().toString()); browsePanel.removeAll(); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con); DiscoverItems result; try { result = discoManager.discoverItems(discoveredItem.getEntityID()); } catch (XMPPException | SmackException | InterruptedException e) { browsePanel.invalidate(); browsePanel.validate(); browsePanel.repaint(); return; } List<Entity> list = new ArrayList<>(); for (DiscoverItems.Item item : result.getItems() ) { Entity entity = new Entity(item); browsePanel.add(entity); list.add(entity); } GraphicUtils.makeSameSize((JComponent[])list.toArray(new JComponent[list.size()])); browsePanel.invalidate(); browsePanel.validate(); browsePanel.repaint(); }
GraphicUtils.makeSameSize(usernameField, passwordField);