Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java button

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

public class MyFrame {
  
MyFrame() 
  
     	JFrame frame = new JFrame("Title");

  		frame.setTitle("JFrame title"); // Frame title
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Exit out of app
        frame.setResizable(true); // Prevent frame from being resized, or not
        frame.setSize(500,500); // Sets x and y 
        frame.setVisible(true); //makes frame visible
  
		button = new JButton(); // creates button

 		Border border = BorderFactory.createLineBorder(Color.green, 3); // specifies border

        button.setBounds(200, 100, 100, 50); // button properties
        button.setBorder(border); // gives button border
        button.setText("A nice button"); // button text

		MyFrame.add(button); //adds button to frame
   
}}
Comment

java button

import javax.swing.*;    
public class button {  
public static void main(String[] args) {  

JFrame frame = new JFrame;
frame.setSize(400, 400);
frame.setVisible(true);
frame.setLayout(null);
  
  //create button
  
JButton btn = new JButton("ok");
btn.setBounds(150, 200, 50, 50); // Properties of button, size, x, and y.
  
  //append button to frame
  
frame.add(btn);

}}
Comment

PREVIOUS NEXT
Code Example
Java :: string starts with alphabet java 
Java :: coding collections clear method java 
Java :: convert class to xml string 
Java :: android studio get string from strings.xml 
Java :: convert hashset to array 
Java :: java selenium select 
Java :: play sound on button click android studio 
Java :: how to add transition between activities android studio 
Java :: get first 5 characters of string java 
Java :: implement graph in java example 
Java :: convert ascii to string java 
Java :: greatest common divisor java 
Java :: java program to find perimeter of rectangle 
Java :: java convert list to page 
Java :: read csv java android 
Java :: hibernate select count 
Java :: how to check if a char is a letter java 
Java :: set char value to null java 
Java :: android studio fragment findviewbyid 
Java :: dagger dependency maven dependency 
Java :: how to set title in center in toolbar in android 
Java :: convert java to kotlin online editor 
Java :: isinstance java 
Java :: rjava error 
Java :: Java JPanel set background color 
Java :: Uri from bitmap java android 
Java :: java add com.google.guava dependancy maven 
Java :: java random uuid 
Java :: make frame visible java 
Java :: android BottomSheetDialogFragment not opening fully on landscape 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =