Skip to content

Instantly share code, notes, and snippets.

@cgravier
Created October 9, 2012 09:28
Show Gist options
  • Save cgravier/3857630 to your computer and use it in GitHub Desktop.
Save cgravier/3857630 to your computer and use it in GitHub Desktop.
Answer to warm up exercise 2, JavaLabs #8 part a
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Deux {
public static void main(String[] args) {
JFrame fenetre=new JFrame("Exo 2");
Container tmp = fenetre.getContentPane();
tmp.setLayout(new BoxLayout(tmp, BoxLayout.Y_AXIS));
JTextField zoneSaisie = new JTextField(10);
JPanel panSaisie = new JPanel();
panSaisie.setLayout(new FlowLayout());
panSaisie.add(zoneSaisie);
tmp.add(panSaisie);
JPanel boutonsChoix = new JPanel();
boutonsChoix.setLayout(new FlowLayout());
JButton b1 = new JButton("1");
b1.setSize(new Dimension(80,80));
boutonsChoix.add(b1);
JButton b2 = new JButton("2");
b1.setSize(new Dimension(80,80));
boutonsChoix.add(b2);
tmp.add(boutonsChoix);
fenetre.setSize(150,100);
fenetre.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment