Guest User

Untitled

a guest
Jan 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.23 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3.  
  4. /*
  5. * To change this template, choose Tools | Templates
  6. * and open the template in the editor.
  7. */
  8.  
  9. /*
  10. * View.java
  11. *
  12. * Created on 2011-03-13, 18:46:53
  13. */
  14.  
  15. /**
  16. *
  17. * @author ksysu
  18. */
  19. public class View extends javax.swing.JFrame {
  20.  
  21. /** Creates new form View */
  22. public View() {
  23. initComponents();
  24. }
  25.  
  26. /** This method is called from within the constructor to
  27. * initialize the form.
  28. * WARNING: Do NOT modify this code. The content of this method is
  29. * always regenerated by the Form Editor.
  30. */
  31. @SuppressWarnings("unchecked")
  32. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  33. private void initComponents() {
  34.  
  35. panel = new javax.swing.JPanel();
  36. text = new javax.swing.JLabel();
  37. rozmiar = new javax.swing.JTextField();
  38. czysc = new javax.swing.JButton();
  39. jComboBox1 = new javax.swing.JComboBox();
  40.  
  41. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  42. setResizable(false);
  43. addMouseListener(new java.awt.event.MouseAdapter() {
  44. public void mouseClicked(java.awt.event.MouseEvent evt) {
  45. formMouseClicked(evt);
  46. }
  47. });
  48.  
  49. panel.setBackground(new java.awt.Color(255, 0, 15));
  50. panel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
  51. panel.setForeground(new java.awt.Color(1, 1, 1));
  52. panel.setDoubleBuffered(true);
  53.  
  54. javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel);
  55. panel.setLayout(panelLayout);
  56. panelLayout.setHorizontalGroup(
  57. panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  58. .addGap(0, 528, Short.MAX_VALUE)
  59. );
  60. panelLayout.setVerticalGroup(
  61. panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  62. .addGap(0, 259, Short.MAX_VALUE)
  63. );
  64.  
  65. text.setText("Rozmiar:");
  66.  
  67. czysc.setText("Wyczyść");
  68.  
  69. jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
  70.  
  71. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  72. getContentPane().setLayout(layout);
  73. layout.setHorizontalGroup(
  74. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  75. .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  76. .addGroup(layout.createSequentialGroup()
  77. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  78. .addComponent(czysc)
  79. .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  80. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 297, Short.MAX_VALUE)
  81. .addComponent(text)
  82. .addGap(18, 18, 18)
  83. .addComponent(rozmiar, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
  84. );
  85. layout.setVerticalGroup(
  86. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  87. .addGroup(layout.createSequentialGroup()
  88. .addComponent(panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  89. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
  90. .addComponent(czysc)
  91. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  92. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  93. .addComponent(rozmiar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  94. .addComponent(text)
  95. .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
  96. );
  97.  
  98. pack();
  99. }// </editor-fold>//GEN-END:initComponents
  100.  
  101. private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
  102. Graphics g= panel.getGraphics();
  103. g.setColor(Color.BLACK);
  104. g.fillRect(evt.getX()-1, evt.getY()-29, 20, 20);
  105. }//GEN-LAST:event_formMouseClicked
  106.  
  107. /**
  108. * @param args the command line arguments
  109. */
  110. public static void main(String args[]) {
  111. java.awt.EventQueue.invokeLater(new Runnable() {
  112. public void run() {
  113. new View().setVisible(true);
  114. }
  115. });
  116. }
  117.  
  118. // Variables declaration - do not modify//GEN-BEGIN:variables
  119. private javax.swing.JButton czysc;
  120. private javax.swing.JComboBox jComboBox1;
  121. private javax.swing.JPanel panel;
  122. private javax.swing.JTextField rozmiar;
  123. private javax.swing.JLabel text;
  124. // End of variables declaration//GEN-END:variables
  125.  
  126. }
Add Comment
Please, Sign In to add comment