Java examples for Swing:JButton
create Small JButton
/******************************************************************************* * Copyright (c) 2011 Zeljko Zirikovic./*from w ww . j av a2 s . com*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GPL which * accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html ******************************************************************************/ //package com.java2s; import javax.swing.JButton; import javax.swing.SwingConstants; import javax.swing.border.EmptyBorder; public class Main { public static void main(String[] argv) throws Exception { System.out.println(createSmallButton()); } public static JButton createSmallButton() { JButton button = new JButton(); button.setBorderPainted(false); button.setBorder(new EmptyBorder(0, 1, 0, 1)); button.setContentAreaFilled(false); button.setFocusPainted(false); button.setRolloverEnabled(true); button.setHorizontalAlignment(SwingConstants.CENTER); return button; } }