“bouton java” Réponses codées

bouton 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

bouton 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

Réponses similaires à “bouton java”

Questions similaires à “bouton java”

Plus de réponses similaires à “bouton java” dans Java

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code