Java Code Examples for javax.swing.JButton#setMinimumSize()

The following examples show how to use javax.swing.JButton#setMinimumSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JTSTestBuilderToolBar.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
private JButton createButton(String toolTipText, 
    ImageIcon icon, 
    java.awt.event.ActionListener actionListener)
{
  JButton btn = new JButton();
  btn.setMargin(new Insets(0, 0, 0, 0));
  btn.setPreferredSize(new Dimension(30, 30));
  btn.setIcon(icon);
  btn.setMinimumSize(new Dimension(30, 30));
  btn.setVerticalTextPosition(SwingConstants.BOTTOM);
  btn.setSelected(false);
  btn.setToolTipText(toolTipText);
  btn.setHorizontalTextPosition(SwingConstants.CENTER);
  btn.setFont(new java.awt.Font("SansSerif", 0, 10));
  btn.setMaximumSize(new Dimension(30, 30));
  btn.addActionListener(actionListener);
  return btn;
}
 
Example 2
Source File: SelectDisplaySettingsWizardPanel.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
private Component[] createColorField(String text, Color defaultColor) {
	JLabel colorLabel = new JLabel(text);
	final JTextField colorField = new JTextField();
	colorField.setEditable(false);
	colorField.setPreferredSize(txtDim);
	colorField.setMinimumSize(txtDim);
	colorField.setText(String.valueOf(defaultColor.getRGB()));	
	colorField.setBackground(defaultColor);
	JButton colorButton = new JButton();
	colorButton.setPreferredSize(buttonDim);
	colorButton.setMinimumSize(buttonDim);
	colorButton.setMaximumSize(buttonDim);
	colorButton.setIcon(ImageUtil.getImageIcon("copy_settings"));
	colorButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			Color color = ExtendedColorChooser.showDialog(SwingUtilities.getWindowAncestor(SelectDisplaySettingsWizardPanel.this), 
					I18NSupport.getString("color.dialog.title"), null);
			if (color != null) {
				colorField.setText(String.valueOf(color.getRGB()));	
				colorField.setBackground(color);
			}
		}			
	});		
	return new Component[] {colorLabel, colorField, colorButton};
}
 
Example 3
Source File: TraceEventTypePopupMenu.java    From pega-tracerviewer with Apache License 2.0 6 votes vote down vote up
private JButton getCancelJButton() {

        JButton cancelJButton = new JButton("Cancel");

        Dimension size = new Dimension(70, 20);
        cancelJButton.setPreferredSize(size);
        cancelJButton.setMinimumSize(size);
        cancelJButton.setMaximumSize(size);

        cancelJButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent event) {
                setVisible(false);
            }
        });

        return cancelJButton;
    }
 
Example 4
Source File: ServerDataSourceSelectionPanel.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
private void init() {
	dataSourceField = new JTextField();
	JButton dsButton = new JButton(ImageUtil.getImageIcon("database"));
	dsButton.setPreferredSize(buttonDim);
	dsButton.setMaximumSize(buttonDim);
	dsButton.setMinimumSize(buttonDim);
	dsButton.setToolTipText(I18NSupport.getString("wizard.panel.start.datasource.title"));
	dsButton.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {      
           	if (selection()) {
           		selectDataSourceDialog();
           	}
           }
       });
	
	setLayout(new GridBagLayout());
       
       add(dataSourceField, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
               GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
               new Insets(0, 0, 0, 0), 0, 0));
       add(dsButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
               GridBagConstraints.WEST, GridBagConstraints.NONE,
               new Insets(0, 5, 0, 0), 0, 0));
}
 
Example 5
Source File: JProductsSelector.java    From nordpos with GNU General Public License v3.0 6 votes vote down vote up
public void addProduct(Image img, String name, ActionListener al) {
    
    JButton btn = new JButton();
    btn.applyComponentOrientation(getComponentOrientation());
    btn.setText(name);
    btn.setFont(btn.getFont().deriveFont((float)24));
    btn.setIcon(new ImageIcon(img));
    btn.setFocusPainted(false);
    btn.setFocusable(false);
    btn.setRequestFocusEnabled(false);
    btn.setHorizontalTextPosition(SwingConstants.CENTER);
    btn.setVerticalTextPosition(SwingConstants.BOTTOM);
    btn.setMargin(new Insets(2, 2, 2, 2));
    btn.setMaximumSize(new Dimension(80, 70));
    btn.setPreferredSize(new Dimension(80, 70));
    btn.setMinimumSize(new Dimension(80, 70));
    btn.addActionListener(al);
    flowpanel.add(btn);        
}
 
Example 6
Source File: DataSourceWizardPanel.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
private void init() {
    setLayout(new BorderLayout());

    dataSourceCombo = new JComboBox();
    dataSourceCombo.setPreferredSize(dim);
    dataSourceCombo.setRenderer(new DataSourceRenderer());
    populateDataSources(null);

    addDataSourceButton = new JButton();
    addDataSourceButton.setPreferredSize(buttonDim);
    addDataSourceButton.setMaximumSize(buttonDim);
    addDataSourceButton.setMinimumSize(buttonDim);

    JPanel dsPanel = new JPanel(new GridBagLayout());
    dsPanel.add(new JLabel(I18NSupport.getString("wizard.panel.datasource.label")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(5, 5, 5, 0), 0, 0));
    dsPanel.add(dataSourceCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(5, 5, 5, 0), 0, 0));
    dsPanel.add(addDataSourceButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5), 0, 0));
    dsPanel.add(new JLabel(""), new GridBagConstraints(3, 0, 1, 2, 1.0, 1.0,
            GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5), 0, 0));
    add(dsPanel, BorderLayout.CENTER);
}
 
Example 7
Source File: StandardButtonHelper.java    From OpERP with MIT License 5 votes vote down vote up
public static JButton SetStandardSizeForButton(JButton btn){
	btn.setMaximumSize(new Dimension(95, 95));
	btn.setMinimumSize(new Dimension(95,95));
	btn.setHorizontalTextPosition(SwingConstants.CENTER);
	btn.setVerticalTextPosition(SwingConstants.BOTTOM);
	btn.setFont(new Font("Arial", Font.PLAIN, 10));
	return btn;
}
 
Example 8
Source File: DungeonScrollBarUi.java    From dungeon with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * This is a temporary solution to remove the buttons from BasicScrollBarUI.
 *
 * @return a JButton with all sizes set to zero
 */
private static JButton createZeroButton() {
  JButton button = new JButton();
  button.setPreferredSize(ZERO_DIMENSION);
  button.setMinimumSize(ZERO_DIMENSION);
  button.setMaximumSize(ZERO_DIMENSION);
  return button;
}
 
Example 9
Source File: RemoteTopologyPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static JButton buildButton(String resourceImagePath, ActionListener buttonListener, Dimension buttonSize) {
    ImageIcon icon = UIUtils.loadImageIcon(resourceImagePath);
    JButton button = new JButton(icon);
    button.setFocusable(false);
    button.addActionListener(buttonListener);
    button.setPreferredSize(buttonSize);
    button.setMinimumSize(buttonSize);
    button.setMaximumSize(buttonSize);
    return button;
}
 
Example 10
Source File: CustomScrollBarUI.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Creates an empty JButton to be used as the scroll bar's arrows (to disable the arrows).
 */
protected JButton createEmptyButton()
{
	JButton button = new JButton();
	Dimension zeroDim = new Dimension(0, 0);
	button.setPreferredSize(zeroDim);
	button.setMinimumSize(zeroDim);
	button.setMaximumSize(zeroDim);
	return button;
}
 
Example 11
Source File: TypeSelectionView.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private JButton createDataSourceSelectionButton(@SuppressWarnings("rawtypes") final DataSourceFactory factory) {
	String label = DataImportWizardUtils.getFactoryLabel(factory);
	String description = DataImportWizardUtils.getFactoryDescription(factory);

	JButton typeSelectionButton = new JButton(new AbstractAction() {

		private static final long serialVersionUID = 1L;

		@Override
		@SuppressWarnings("unchecked")
		public void actionPerformed(ActionEvent e) {
			enableDataSourceButtons(false);

			// update the wizard by setting the selected factory
			wizard.setDataSource(factory.createNew(), factory);

			// switch to the next wizard step (location selection)
			wizard.nextStep();
		}

	});

	typeSelectionButton.setText(label);
	typeSelectionButton.setToolTipText(description);

	typeSelectionButton.setMinimumSize(TYPE_BUTTON_DIMENSION);
	typeSelectionButton.setPreferredSize(TYPE_BUTTON_DIMENSION);
	typeSelectionButton.setMaximumSize(TYPE_BUTTON_DIMENSION);
	typeSelectionButton.setIcon(DataImportWizardUtils.getFactoryIcon(factory));

	return typeSelectionButton;
}
 
Example 12
Source File: HistoryColorChooserPanel.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
private JButton makeColorButton(String name) {
    JButton button = new JButton(name);
    button.setPreferredSize(btnDim);
    button.setMinimumSize(btnDim);
    button.setMaximumSize(btnDim);        
    button.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.WHITE),
            BorderFactory.createRaisedBevelBorder()));        
    button.setBackground(Color.GRAY);
    button.setEnabled(false);        
    return button;
}
 
Example 13
Source File: ExportJar.java    From bytecode-viewer with GNU General Public License v3.0 4 votes vote down vote up
public ExportJar(final String jarPath) {
    setSize(new Dimension(250, 277));
    setResizable(false);
    setTitle("Save As Jar..");

    JButton btnNewButton = new JButton("Save As Jar..");
    btnNewButton.setMaximumSize(new Dimension(999, 23));
    btnNewButton.setMinimumSize(new Dimension(999, 23));
    btnNewButton.setSize(new Dimension(999, 0));
    getContentPane().setLayout(
            new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    JScrollPane scrollPane = new JScrollPane();
    getContentPane().add(scrollPane);

    JLabel lblMetainfmanifestmf = new JLabel("META-INF/MANIFEST.MF:");
    scrollPane.setColumnHeaderView(lblMetainfmanifestmf);

    final JTextArea mani = new JTextArea();
    mani.setText("Manifest-Version: 1.0\r\nClass-Path: .\r\nMain-Class: ");
    scrollPane.setViewportView(mani);
    getContentPane().add(btnNewButton);

    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            BytecodeViewer.viewer.setIcon(true);
            Thread t = new Thread() {
                @Override
                public void run() {
                    JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), jarPath,
                            mani.getText());
                    BytecodeViewer.viewer.setIcon(false);
                }
            };
            t.start();
            dispose();
        }
    });

    this.setLocationRelativeTo(null);
}
 
Example 14
Source File: IsotopePeakScannerSetupDialog.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void addDialogComponents() {
  super.addDialogComponents();

  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

  pnlChart = new EChartPanel(chart);
  pnlChart.setPreferredSize(
      new Dimension((int) (screenSize.getWidth() / 3), (int) (screenSize.getHeight() / 3)));
  pnlPreview.add(pnlChart, BorderLayout.CENTER);


  // get components
  cmpAutoCarbon = (OptionalModuleComponent) this
      .getComponentForParameter(IsotopePeakScannerParameters.autoCarbonOpt);
  cmpAutoCarbonCbx = (JCheckBox) cmpAutoCarbon.getComponent(0);
  cmpPreview =
      (JCheckBox) this.getComponentForParameter(IsotopePeakScannerParameters.showPreview);
  cmpPreview.setSelected(false); // i want to have the checkbox below the pattern settings
  // but it should be disabled by default. Thats why it's hardcoded here.

  // get parameters
  pElement = parameterSet.getParameter(IsotopePeakScannerParameters.element);
  pMinIntensity = parameterSet.getParameter(IsotopePeakScannerParameters.minPatternIntensity);
  pCharge = parameterSet.getParameter(IsotopePeakScannerParameters.charge);
  pMergeWidth = parameterSet.getParameter(IsotopePeakScannerParameters.mergeWidth);
  pAutoCarbon = parameterSet.getParameter(IsotopePeakScannerParameters.autoCarbonOpt);
  autoCarbonParameters = pAutoCarbon.getEmbeddedParameters();
  pMinC = autoCarbonParameters.getParameter(AutoCarbonParameters.minCarbon);
  pMaxC = autoCarbonParameters.getParameter(AutoCarbonParameters.maxCarbon);
  pMinSize = autoCarbonParameters.getParameter(AutoCarbonParameters.minPatternSize);

  // set up gui
  form = new NumberFormatter(NumberFormat.getInstance());
  form.setValueClass(Integer.class);
  form.setFormat(new DecimalFormat("0"));
  form.setAllowsInvalid(true);
  form.setMinimum(minC);
  form.setMaximum(maxC);

  btnPrevPattern = new JButton("Previous");
  btnPrevPattern.addActionListener(this);
  btnPrevPattern.setMinimumSize(btnPrevPattern.getPreferredSize());
  btnPrevPattern.setEnabled(cmpAutoCarbonCbx.isSelected());

  txtCurrentPatternIndex = new JFormattedTextField(form);
  txtCurrentPatternIndex.addActionListener(this);
  txtCurrentPatternIndex.setText(String.valueOf((minC + maxC) / 2));
  txtCurrentPatternIndex.setPreferredSize(new Dimension(50, 25));
  txtCurrentPatternIndex.setEditable(true);
  txtCurrentPatternIndex.setEnabled(cmpAutoCarbonCbx.isSelected());

  btnNextPattern = new JButton("Next");
  btnNextPattern.addActionListener(this);
  btnNextPattern.setPreferredSize(btnNextPattern.getMinimumSize());
  btnNextPattern.setEnabled(cmpAutoCarbonCbx.isSelected());

  chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance",
      new XYSeriesCollection(new XYSeries("")));
  chart.getPlot().setBackgroundPaint(Color.WHITE);
  chart.getXYPlot().setDomainGridlinePaint(Color.GRAY);
  chart.getXYPlot().setRangeGridlinePaint(Color.GRAY);

  pnlPreviewButtons.add(btnPrevPattern);
  pnlPreviewButtons.add(txtCurrentPatternIndex);
  pnlPreviewButtons.add(btnNextPattern);

  pack();
}
 
Example 15
Source File: BESplitPaneDivider.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
 * Creates and return an instance of JButton that can be used to
 * collapse the right component in the split pane.
 *
 * @return the j button
 */
protected JButton createRightOneTouchButton() {
	JButton b = new JButton() {
		public void setBorder(Border border) {
		}
		public void paint(Graphics g) {
			if (splitPane != null) {
				int[]          xs = new int[3];
				int[]          ys = new int[3];
				int            blockSize;

				// Fill the background first ...
				g.setColor(this.getBackground());
				g.fillRect(0, 0, this.getWidth(),
						this.getHeight());

				//* 开启反走样
				BEUtils.setAntiAliasing((Graphics2D)g, true);
				
				// ... then draw the arrow.
				if (orientation == JSplitPane.VERTICAL_SPLIT) {
					blockSize = Math.min(getHeight(), oneTouchSize);
					xs[0] = blockSize;
					xs[1] = blockSize << 1;
					xs[2] = 0;
					ys[0] = blockSize;
					ys[1] = ys[2] = 0;
				}
				else {
					blockSize = Math.min(getWidth(), oneTouchSize);
					xs[0] = xs[2] = 0;
					xs[1] = blockSize;
					ys[0] = 0;
					ys[1] = blockSize;
					ys[2] = blockSize << 1;
				}

				//modified by jb2011
				g.setColor(TOUCH_BUTTON_COLOR);//Color.black);

				g.fillPolygon(xs, ys, 3);
				
				//* 关闭反走样
				BEUtils.setAntiAliasing((Graphics2D)g, false);
			}
		}
		// Don't want the button to participate in focus traversable.
		public boolean isFocusTraversable() {
			return false;
		}
	};
	b.setMinimumSize(new Dimension(oneTouchSize, oneTouchSize));
	b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	b.setFocusPainted(false);
	b.setBorderPainted(false);
	b.setRequestFocusEnabled(false);
	return b;
}
 
Example 16
Source File: AbstractUndoableMovesPanel.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
protected void setSize(final Dimension buttonSize, final JButton cancelButton) {
  cancelButton.setMinimumSize(buttonSize);
  cancelButton.setPreferredSize(buttonSize);
  cancelButton.setMaximumSize(buttonSize);
}
 
Example 17
Source File: ProLogWindow.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
private void settingsDetailsButtonActionPerformed() {
  final JDialog dialog = new JDialog(this, "Pro AI - Settings Details");
  String message = "";
  if (tabPaneMain.getSelectedIndex() == 0) { // Debugging
    message =
        "Debugging\r\n"
            + "\r\n"
            + "AI Logging: When this is checked, the AI's will output their logs, as they come "
            + "in, so you can see exactly what the AI is thinking.\r\n"
            + "Note that if you check this on, you still have to press OK then reopen the "
            + "settings window for the logs to actually start displaying.\r\n"
            + "\r\n"
            + "Log Depth: This setting lets you choose how deep you want the AI logging to be. "
            + "Fine only displays the high-level events, like the start of a phase, etc.\r\n"
            + "Finer displays medium-level events, such as attacks, reinforcements, etc.\r\n"
            + "Finest displays all the AI logging available. Can be used for detailed analysis, "
            + "but is a lot harder to read through it.\r\n"
            + "\r\n"
            + "Pause AI's: This checkbox pauses all the AI's while it's checked, so you can look "
            + "at the logs without the AI's outputting floods of information.\r\n"
            + "\r\n"
            + "Limit Log History To X Rounds: If this is checked, the AI log information will "
            + "be limited to X rounds of information.\r\n";
  }
  final JTextArea label = new JTextArea(message);
  label.setFont(new Font("Segoe UI", Font.PLAIN, 12));
  label.setEditable(false);
  label.setAutoscrolls(true);
  label.setLineWrap(false);
  label.setFocusable(false);
  label.setWrapStyleWord(true);
  label.setLocation(0, 0);
  dialog.setBackground(label.getBackground());
  dialog.setLayout(new BorderLayout());
  final JScrollPane pane = new JScrollPane();
  pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
  pane.setViewportView(label);
  dialog.add(pane, BorderLayout.CENTER);
  final JButton button = new JButton("Close");
  button.setMinimumSize(new Dimension(100, 30));
  button.addActionListener(e -> dialog.dispose());
  dialog.add(button, BorderLayout.SOUTH);
  dialog.setMinimumSize(new Dimension(500, 300));
  dialog.setSize(new Dimension(800, 600));
  dialog.setResizable(true);
  dialog.setLocationRelativeTo(this);
  dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  dialog.setVisible(true);
}
 
Example 18
Source File: ErrorDialog.java    From binnavi with Apache License 2.0 4 votes vote down vote up
private void createGui() {
  final JPanel topPanel = new JPanel(new BorderLayout());

  final JPanel messagePanel = new JPanel(new BorderLayout());

  final JTextField messageField = new JTextField();
  messageField.setEditable(false);
  messageField.setText(message);
  messageField.setBackground(Color.WHITE);

  messagePanel.add(messageField);

  messagePanel.setBorder(new TitledBorder("Error Message"));

  topPanel.add(messagePanel, BorderLayout.NORTH);

  final JTabbedPane tabbedPane = new JTabbedPane();

  final JTextArea descriptionArea = new JTextArea();

  descriptionArea.setEditable(false);
  descriptionArea.setText(description);
  descriptionArea.setLineWrap(true);
  descriptionArea.setWrapStyleWord(true);

  tabbedPane.addTab("Description", descriptionArea);

  if (exception != null) {
    final JTextArea traceArea = new JTextArea();

    traceArea.setEditable(false);
    traceArea.setText(StackTrace.toString(exception.getStackTrace()));

    tabbedPane.addTab("Stack Trace", new JScrollPane(traceArea));
  }

  add(topPanel, BorderLayout.NORTH);
  add(tabbedPane);

  final JPanel bottomButtonPanel = new JPanel(new BorderLayout());
  final JPanel leftButtonPanelBottom = new JPanel();

  final JButton reportButton = new JButton(new ReportAction());
  reportButton.setMinimumSize(new Dimension(180, reportButton.getHeight()));

  leftButtonPanelBottom.add(reportButton);

  bottomButtonPanel.add(leftButtonPanelBottom, BorderLayout.WEST);

  final JPanel rightButtonPanelBottom = new JPanel();
  final JButton okButton = new JButton(new CloseButtonListener());
  getRootPane().setDefaultButton(okButton);
  rightButtonPanelBottom.add(okButton);
  bottomButtonPanel.add(rightButtonPanelBottom, BorderLayout.EAST);
  add(bottomButtonPanel, BorderLayout.SOUTH);
}
 
Example 19
Source File: DarculaSplitPaneDivider.java    From Darcula with Apache License 2.0 4 votes vote down vote up
@Override
protected JButton createRightOneTouchButton() {
    JButton b = new JButton() {
        public void setBorder(Border border) {
        }
        public void paint(Graphics g) {
            if (splitPane != null) {
                int[]          xs = new int[3];
                int[]          ys = new int[3];
                int            blockSize;

                // Fill the background first ...
                g.setColor(this.getBackground());
                g.fillRect(0, 0, this.getWidth(),
                        this.getHeight());

                // ... then draw the arrow.
                if (orientation == JSplitPane.VERTICAL_SPLIT) {
                    blockSize = Math.min(getHeight(), ONE_TOUCH_SIZE);
                    xs[0] = blockSize;
                    xs[1] = blockSize << 1;
                    xs[2] = 0;
                    ys[0] = blockSize;
                    ys[1] = ys[2] = 0;
                }
                else {
                    blockSize = Math.min(getWidth(), ONE_TOUCH_SIZE);
                    xs[0] = xs[2] = 0;
                    xs[1] = blockSize;
                    ys[0] = 0;
                    ys[1] = blockSize;
                    ys[2] = blockSize << 1;
                }
                g.setColor(new DoubleColor(Gray._255, UIUtil.getLabelForeground()));
                g.fillPolygon(xs, ys, 3);
            }
        }
        // Don't want the button to participate in focus traversable.
        public boolean isFocusTraversable() {
            return false;
        }
    };
    b.setMinimumSize(new Dimension(ONE_TOUCH_SIZE, ONE_TOUCH_SIZE));
    b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    b.setFocusPainted(false);
    b.setBorderPainted(false);
    b.setRequestFocusEnabled(false);
    return b;
}
 
Example 20
Source File: UnicornSplitPaneUI.java    From Data_Processor with Apache License 2.0 4 votes vote down vote up
/**  
 * Creates and return an instance of JButton that can be used to  
 * collapse the right component in the split pane.  
 */  
@Override  
protected JButton createRightOneTouchButton() {   
	JButton b = new JButton() {   
		private static final long serialVersionUID = 1L;

		public void setBorder(Border border) {   
		}   

		@Override  
		public void paint(Graphics g) {   
			if (splitPane != null) {   
				int[] xs = new int[3];   
				int[] ys = new int[3];   
				int blockSize;   

				// Fill the background first ...   
				g.setColor(new Color(255,0,255));   
				g.fillRect(0, 0, this.getWidth(),   
						this.getHeight());   

				// ... then draw the arrow.   
				if (orientation == JSplitPane.VERTICAL_SPLIT) {   
					blockSize = Math.min(getHeight(), oneTouchSize);   
					xs[0] = blockSize;   
					xs[1] = blockSize << 1;   
					xs[2] = 0;   
					ys[0] = blockSize;   
					ys[1] = ys[2] = 0;   
				} else {   
					blockSize = Math.min(getWidth(), oneTouchSize);   
					xs[0] = xs[2] = 0;   
					xs[1] = blockSize;   
					ys[0] = 0;   
					ys[1] = blockSize;   
					ys[2] = blockSize << 1;   
				}   
				g.setColor(new Color(255,0,255));     
				g.fillPolygon(xs, ys, 3);   
			}   
		}   
		// Don't want the button to participate in focus traversable.   

		public boolean isFocusTraversable() {   
			return false;   
		}   
	};   
	b.setMinimumSize(new Dimension(oneTouchSize, oneTouchSize));   
	b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));   
	b.setFocusPainted(false);   
	b.setBorderPainted(false);   
	b.setRequestFocusEnabled(false);   
	return b;   
}