“Tombol Java” Kode Jawaban

Tombol Java

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
   
}}
ayaan

Tombol Java

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);

}}
ayaan

Jawaban yang mirip dengan “Tombol Java”

Pertanyaan yang mirip dengan “Tombol Java”

Lebih banyak jawaban terkait untuk “Tombol Java” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya