https://azartspeles.online
Thanks for sharing your thoughts. I really appreciate your efforts and I will be waiting for your next post thanks once again.https://azartspeles.online
public class ButtonGrid { public static void main(String[] args) { } }.
インポート:
import javax.swing.JFrame; import javax.swing.JButton; import java.awt.GridLayout; public class ButtonGrid { ...
コンストラクタ・コード:
public class ButtonGrid { public ButtonGrid(int width, int length){ } ...
フレーム・コード:
public class ButtonGrid { JFrame frame=new Jframe(); public ButtonGrid(int width, int length){ frame.setLayout(new GridLayout(width,length)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } } ...
ボタングリッドのコード
|JFrame frame=new JFrame(); //フレームを作成 JButton[][] grid; //ボタングリッドの名前 public ButtonGrid(int width, int length){ //2つのパラメータを持つコンストラクタ frame.setLayout(new GridLayout(width,length)); //フレームのレイアウトを設定 grid=new JButton[width][length]; //グリッドのサイズを確保 for(int y=0; y
フレームにボタンを追加します:
for(int y=0; y
ボタン・グリッドのインスタンスを作る:
public static void main(String[] args) { new ButtonGrid(3,3);//makes new ButtonGrid with 2 parameters } ...
最終コード
import javax.swing.JFrame; //imports JFrame library import javax.swing.JButton; //imports JButton library import java.awt.GridLayout; //imports GridLayout library public class ButtonGrid { JFrame frame=new JFrame(); //フレームを作成 JButton[][] grid; //ボタンのグリッドを指定 public ButtonGrid(int width, int length){ //constructor frame.setLayout(new GridLayout(width,length)); //レイアウトを設定 grid=new JButton[width][length]; //グリッドのサイズを確保 for(int y=0; y
public ButtonGrid(int width, int length){ //constructor frame.setLayout(new GridLayout(width,length)); //レイアウトを設定 grid=new JButton[width][length]; //グリッドのサイズを確保 for(int y=0; y
コメント
最新を表示する
NG表示方式
NGID一覧