Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. package graphicsNEw;
  2. //1.set Panel-yes\ 2.set Default text-yes\set Buttons-not yet
  3. import java.awt.*;
  4.  
  5. import javax.swing.*;
  6. import javax.swing.event.*;
  7.  
  8. import java.awt.event.*;
  9. import java.util.*;
  10. public class tzayar extends JFrame {
  11. static
  12. JButton[] SUP=new JButton[7];
  13. JPanel panel;
  14. JLabel picture,text;
  15. Color color=(Color.WHITE);
  16. String[] buttons ={"backG","line","squereF","squereNF","textWC","textNC","Circle","rect3D"};
  17. JButton but[]=new JButton[7];
  18. public tzayar(){
  19. super ("Tzayar");
  20. setLayout(new FlowLayout());
  21.  
  22. panel = new JPanel ();
  23. panel.setBackground(color);
  24. panel.setPreferredSize(new Dimension(350,350));
  25. add(panel);
  26.  
  27. picture = new JLabel();
  28. picture.setIcon(new ImageIcon(getClass().getResource("PaintSmall.png")));
  29. add(picture,BorderLayout.NORTH);
  30.  
  31. text = new JLabel("Default");
  32. add(text,BorderLayout.SOUTH);
  33. button betu = new button();
  34. for(int counter=0;counter<SUP.length;counter++){
  35. SUP[counter] = new JButton(buttons[counter]);
  36. add(SUP[counter]);
  37. SUP[counter].addActionListener(betu);
  38. }
  39.  
  40.  
  41. handler han = new handler();
  42. panel.addMouseMotionListener(han);
  43. panel.addMouseListener(han);
  44.  
  45.  
  46.  
  47. }
  48. //class for changing text-MouseEvent
  49. private class handler extends MouseAdapter{
  50. public void mouseClicked(MouseEvent x){
  51. text.setText("you Clicked the mouse");
  52. }
  53. public void mousePressed(MouseEvent x){
  54. text.setText("you are pressing the mouse");
  55. }
  56. //not working
  57. public void mouseRealesed (final MouseEvent x){
  58. text.setText("you Realesed the mouse");
  59. }
  60. public void mouseDragged(MouseEvent x){
  61. text.setText("you Dragging the mouse the mouse");
  62. }
  63. public void mouseMoved(MouseEvent x){
  64. text.setText("you are moving the mouse");
  65. }
  66. }
  67. private class pargo implements ActionListener{
  68. public void actionPerformed(ActionEvent event){
  69.  
  70. }
  71. }
  72. private class button implements ActionListener{
  73. public void actionPerformed(ActionEvent event){
  74. if(SUP[1].isSelected()){JOptionPane.showMessageDialog(null,"hello");}else
  75. if(SUP[0].isSelected()){JOptionPane.showMessageDialog(null,"hey sir");}else
  76. if(SUP[2].isSelected()){}else
  77. if(SUP[3].isSelected()){}else
  78. if(SUP[4].isSelected()){}else
  79. if(SUP[5].isSelected()){}else
  80. if(SUP[6].isSelected()){}else
  81. if(SUP[1].isSelected()){}
  82.  
  83.  
  84.  
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement