Last active
January 7, 2016 14:30
-
-
Save AnnaBoro/70470f787943478dbfa7 to your computer and use it in GitHub Desktop.
StoreUI1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson5_8.shop; | |
public class Launcher { | |
public static void main(String[] args) { | |
Store store = new Store(); | |
new StoreUI1(store); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson5_8.shop; | |
import javax.swing.*; | |
import java.awt.*; | |
import java.text.NumberFormat; | |
public class StoreUI1 { | |
private Store store; | |
public StoreUI1(Store store) { | |
this.store = store; | |
JFrame frame = new JFrame("STORE"); | |
frame.setMinimumSize(new Dimension(800, 600)); | |
frame.setLocation(300, 200); | |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
frame.getContentPane().add(createSellingPanel()); | |
frame.pack(); | |
frame.setVisible(true); | |
} | |
private JPanel createSellingPanel() { | |
JPanel panel = new JPanel(); | |
JLabel jName = new JLabel("Enter name: "); | |
JTextField jTField = new JTextField(20); | |
panel.add(jName); | |
panel.add(jTField); | |
JRadioButton bird1Button = new JRadioButton("bird1"); | |
JRadioButton bird2Button = new JRadioButton("bird2"); | |
JRadioButton bird3Button = new JRadioButton("bird3"); | |
ButtonGroup group = new ButtonGroup(); | |
group.add(bird1Button); | |
group.add(bird2Button); | |
group.add(bird3Button); | |
panel.add(bird1Button); | |
panel.add(bird2Button); | |
panel.add(bird3Button); | |
JLabel jNumber = new JLabel("Quantity: "); | |
NumberFormat nf = NumberFormat.getInstance(); | |
JFormattedTextField jTField2 = new JFormattedTextField(nf); | |
jTField2.setValue(1); | |
panel.add(jNumber); | |
panel.add(jTField2); | |
JButton buyButton = new JButton("BUY"); | |
panel.add(buyButton); | |
return panel; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment