jbutton

Solutions on MaxInterview for jbutton by the best coders in the world

showing results for - "jbutton"
Paula
20 Jan 2017
1btn.setFocusable(false);
2btn.setBorderPainted(false);
Silvia
18 Mar 2019
1import java.awt.Dimension;
2import java.awt.Font;
3
4import javax.swing.JButton;
5import javax.swing.JFrame;
6
7public class Jbutton {
8
9	public static void main(String[] args) {
10
11		JFrame frame = new JFrame("GRProgram");
12	    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
13	    int width = 400;										// Window Value Width 
14	    int height = 300;										// Window Value Height								
15	    frame.setSize(width,height);							// Window Dimension with Variables 
16	    frame.setLayout(null);									//better Layout
17	   	    
18	    JButton button = new JButton();
19	    String bText = "My Button in a long version";			// String value for Button
20	    button.setText(bText);									// set String for Button Text
21	    String tText = "Tool Tip text";							// String value for ToolTip on Button
22	    button.setToolTipText(tText);							// set String for Button ToolTipText
23	    Font schriftart=new Font("Arial",Font.BOLD,18);			// Define a Font, mayby Bold and size
24	    button.setFont(schriftart);								// Set Font on Botton
25	    Dimension size = button.getPreferredSize();				// Get prefered Size for Button on Text Size 
26	    button.setBounds(width/5, height/5, size.width, size.height);	// Set Button Start Point (Left upper Corner) and Size on text Size
27	    
28	    frame.add(button);
29	    frame.setVisible(true);
30		
31	}
32
33}