List of usage examples for javax.swing AbstractButton setOpaque
@BeanProperty(expert = true, description = "The component's opacity") public void setOpaque(boolean isOpaque)
From source file:Main.java
/** * //from w w w . j a v a 2s. c om * TODO * @param action * @return */ public static AbstractButton createToolbarItem(Action action) { final AbstractButton button; if (action == null) { throw new NullPointerException("Action cannot be null!"); } else if (action.getValue(Action.SELECTED_KEY) != null) { button = new JToggleButton(action); } else { button = new JButton(action); } button.setOpaque(false); // hide text if icon is available if (action != null && (action.getValue(Action.SMALL_ICON) != null || action.getValue(Action.LARGE_ICON_KEY) != null)) { button.setHideActionText(true); } button.setHorizontalTextPosition(JButton.CENTER); button.setVerticalTextPosition(JButton.BOTTOM); return button; }
From source file:org.drugis.addis.gui.WelcomeDialog.java
private void initComps() { final ButtonGroup examples = new ButtonGroup(); examples.add(new JRadioButton(Main.Examples.DEPRESSION.name, true)); examples.add(new JRadioButton(Main.Examples.HYPERTENSION.name)); final AbstractAction exampleAction = new AbstractAction() { public void actionPerformed(ActionEvent arg0) { d_main.loadExampleDomain(Main.Examples.findFileName(getSelection(examples).getText())); closeWelcome();//from w w w. ja va2 s .c om } }; final AbstractAction loadAction = new AbstractAction() { public void actionPerformed(ActionEvent arg0) { if (d_main.fileLoadActions() == JFileChooser.APPROVE_OPTION) { closeWelcome(); } } }; final AbstractAction newAction = new AbstractAction() { public void actionPerformed(ActionEvent arg0) { d_main.newFileActions(); closeWelcome(); } }; FormLayout layout = new FormLayout("left:pref, " + SPACING + "px, left:pref", "p, 3dlu, p, " + SPACING + "px, p, " + SPACING + "px, p, 3dlu, p"); PanelBuilder builder = new PanelBuilder(layout); final CellConstraints cc = new CellConstraints(); builder.add(createImageLabel(FileNames.IMAGE_HEADER), cc.xyw(1, 1, 3)); builder.add(createButton("Load example", FileNames.ICON_TIP, exampleAction), cc.xy(1, 3)); final PanelBuilder radios = new PanelBuilder(new FormLayout("p, fill:pref:grow, right:pref", "p, 3dlu, p")); final ArrayList<AbstractButton> buttons = Collections.list(examples.getElements()); forAllDo(buttons, new Closure<AbstractButton>() { public void execute(final AbstractButton exampleOption) { int row = buttons.indexOf(exampleOption) == 0 ? 1 : buttons.indexOf(exampleOption) + 2; exampleOption.setOpaque(false); radios.add(exampleOption, cc.xy(1, row)); radios.add(createHelpButton(exampleOption), cc.xy(3, row)); } private JButton createHelpButton(final AbstractButton exampleOption) { JButton help = GUIFactory.createIconButton(org.drugis.mtc.gui.FileNames.ICON_ABOUT, "Information about this example"); removeBackground(help); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Examples example = Examples.findByName(exampleOption.getText()); String helpText = s_help.getHelpText(example.name().toLowerCase()); showExampleInfo(helpText); } }); return help; } }); JPanel radiosPanel = radios.getPanel(); setBorder(radiosPanel); builder.add(radiosPanel, cc.xy(3, 3)); builder.add(createButton("Open file", FileNames.ICON_OPENFILE, loadAction), cc.xy(1, 5)); JTextPane load = createLabel("Load an existing ADDIS data file stored on your computer."); builder.add(load, cc.xy(3, 5)); builder.add(createButton("New dataset", FileNames.ICON_FILE_NEW, newAction), cc.xy(1, 7)); builder.add(createLabel("Start with an empty file to build up your own data and analyses."), cc.xy(3, 7)); builder.add(createImageLabel(FileNames.IMAGE_FOOTER), cc.xyw(1, 9, 3)); setContentPane(builder.getPanel()); }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Sets the UI properties of the button to unify the L&F. * //from w w w. ja va 2 s . c om * @param b The button. */ public static void unifiedButtonLookAndFeel(AbstractButton b) { if (b == null) return; //b.setMargin(new Insets(0, 2, 0, 3)); //b.setBorderPainted(false); //b.setFocusPainted(false); b.setOpaque(false); b.setBorder(new EmptyBorder(2, 2, 2, 2)); }