Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package graphicsNEw;
- //1.set Panel-yes\ 2.set Default text-yes\set Buttons-not yet
- import java.awt.*;
- import javax.swing.*;
- import javax.swing.event.*;
- import java.awt.event.*;
- import java.util.*;
- public class tzayar extends JFrame {
- static
- JButton[] SUP=new JButton[7];
- JPanel panel;
- JLabel picture,text;
- Color color=(Color.WHITE);
- String[] buttons ={"backG","line","squereF","squereNF","textWC","textNC","Circle","rect3D"};
- JButton but[]=new JButton[7];
- public tzayar(){
- super ("Tzayar");
- setLayout(new FlowLayout());
- panel = new JPanel ();
- panel.setBackground(color);
- panel.setPreferredSize(new Dimension(350,350));
- add(panel);
- picture = new JLabel();
- picture.setIcon(new ImageIcon(getClass().getResource("PaintSmall.png")));
- add(picture,BorderLayout.NORTH);
- text = new JLabel("Default");
- add(text,BorderLayout.SOUTH);
- for(int counter=0;counter<SUP.length;counter++){
- SUP[counter] = new JButton(buttons[counter]);
- add(SUP[counter]);
- }
- handler han = new handler();
- panel.addMouseMotionListener(han);
- panel.addMouseListener(han);
- }
- //class for changing text-MouseEvent
- private class handler extends MouseAdapter{
- public void mouseClicked(MouseEvent x){
- text.setText("you Clicked the mouse");
- }
- public void mousePressed(MouseEvent x){
- text.setText("you are pressing the mouse");
- }
- //not working
- public void mouseRealesed (final MouseEvent x){
- text.setText("you Realesed the mouse");
- }
- public void mouseDragged(MouseEvent x){
- text.setText("you Dragging the mouse the mouse");
- }
- public void mouseMoved(MouseEvent x){
- text.setText("you are moving the mouse");
- }
- }
- private class pargo implements ActionListener{
- public void actionPerformed(ActionEvent event){
- }
- }
- private class button implements ActionListener{
- public void actionPerformed(ActionEvent event){
- if(SUP[1].isSelected()){JOptionPane.showMessageDialog(null,"hello");}else
- if(SUP[0].isSelected()){JOptionPane.showMessageDialog(null,"hey sir");}else
- if(SUP[2].isSelected()){}else
- if(SUP[3].isSelected()){}else
- if(SUP[4].isSelected()){}else
- if(SUP[5].isSelected()){}else
- if(SUP[6].isSelected()){}else
- if(SUP[1].isSelected()){}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement