Advertisement
Guest User

bimbo

a guest
Mar 25th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.46 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package FiguriPanel;
  7.  
  8. import java.awt.Color;
  9. import java.awt.Graphics;
  10.  
  11. /**
  12. *
  13. * @author student
  14. */
  15. public class MyFrame extends javax.swing.JFrame {
  16.  
  17. /**
  18. * Creates new form MyFrame
  19. */
  20. public MyFrame() {
  21. initComponents();
  22. }
  23.  
  24. /**
  25. * This method is called from within the constructor to initialize the form.
  26. * WARNING: Do NOT modify this code. The content of this method is always
  27. * regenerated by the Form Editor.
  28. */
  29. @SuppressWarnings("unchecked")
  30. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  31. private void initComponents() {
  32.  
  33. jPanel1 = new javax.swing.JPanel();
  34. jButonCerc = new javax.swing.JButton();
  35. jButonPatrat = new javax.swing.JButton();
  36. jButonLinie = new javax.swing.JButton();
  37.  
  38. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  39.  
  40. jPanel1.setBackground(new java.awt.Color(255, 255, 255));
  41.  
  42. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  43. jPanel1.setLayout(jPanel1Layout);
  44. jPanel1Layout.setHorizontalGroup(
  45. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  46. .addGap(0, 731, Short.MAX_VALUE)
  47. );
  48. jPanel1Layout.setVerticalGroup(
  49. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  50. .addGap(0, 412, Short.MAX_VALUE)
  51. );
  52.  
  53. jButonCerc.setBackground(new java.awt.Color(255, 255, 255));
  54. jButonCerc.setText("Cerc");
  55. jButonCerc.addActionListener(new java.awt.event.ActionListener() {
  56. public void actionPerformed(java.awt.event.ActionEvent evt) {
  57. jButonCercActionPerformed(evt);
  58. }
  59. });
  60.  
  61. jButonPatrat.setBackground(new java.awt.Color(255, 255, 255));
  62. jButonPatrat.setText("Patrat");
  63. jButonPatrat.addActionListener(new java.awt.event.ActionListener() {
  64. public void actionPerformed(java.awt.event.ActionEvent evt) {
  65. jButonPatratActionPerformed(evt);
  66. }
  67. });
  68.  
  69. jButonLinie.setBackground(new java.awt.Color(255, 255, 255));
  70. jButonLinie.setText("Linie");
  71.  
  72. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  73. getContentPane().setLayout(layout);
  74. layout.setHorizontalGroup(
  75. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  76. .addGroup(layout.createSequentialGroup()
  77. .addGap(47, 47, 47)
  78. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  79. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE)
  80. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  81. .addComponent(jButonCerc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  82. .addComponent(jButonPatrat, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE)
  83. .addComponent(jButonLinie, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  84. .addGap(43, 43, 43))
  85. );
  86. layout.setVerticalGroup(
  87. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  88. .addGroup(layout.createSequentialGroup()
  89. .addGap(37, 37, 37)
  90. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  91. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  92. .addGroup(layout.createSequentialGroup()
  93. .addComponent(jButonCerc, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
  94. .addGap(40, 40, 40)
  95. .addComponent(jButonPatrat, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
  96. .addGap(49, 49, 49)
  97. .addComponent(jButonLinie, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)))
  98. .addContainerGap(64, Short.MAX_VALUE))
  99. );
  100.  
  101. pack();
  102. }// </editor-fold>
  103.  
  104. private void jButonCercActionPerformed(java.awt.event.ActionEvent evt) {
  105. // TODO add your handling code here:
  106. System.out.println("Click cerc");
  107. Graphics g=jPanel1.getGraphics();
  108. g.setColor(Color.red);
  109. g.drawOval(100, 100, 100, 100);
  110. }
  111.  
  112. private void jButonPatratActionPerformed(java.awt.event.ActionEvent evt) {
  113. // TODO add your handling code here:
  114. System.out.println("Click patrat");
  115. Graphics g=jPanel1.getGraphics();
  116. g.setColor(Color.blue);
  117. g.drawRect(150, 150, 100, 100);
  118. }
  119.  
  120. /**
  121. * @param args the command line arguments
  122. */
  123. public static void main(String args[]) {
  124. /* Set the Nimbus look and feel */
  125. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  126. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  127. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  128. */
  129. try {
  130. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  131. if ("Nimbus".equals(info.getName())) {
  132. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  133. break;
  134. }
  135. }
  136. } catch (ClassNotFoundException ex) {
  137. java.util.logging.Logger.getLogger(MyFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  138. } catch (InstantiationException ex) {
  139. java.util.logging.Logger.getLogger(MyFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  140. } catch (IllegalAccessException ex) {
  141. java.util.logging.Logger.getLogger(MyFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  142. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  143. java.util.logging.Logger.getLogger(MyFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  144. }
  145. //</editor-fold>
  146.  
  147. /* Create and display the form */
  148. java.awt.EventQueue.invokeLater(new Runnable() {
  149. public void run() {
  150. new MyFrame().setVisible(true);
  151. }
  152. });
  153. }
  154.  
  155. // Variables declaration - do not modify
  156. private javax.swing.JButton jButonCerc;
  157. private javax.swing.JButton jButonLinie;
  158. private javax.swing.JButton jButonPatrat;
  159. private javax.swing.JPanel jPanel1;
  160. // End of variables declaration
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement