Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 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. for(int counter=0;counter<SUP.length;counter++){
  34. SUP[counter] = new JButton(buttons[counter]);
  35. add(SUP[counter]);
  36. }
  37.  
  38.  
  39. handler han = new handler();
  40. panel.addMouseMotionListener(han);
  41. panel.addMouseListener(han);
  42.  
  43. }
  44. //class for changing text-MouseEvent
  45. private class handler extends MouseAdapter{
  46. public void mouseClicked(MouseEvent x){
  47. text.setText("you Clicked the mouse");
  48. }
  49. public void mousePressed(MouseEvent x){
  50. text.setText("you are pressing the mouse");
  51. }
  52. //not working
  53. public void mouseRealesed (final MouseEvent x){
  54. text.setText("you Realesed the mouse");
  55. }
  56. public void mouseDragged(MouseEvent x){
  57. text.setText("you Dragging the mouse the mouse");
  58. }
  59. public void mouseMoved(MouseEvent x){
  60. text.setText("you are moving the mouse");
  61. }
  62. }
  63. private class pargo implements ActionListener{
  64. public void actionPerformed(ActionEvent event){
  65.  
  66. }
  67. }
  68. private class button implements ActionListener{
  69. public void actionPerformed(ActionEvent event){
  70. if(SUP[1].isSelected()){JOptionPane.showMessageDialog(null,"hello");}else
  71. if(SUP[0].isSelected()){JOptionPane.showMessageDialog(null,"hey sir");}else
  72. if(SUP[2].isSelected()){}else
  73. if(SUP[3].isSelected()){}else
  74. if(SUP[4].isSelected()){}else
  75. if(SUP[5].isSelected()){}else
  76. if(SUP[6].isSelected()){}else
  77. if(SUP[1].isSelected()){}
  78.  
  79.  
  80.  
  81. }
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement