List of usage examples for javax.swing JButton setMargin
@BeanProperty(visualUpdate = true, description = "The space between the button's border and the label.") public void setMargin(Insets m)
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JButton getImageButton(ImageIcon icon) { JButton res = new JButton(icon); res.setMargin(new Insets(0, 0, 0, 0)); res.setBorderPainted(false);// w w w.j a va 2 s . co m res.setContentAreaFilled(false); return res; }
From source file:lisong_mechlab.view.graphs.DamageGraph.java
/** * Creates and displays the {@link DamageGraph}. * /*from w w w . j av a 2 s . co m*/ * @param aLoadout * Which load out the diagram is for. * @param anXbar * A {@link MessageXBar} to listen for changes to the loadout on. * @param aMaxSustainedDpsMetric * A {@link MaxSustainedDPS} instance to use in calculation. */ public DamageGraph(LoadoutBase<?> aLoadout, MessageXBar anXbar, MaxSustainedDPS aMaxSustainedDpsMetric) { super("Max Sustained DPS over range for " + aLoadout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); anXbar.attach(this); loadout = aLoadout; maxSustainedDPS = aMaxSustainedDpsMetric; chartPanel = new ChartPanel(makechart()); setContentPane(chartPanel); chartPanel.getChart().getLegend().setHorizontalAlignment(HorizontalAlignment.RIGHT); chartPanel.getChart().getLegend().setVerticalAlignment(VerticalAlignment.TOP); LegendTitle legendTitle = chartPanel.getChart().getLegend(); XYTitleAnnotation titleAnnotation = new XYTitleAnnotation(0.98, 0.98, legendTitle, RectangleAnchor.TOP_RIGHT); titleAnnotation.setMaxWidth(0.4); ((XYPlot) (chartPanel.getChart().getPlot())).addAnnotation(titleAnnotation); chartPanel.getChart().removeLegend(); chartPanel.setLayout(new OverlayLayout(chartPanel)); JButton button = new JButton( new OpenHelp("What is this?", "Max-sustained-dps-graph", KeyStroke.getKeyStroke('w'))); button.setMargin(new Insets(10, 10, 10, 10)); button.setFocusable(false); button.setAlignmentX(Component.RIGHT_ALIGNMENT); button.setAlignmentY(Component.BOTTOM_ALIGNMENT); chartPanel.add(button); setIconImage(ProgramInit.programIcon); setSize(800, 600); setVisible(true); }
From source file:lisong_mechlab.view.graphs.SustainedDpsGraph.java
/** * Creates and displays the {@link SustainedDpsGraph}. * /*from w ww.j av a 2s . c om*/ * @param aLoadout * Which load out the diagram is for. * @param aXbar * A {@link MessageXBar} to listen for changes to the loadout on. * @param aMaxSustainedDpsMetric * A {@link MaxSustainedDPS} instance to use in calculation. */ public SustainedDpsGraph(LoadoutBase<?> aLoadout, MessageXBar aXbar, MaxSustainedDPS aMaxSustainedDpsMetric) { super("Max Sustained DPS over range for " + aLoadout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); aXbar.attach(this); loadout = aLoadout; maxSustainedDPS = aMaxSustainedDpsMetric; chartPanel = new ChartPanel(makechart()); setContentPane(chartPanel); chartPanel.setLayout(new OverlayLayout(chartPanel)); JButton button = new JButton( new OpenHelp("What is this?", "Max-sustained-dps-graph", KeyStroke.getKeyStroke('w'))); button.setMargin(new Insets(5, 5, 5, 5)); button.setFocusable(false); button.setAlignmentX(Component.RIGHT_ALIGNMENT); button.setAlignmentY(Component.TOP_ALIGNMENT); chartPanel.add(button); setIconImage(ProgramInit.programIcon); setSize(800, 600); setVisible(true); }
From source file:org.datacleaner.widgets.result.PatternFinderResultSwingRendererCrosstabDelegate.java
@Override public JComponent render(CrosstabResult result) { final CrosstabPanel crosstabPanel = super.renderInternal(result); final DCTable table = crosstabPanel.getTable(); if (isInitiallyCharted(table) || isTooLimitedToChart(table)) { return crosstabPanel; }/*from ww w. j a va2 s .c om*/ final DCPanel headerPanel = new DCPanel(); headerPanel.setLayout(new FlowLayout(Alignment.RIGHT.getFlowLayoutAlignment(), 1, 1)); final JButton chartButton = WidgetFactory.createDefaultButton("Show distribution chart", IconUtils.CHART_BAR); chartButton.setMargin(new Insets(1, 1, 1, 1)); chartButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { headerPanel.setVisible(false); displayChart(table, crosstabPanel.getDisplayChartCallback()); } }); headerPanel.add(chartButton); final DCPanel panel = new DCPanel(); panel.setLayout(new BorderLayout()); panel.add(headerPanel, BorderLayout.NORTH); panel.add(crosstabPanel, BorderLayout.CENTER); return panel; }
From source file:org.eobjects.datacleaner.widgets.result.PatternFinderResultSwingRendererCrosstabDelegate.java
@Override public JComponent render(CrosstabResult result) { final CrosstabPanel crosstabPanel = super.renderInternal(result); final DCTable table = crosstabPanel.getTable(); if (isInitiallyCharted(table) || isTooLimitedToChart(table)) { return crosstabPanel; }/* www.j a va 2s .c o m*/ final DCPanel headerPanel = new DCPanel(); headerPanel.setLayout(new FlowLayout(Alignment.RIGHT.getFlowLayoutAlignment(), 1, 1)); final JButton chartButton = new JButton("Show distribution chart", ImageManager.get().getImageIcon("images/chart-types/bar.png")); chartButton.setMargin(new Insets(1, 1, 1, 1)); chartButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { headerPanel.setVisible(false); displayChart(table, crosstabPanel.getDisplayChartCallback()); } }); headerPanel.add(chartButton); final DCPanel panel = new DCPanel(); panel.setLayout(new BorderLayout()); panel.add(headerPanel, BorderLayout.NORTH); panel.add(crosstabPanel, BorderLayout.CENTER); return panel; }
From source file:com.haulmont.cuba.desktop.gui.components.CubaFileUploadWrapper.java
public CubaFileUploadWrapper(Button uploadButton) { setLayout(new BorderLayout()); ComponentsFactory componentsFactory = AppBeans.get(ComponentsFactory.NAME); container = (DesktopHBox) componentsFactory.createComponent(DesktopHBox.NAME); container.setSpacing(true);//from w w w . j av a2 s .c o m add(container.unwrap(JPanel.class)); fileNameButton = (LinkButton) componentsFactory.createComponent(LinkButton.NAME); fileNameButton.setVisible(false); fileNameButton.setAction(new AbstractAction("") { @Override public void actionPerform(Component component) { if (fileNameButtonClickListener != null) { fileNameButtonClickListener.run(); } } }); setFileName(null); container.add(fileNameButton); fileNameButton.setAlignment(Component.Alignment.MIDDLE_LEFT); this.uploadButton = uploadButton; JButton jUploadButton = uploadButton.unwrap(JButton.class); jUploadButton.setMargin(new Insets(0, 0, 0, 0)); container.add(uploadButton); uploadButton.setAlignment(Component.Alignment.MIDDLE_RIGHT); clearButton = (Button) componentsFactory.createComponent(Button.NAME); clearButton.setAction(new AbstractAction("") { @Override public void actionPerform(Component component) { if (clearButtonListener != null) { clearButtonListener.run(); } } }); clearButton.setCaption(messages.getMainMessage("FileUploadField.clearButtonCaption")); clearButton.setVisible(false); JButton jClearButton = clearButton.unwrap(JButton.class); jClearButton.setMargin(new Insets(0, 0, 0, 0)); container.add(clearButton); clearButton.setAlignment(Component.Alignment.MIDDLE_RIGHT); setShowFileName(false); }
From source file:TextSamplerDemo.java
protected void addStylesToDocument(StyledDocument doc) { //Initialize some styles. Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "SansSerif"); Style s = doc.addStyle("italic", regular); StyleConstants.setItalic(s, true); s = doc.addStyle("bold", regular); StyleConstants.setBold(s, true); s = doc.addStyle("small", regular); StyleConstants.setFontSize(s, 10); s = doc.addStyle("large", regular); StyleConstants.setFontSize(s, 16); s = doc.addStyle("icon", regular); StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER); ImageIcon pigIcon = createImageIcon("images/Pig.gif", "a cute pig"); if (pigIcon != null) { StyleConstants.setIcon(s, pigIcon); }/* w w w . j a va2s .c om*/ s = doc.addStyle("button", regular); StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER); ImageIcon soundIcon = createImageIcon("images/sound.gif", "sound icon"); JButton button = new JButton(); if (soundIcon != null) { button.setIcon(soundIcon); } else { button.setText("BEEP"); } button.setCursor(Cursor.getDefaultCursor()); button.setMargin(new Insets(0, 0, 0, 0)); button.setActionCommand(buttonString); button.addActionListener(this); StyleConstants.setComponent(s, button); }
From source file:DateChooserPanel.java
/** * Returns a panel of buttons, each button representing a day in the month. * This is a sub-component of the DatePanel. * * @return the panel./*from w w w.j av a2 s . c o m*/ */ private JPanel getCalendarPanel() { final JPanel p = new JPanel(new GridLayout(7, 7)); final DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(); final String[] weekDays = dateFormatSymbols.getShortWeekdays(); for (int i = 0; i < this.WEEK_DAYS.length; i++) { p.add(new JLabel(weekDays[this.WEEK_DAYS[i]], SwingConstants.CENTER)); } this.buttons = new JButton[42]; for (int i = 0; i < 42; i++) { final JButton b = new JButton(""); b.setMargin(new Insets(1, 1, 1, 1)); b.setName(Integer.toString(i)); b.setFont(this.dateFont); b.setFocusPainted(false); b.setActionCommand("dateButtonClicked"); b.addActionListener(this); this.buttons[i] = b; p.add(b); } return p; }
From source file:com.vgi.mafscaling.LogPlay.java
private JButton addPlayerButton(int column, ImageIcon icon) { JButton button = new JButton(icon); button.putClientProperty("Nimbus.Overrides", zeroInsets); button.setMargin(insets0); button.setBorderPainted(false);/*from w w w . j a v a 2 s. com*/ button.setContentAreaFilled(false); button.addActionListener(this); GridBagConstraints gbc_button = new GridBagConstraints(); gbc_button.insets = insets0; gbc_button.anchor = GridBagConstraints.WEST; gbc_button.gridx = column; gbc_button.gridy = 1; playerPanel.add(button, gbc_button); return button; }
From source file:com.intuit.tank.proxy.ProxyApp.java
private JButton createButton(Action a) { JButton ret = new JButton(a); ret.setText(""); ret.setMargin(new Insets(3, 3, 3, 3)); // ret.setIcon((Icon) a.getValue(Action.SMALL_ICON_KEY)); return ret;/*from ww w . j a va2s . c om*/ }