Share on Google+Share on Google+

1 Answer(s)      8 years ago
Posted in : Java Beginners


View Answers

October 14, 2008 at 5:34 PM


import javax.swing.*;
import java.awt.*;

public class ButtonSizeDemo extends JFrame {

private Toolkit toolkit;

public ButtonSizeDemo() {

setTitle("Set button size application");
setSize(300, 200);

toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation((size.width - getWidth())/2, (size.height - getHeight())/2);

JPanel panel = new JPanel();

panel.setToolTipText("A Panel container");

JButton button = new JButton("Button");
button.setBounds(100, 60, 80, 30);
button.setToolTipText("A button component");



public static void main(String[] args) {

ButtonSizeDemo bs = new ButtonSizeDemo();


Please visit for more information,


Related Tutorials/Questions & Answers:
Java Swings
Java Swings  I am doing one project on java Swings, in this i have created one jframe where i defined some JButtons and Jcombobox's, here i need to insert one JTable with headers(IN CURRENT JFrame only).pls help me urgently
java swings - Java Beginners
java swings   Do you want to add textfields on the JPanel
java swings - Java Beginners
java swings   Hi, I need the code for click the refresh button then list values will be refresh.Please send the code ........... Thanks, Valarmathi
java swings - Java Beginners
java swings   Hi, I need the code for joptionpane with jcombobox. my requirement is click on add button,one joptionpane will come.from the option pane i need to select the combobox values. Please send the sample code
java swings - Swing AWT
write the code for bar charts using java swings.  Hi friend, I swings  I am doing a project for my company. I need a to show....
java swings - Java Beginners
java swings   Hi, I already posted the question for three times.... I have two listboxes.If i select first value in the first listbox and moved to second listbox.The next time the same value will not able to move the first
java swings - Java Beginners
java swings   Hi, I have two classes(two tabbed panes). how can i get the one class jtextfield value into another class method. Please send the code as sson as possible. Thanks, Valarmathi  Hi Friend, Try
java swings - Java Beginners
java swings   Hi , I have two listboxes.I want to move one listbox... correct the value and send it to me. This is my java code package...,because place the xml file in the c:/ directly and run the java code
java swings - Java Beginners
java swings   Hi, This is my code. How can i set the jtextfield...", Font.BOLD, 12)); javapathname = new JLabel("Java Path"); javatextpath = new JTextField(33); javatextpath.setToolTipText("Java Installation Path
java swings - Java Beginners
java swings   hi, I posted the same question two times,but i didnt get the reply. Please change the jframe look and feel type of code.please send the code immediately. This is my code package; import
Java Swings-awt - Swing AWT
Java Swings-awt  Hi, Thanks for posting the Answer... I need to design a tool Bar which looks like a Formating toolbar in MS-Office Winword(Standard & Formating) tool Bar. Please help me... Thanks in Advance
Java Swings problem - Swing AWT
Java Swings problem  Sir, I am facing a problem in JSplitPane. I want the divider in the splitpane to be customized. I have a splitpane with Horizontal orientation and here, there lies the divider between left component and right
java swings
java swings  how can we use the shared locks of dbms in java? I am working on a mini project which is based on the eamcet councilling .i am struck with a problem where if a student select a college and a branch and sees
java swings
java swings  Hi, I have one class file using three panel methods,the three methods is used for three tabs.then how can i set the background image.Please send the sample code for me. I already posted two questions,but i didnt get
java swings
java swings  hi... I am having multiple swing forms.. when i click on a button another form is going to opening but it is opening as different form... Now i want it to be open dynamically instead separately.... Is there any
java swings
java swings  Hi, I need a sample code for once click the exit tab the frame window will be closed. Instead of button close i need tab close option.Please send the sample code immediately.......?Its very urgent........ Thanks
java swings
java swings  Hi, I need the sample code for how to set the background image using jframe and also set the jtext field and jlable boxes under the bachground image. Please send the code immediately,its very urgent.Please send me
File format validation and text field validation in java swings
File format validation and text field validation in java swings   i am reading a jpg image file throuh jfilechooser in java swings,when we press... 'please select jpg file only' plz give me the code in swings. Please
Java Swings - Java Beginners
Java Swings  hi , I am doing project using netbeans. I have a combobox . I want to add items in that combobox from a method.For this i found... code:
Java swings - Swing AWT
Java swings  i have the following class .In that class i has two panels,panel1and panel2.panel1 contains an image.i want drag it in panel2(gray background).but i dont want to remove the image from panel1.i want
java swings - Java Beginners
java swings  hi, I send two questions ,but i didnt reply .please reply me back. I need the jfiledialog select option is only for directory... c:/valar/ only. This code is only for c:/valar/some.txt,pdf... import
java swings - JavaMail
java swings  Hi sir,i am doing a project on swings,i don't have any...://
java swings - Java Beginners
java swings  Hi, I need the code for how can i set the joptionpane color(background and foreground). can i set the delay time for joptionpane display. Please send the code .its urgent. Thanks, Valarmathi
java swings - IDE Questions
java swings  I'm developing a java desktop database application using NetBeans 6.5 and using mysql as database,When I create the table and link with my program it automatically gives the front end;can I change the look and feel
java swings - Java Beginners
java swings  Hi, I have two list boxes.From the first listbox i have some value ,i can select the value from the first listbox and it is moved... send the question so many times. Please send the answer. This is my java
java swings - Java Beginners
java swings  Hi, I have two list boxes.From the first listbox i have some value ,i can select the value from the first listbox and it is moved to the second listbox using add button and the value is moved into one by one
java swings - Java Beginners
java swings  Hi, I need only directory selection filedialog. This code is only for text file selection, c:/valar/file.txt or c:/valar/file.pdf,file.html.... but i need c:/valar only import java.awt.*; import
java swings - Java Beginners
java swings  Hi , This is my java code.Please change the code as swing look and feel.... Please change the code and send it quickly its very urgent. package; import java.awt.Color; import
java swings - Swing AWT
java swings  hi everyone, can we make a chain of frames with JSplitpane and run a shell script in any one of those frames
java swings - Java Beginners
java swings  hi, can i set the delay time for joptionpane. I need the sample code. And i need the Refresh jbutton sample code. ie i have two listboxes.I need to move the value from first listbox into second listbox.then
Java Swings - Java Beginners
Java Swings  Hi, I am sending example button program. Please check it and give answer. I have an urgent requuirement with this. //The sample program import javax.swing.*; class ButtonSizeTest extends JFrame { JButton
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized


Advertisement null