Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. import java.awt.BorderLayout;
  2. import java.awt.EventQueue;
  3.  
  4. import javax.swing.JFrame;
  5. import javax.swing.JPanel;
  6. import javax.swing.border.EmptyBorder;
  7. import java.awt.GridBagLayout;
  8. import java.awt.Choice;
  9. import java.awt.GridBagConstraints;
  10. import java.awt.Insets;
  11. import javax.swing.JTextField;
  12. import java.awt.Button;
  13.  
  14. public class Wyglad extends JFrame {
  15.  
  16. private JPanel contentPane;
  17. private JTextField textField_1;
  18. private JTextField textField;
  19. private Button button;
  20.  
  21. /**
  22. * Launch the application.
  23. */
  24. public static void main(String[] args) {
  25. EventQueue.invokeLater(new Runnable() {
  26. public void run() {
  27. try {
  28. Wyglad frame = new Wyglad();
  29. frame.setVisible(true);
  30. } catch (Exception e) {
  31. e.printStackTrace();
  32. }
  33. }
  34. });
  35. }
  36.  
  37. /**
  38. * Create the frame.
  39. */
  40. public Wyglad() {
  41. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  42. setBounds(100, 100, 450, 182);
  43. contentPane = new JPanel();
  44. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  45. contentPane.setLayout(new BorderLayout(0, 0));
  46. setContentPane(contentPane);
  47.  
  48. JPanel panel = new JPanel();
  49. contentPane.add(panel, BorderLayout.CENTER);
  50. GridBagLayout gbl_panel = new GridBagLayout();
  51. gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  52. gbl_panel.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
  53. gbl_panel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
  54. gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  55. panel.setLayout(gbl_panel);
  56.  
  57. textField = new JTextField();
  58. textField.setHorizontalAlignment(JTextField.RIGHT);
  59. GridBagConstraints gbc_textField = new GridBagConstraints();
  60. gbc_textField.gridheight = 2;
  61. gbc_textField.gridwidth = 4;
  62. gbc_textField.insets = new Insets(0, 0, 5, 5);
  63. gbc_textField.fill = GridBagConstraints.HORIZONTAL;
  64. gbc_textField.gridx = 1;
  65. gbc_textField.gridy = 1;
  66. panel.add(textField, gbc_textField);
  67. textField.setColumns(10);
  68.  
  69. textField_1 = new JTextField();
  70. textField_1.setHorizontalAlignment(JTextField.RIGHT);
  71. textField_1.setEditable(false);
  72. GridBagConstraints gbc_textField_1 = new GridBagConstraints();
  73. gbc_textField_1.gridheight = 2;
  74. gbc_textField_1.gridwidth = 4;
  75. gbc_textField_1.insets = new Insets(0, 0, 5, 5);
  76. gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
  77. gbc_textField_1.gridx = 9;
  78. gbc_textField_1.gridy = 1;
  79. panel.add(textField_1, gbc_textField_1);
  80. textField_1.setColumns(10);
  81.  
  82. Choice choice = new Choice();
  83. String[] tab = {"af","fa","ga","Ga","gs"};
  84. for(String s: tab)
  85. {
  86. choice.add(s);
  87. }
  88. GridBagConstraints gbc_choice = new GridBagConstraints();
  89. gbc_choice.insets = new Insets(0, 0, 5, 5);
  90. gbc_choice.gridwidth = 3;
  91. gbc_choice.gridx = 3;
  92. gbc_choice.gridy = 3;
  93. panel.add(choice, gbc_choice);
  94.  
  95. Choice choice_1 = new Choice();
  96. for(String s: tab)
  97. {
  98. choice_1.add(s);
  99. }
  100. GridBagConstraints gbc_choice_1 = new GridBagConstraints();
  101. gbc_choice_1.insets = new Insets(0, 0, 5, 0);
  102. gbc_choice_1.gridwidth = 3;
  103. gbc_choice_1.gridx = 11;
  104. gbc_choice_1.gridy = 3;
  105. panel.add(choice_1, gbc_choice_1);
  106.  
  107. button = new Button("Przelicz");
  108. button.setActionCommand("Przelicz");
  109. GridBagConstraints gbc_button = new GridBagConstraints();
  110. gbc_button.insets = new Insets(0, 0, 0, 5);
  111. gbc_button.gridx = 6;
  112. gbc_button.gridy = 4;
  113. panel.add(button, gbc_button);
  114. }
  115.  
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement