Exemplo n.º 1
0
  void jbInit() throws Exception {
    panel1.setLayout(borderLayout1);
    panel2.setBackground(Color.yellow);
    panel2.setLayout(borderLayout2);
    ButtonOK.setLabel("OK");
    ButtonOK.addMouseListener(
        new java.awt.event.MouseAdapter() {

          public void mouseClicked(MouseEvent e) {
            ButtonOK_mouseClicked(e);
          }
        });

    String s1 = CallingApp.MotherApplet.GetName();

    textArea1.setBackground(SystemColor.control);
    textArea1.setEditable(false);

    panel1.add(panel2, BorderLayout.CENTER);
    panel2.add(textArea1, BorderLayout.CENTER);
    panel1.add(panel3, BorderLayout.SOUTH);
    panel3.add(ButtonOK, null);
    String s =
        s1
            + " v:"
            + CallingApp.MotherApplet.GetVersionNum()
            + "\n"
            + CallingApp.MotherApplet.GetInfos();
    textArea1.setText(s);
  }
Exemplo n.º 2
0
 public void adjustmentValueChanged(AdjustmentEvent e) {
   Object ob = e.getSource();
   int p, q, r;
   p = s1.getValue();
   q = s2.getValue();
   r = s3.getValue();
   Color c = new Color(p, q, r);
   p1.setBackground(c);
 }
Exemplo n.º 3
0
  /** Constructor. */
  private HeaderPanel() {
    setBackground(BACKGROUND_COLOR);
    setLayout(cardLayout);

    add(functionCard, FUNCTION);
    add(messageCard, MESSAGE);

    functionCard.setBackground(BACKGROUND_COLOR);
    functionCard.setLayout(new BorderLayout());

    messageCard.setBackground(BACKGROUND_COLOR);
    messageCard.setLayout(new BorderLayout());

    label.setFont(new Font("Dialog", Font.BOLD, 12));
    label.setAlignment(Label.CENTER);
    label.setForeground(Color.black);

    messageCard.add(label, BorderLayout.CENTER);
  }
Exemplo n.º 4
0
  public static void main(String[] args) {
    FrameWithPanel fwp = new FrameWithPanel("This is a Panel Test");
    fwp.setLayout(null);

    Panel p = new Panel();
    p.setSize(200, 150);
    p.setBackground(Color.yellow);

    fwp.add(p); // 프레임에  패널 추가
    fwp.setSize(400, 300);
    fwp.setBackground(Color.cyan);
    fwp.setVisible(true);
  }
Exemplo n.º 5
0
  public TheWorld() throws HeadlessException {
    super("This is the world, and God syas ...");
    p = new Panel();
    p.setBackground(Color.black);

    add(p);
    btnLand = new LetThereBeLandCommand("Let there be land", p);
    btnLight = new LetThereBeLightCommand("Let there be light", p);
    p.add(btnLand);
    p.add(btnLight);
    btnLight.addActionListener(this);
    btnLand.addActionListener(this);
    setBounds(100, 100, 400, 200);
    setVisible(true);
  }
Exemplo n.º 6
0
  public void updateColor(Color c, Object source) {
    // record colour for the object
    rgb = c.getRGB();

    if (source != red && source != green && source != blue) {
      red.setIntValue((rgb & 0xff0000) >> 16);
      green.setIntValue((rgb & 0xff00) >> 8);
      blue.setIntValue((rgb & 0xff));

      hexText.setText("0x" + String.format("%06x", rgb & 0xffffff));
    }

    colorSample.setBackground(c);
    colorSample.repaint();
  }
  /**
   * I Layout sono 3 intanto Layout esterno: è di tipo Border e ordina banner a nord e tastiera a
   * sud Layout del banner: è di tipo Border e ordina messaggio e casella di testo Layout tastiera:
   * è ovviamente una grid.
   */
  public void init() { // DICHIARO GLI OGGETTI DELLA APPLET, DEI PANNELLI. LI AGGIUNGO A QUESTA

    setLayout(new BorderLayout());

    Panel banner = new Panel();
    banner.setLayout(new BorderLayout());
    banner.setBackground(Color.RED);

    Label titolo = new Label("benvenuto in pCalc");
    banner.add(titolo, BorderLayout.NORTH);

    TextField risultato = new TextField(30);
    banner.add(risultato, BorderLayout.SOUTH);

    Panel tastiera = new Panel();
    tastiera.setLayout(new GridLayout(3, 3));

    Button tasto0 = new Button("0");
    tastiera.add(tasto0);
    Button tasto1 = new Button("1");
    tastiera.add(tasto1);
    Button tasto2 = new Button("2");
    tastiera.add(tasto2);
    Button tasto3 = new Button("3");
    tastiera.add(tasto3);
    Button tasto4 = new Button("4");
    tastiera.add(tasto4);
    Button tasto5 = new Button("5");
    tastiera.add(tasto5);
    Button tasto6 = new Button("6");
    tastiera.add(tasto6);
    Button tasto7 = new Button("7");
    tastiera.add(tasto7);
    Button tasto8 = new Button("8");
    tastiera.add(tasto8);
    Button tasto9 = new Button("9");
    tastiera.add(tasto9);

    add(banner, BorderLayout.NORTH);
    add(tastiera, BorderLayout.SOUTH);
  }
Exemplo n.º 8
0
  public TheWorld() {
    super("This is the world, and God says...");

    p = new Panel();
    p.setBackground(Color.black);

    add(p);
    btnLight = new LetThereBeLightCommand("Let there be light", p);
    btnLand = new LetThereBeLandCommand("Let there be land", p);
    btnReset = new ResetCommand("Reset", p);
    btnExit = new GodRestsCommand("God rests");

    p.add(btnLight);
    p.add(btnLand);
    p.add(btnReset);
    p.add(btnExit);

    btnLight.addActionListener(this);
    btnLand.addActionListener(this);
    btnReset.addActionListener(this);
    btnExit.addActionListener(this);
    setBounds(100, 100, 400, 200);
    setVisible(true);
  }
Exemplo n.º 9
0
  public void init() {
    try {
      robot = new Robot();
    } catch (AWTException ex) {
      ex.printStackTrace();
      throw new RuntimeException(ex);
    }
    this.setLayout(new BorderLayout());

    target.setBackground(Color.green);
    target.setName("GreenBox"); // for the ease of debug
    target.setPreferredSize(new Dimension(100, 100));
    String toolkit = Toolkit.getDefaultToolkit().getClass().getName();

    // on X systems two buttons are reserved for wheel though they are countable by MouseInfo.
    int buttonsNumber =
        toolkit.equals("sun.awt.windows.WToolkit")
            ? MouseInfo.getNumberOfButtons()
            : MouseInfo.getNumberOfButtons() - 2;

    for (int i = 0; i < 8; i++) {
      buttonNumber.add("BUTTON" + (i + 1) + "_MASK");
    }

    pressOn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.out.println("Now pressing : " + (buttonNumber.getSelectedIndex() + 1));

            Timer timer = new Timer();
            TimerTask robotInteraction =
                new TimerTask() {
                  public void run() {
                    robot.mouseMove(updateTargetLocation().x, updateTargetLocation().y);
                    robot.mousePress(getMask(buttonNumber.getSelectedIndex() + 1));
                  }
                };
            timer.schedule(robotInteraction, SEND_DELAY);
          }
        });

    releaseOn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.out.println("Now releasing : " + (buttonNumber.getSelectedIndex() + 1));
            Timer timer = new Timer();
            TimerTask robotInteraction =
                new TimerTask() {
                  public void run() {
                    robot.mouseMove(updateTargetLocation().x, updateTargetLocation().y);
                    robot.mouseRelease(getMask(buttonNumber.getSelectedIndex() + 1));
                  }
                };
            timer.schedule(robotInteraction, SEND_DELAY);
          }
        });

    clickOn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.out.println("Now clicking : " + (buttonNumber.getSelectedIndex() + 1));
            Timer timer = new Timer();
            TimerTask robotInteraction =
                new TimerTask() {
                  public void run() {
                    robot.mouseMove(updateTargetLocation().x, updateTargetLocation().y);
                    robot.mousePress(getMask(buttonNumber.getSelectedIndex() + 1));
                    robot.mouseRelease(getMask(buttonNumber.getSelectedIndex() + 1));
                  }
                };
            timer.schedule(robotInteraction, SEND_DELAY);
          }
        });
    target.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            Sysout.println("" + e);
          }

          public void mouseReleased(MouseEvent e) {
            Sysout.println("" + e);
          }

          public void mouseClicked(MouseEvent e) {
            Sysout.println("" + e);
          }
        });

    String[] instructions = {
      "Do provide an instruction to the robot by",
      "choosing the button number to act and ",
      "pressing appropriate java.awt.Button on the left.",
      "Inspect an output in the TextArea below.",
      "Please don't generate non-natural sequences like Release-Release, etc.",
      "If you use keyboard be sure that you released the keyboard shortly.",
      "If events are generated well press Pass, otherwise Fail."
    };
    Sysout.createDialogWithInstructions(instructions);
  } // End  init()
Exemplo n.º 10
0
  /**
   * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is
   * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ.
   */
  public ImageJ(java.applet.Applet applet, int mode) {
    super("ImageJ");
    if ((mode & DEBUG) != 0) IJ.setDebugMode(true);
    mode = mode & 255;
    if (IJ.debugMode) IJ.log("ImageJ starting in debug mode: " + mode);
    embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW);
    this.applet = applet;
    String err1 = Prefs.load(this, applet);
    setBackground(backgroundColor);
    Menus m = new Menus(this, applet);
    String err2 = m.addMenuBar();
    m.installPopupMenu(this);
    setLayout(new BorderLayout());

    // Tool bar
    toolbar = new Toolbar();
    toolbar.addKeyListener(this);
    add("Center", toolbar);

    // Status bar
    statusBar = new Panel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setForeground(Color.black);
    statusBar.setBackground(backgroundColor);
    statusLine = new JLabel();
    statusLine.setFont(new Font("SansSerif", Font.PLAIN, 13));
    statusLine.addKeyListener(this);
    statusLine.addMouseListener(this);
    statusBar.add("Center", statusLine);
    progressBar = new ProgressBar(120, 20);
    progressBar.addKeyListener(this);
    progressBar.addMouseListener(this);
    statusBar.add("East", progressBar);
    add("South", statusBar);

    IJ.init(this, applet);
    addKeyListener(this);
    addWindowListener(this);
    setFocusTraversalKeysEnabled(false);
    m.installStartupMacroSet(); // add custom tools
    runStartupMacro();

    Point loc = getPreferredLocation();
    Dimension tbSize = toolbar.getPreferredSize();
    setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug
    if (mode != NO_SHOW) {
      if (IJ.isWindows())
        try {
          setIcon();
        } catch (Exception e) {
        }
      setLocation(loc.x, loc.y);
      setResizable(!IJ.isMacOSX());
      pack();
      setVisible(true);
    }
    if (err1 != null) IJ.error(err1);
    if (err2 != null) {
      IJ.error(err2);
      IJ.runPlugIn("ij.plugin.ClassChecker", "");
    }
    if (IJ.isMacintosh() && applet == null) {
      Object qh = null;
      qh = IJ.runPlugIn("MacAdapter", "");
      if (qh == null) IJ.runPlugIn("QuitHandler", "");
    }
    if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", "");
    String str = m.getMacroCount() == 1 ? " macro" : " macros";
    IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str);
    configureProxy();
    if (applet == null) loadCursors();
  }
Exemplo n.º 11
0
  /**
   * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is
   * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ.
   */
  public ImageJ(java.applet.Applet applet, int mode) {
    super("ImageJ");
    embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW);
    this.applet = applet;
    String err1 = Prefs.load(this, applet);
    if (IJ.isLinux()) {
      backgroundColor = new Color(240, 240, 240);
      setBackground(backgroundColor);
    }
    Menus m = new Menus(this, applet);
    String err2 = m.addMenuBar();
    m.installPopupMenu(this);
    setLayout(new GridLayout(2, 1));

    // Tool bar
    toolbar = new Toolbar();
    toolbar.addKeyListener(this);
    add(toolbar);

    // Status bar
    statusBar = new Panel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setForeground(Color.black);
    statusBar.setBackground(backgroundColor);
    statusLine = new Label();
    statusLine.setFont(SansSerif12);
    statusLine.addKeyListener(this);
    statusLine.addMouseListener(this);
    statusBar.add("Center", statusLine);
    progressBar = new ProgressBar(120, 20);
    progressBar.addKeyListener(this);
    progressBar.addMouseListener(this);
    statusBar.add("East", progressBar);
    statusBar.setSize(toolbar.getPreferredSize());
    add(statusBar);

    IJ.init(this, applet);
    addKeyListener(this);
    addWindowListener(this);
    setFocusTraversalKeysEnabled(false);

    Point loc = getPreferredLocation();
    Dimension tbSize = toolbar.getPreferredSize();
    int ijWidth = tbSize.width + 10;
    int ijHeight = 100;
    setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug
    if (mode != NO_SHOW) {
      if (IJ.isWindows())
        try {
          setIcon();
        } catch (Exception e) {
        }
      setBounds(loc.x, loc.y, ijWidth, ijHeight); // needed for pack to work
      setLocation(loc.x, loc.y);
      pack();
      setResizable(!(IJ.isMacintosh() || IJ.isWindows())); // make resizable on Linux
      show();
    }
    if (err1 != null) IJ.error(err1);
    if (err2 != null) {
      IJ.error(err2);
      IJ.runPlugIn("ij.plugin.ClassChecker", "");
    }
    m.installStartupMacroSet();
    if (IJ.isMacintosh() && applet == null) {
      Object qh = null;
      qh = IJ.runPlugIn("MacAdapter", "");
      if (qh == null) IJ.runPlugIn("QuitHandler", "");
    }
    if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", "");
    String str = m.getMacroCount() == 1 ? " macro" : " macros";
    IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str);
    // if (applet==null && !embedded && Prefs.runSocketListener)
    //	new SocketListener();
    configureProxy();
    if (applet == null) loadCursors();
  }
Exemplo n.º 12
0
  public void init() {
    sounds = new TetrisSound();
    installNewPiece();

    pause_resume_butt.setEnabled(false);
    start_newgame_butt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            if (start_newgame_butt.getLabel().equals("Start")) startGame();
            else newGame();
          }
        });
    pause_resume_butt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            if (pause_resume_butt.getLabel().equals("Pause")) pauseGame();
            else resumeGame();
          }
        });

    KeyListener key_listener =
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (timer.isPaused()) return;
            if (e.getKeyCode() == 37 || e.getKeyCode() == 39) {
              int dir = e.getKeyCode() == 37 ? -1 : 1;
              synchronized (timer) {
                cur_piece.cut();
                cur_piece.setX(cur_piece.getX() + dir);
                if (!cur_piece.canPaste()) cur_piece.setX(cur_piece.getX() - dir);
                cur_piece.paste();
              }
              game_grid.repaint();
            } else if (e.getKeyCode() == 38) {
              synchronized (timer) {
                cur_piece.cut();
                cur_piece.rotate();
                if (!cur_piece.canPaste()) cur_piece.rotateBack();
                cur_piece.paste();
              }
              game_grid.repaint();
            }
            if (e.getKeyCode() == 40) {
              timer.setFast(true);
            }
          }
        };

    start_newgame_butt.addKeyListener(key_listener);
    pause_resume_butt.addKeyListener(key_listener);

    Panel right_panel = new Panel(new GridLayout(3, 1));
    right_panel.setBackground(BACKGROUND_COLOR);

    Panel control_panel = new Panel();
    control_panel.add(start_newgame_butt);
    control_panel.add(pause_resume_butt);
    control_panel.setBackground(BACKGROUND_COLOR);
    right_panel.add(control_panel);

    Panel tmp = new Panel(new BorderLayout());
    tmp.add("North", new TetrisLabel("    Next Piece:"));
    tmp.add("Center", next_piece_canvas);
    tmp.setBackground(BACKGROUND_COLOR);
    right_panel.add(tmp);

    Panel stats_panel = new Panel(new GridLayout(4, 2));
    stats_panel.add(new TetrisLabel("    Rows Deleted: "));
    stats_panel.add(rows_deleted_label);
    stats_panel.add(new TetrisLabel("    Level: "));
    stats_panel.add(level_label);
    stats_panel.add(new TetrisLabel("    Score: "));
    stats_panel.add(score_label);
    stats_panel.add(new TetrisLabel("    High Score: "));
    stats_panel.add(high_score_label);
    tmp = new Panel(new BorderLayout());
    tmp.setBackground(BACKGROUND_COLOR);
    tmp.add("Center", stats_panel);
    right_panel.add(tmp);

    this.setLayout(new GridLayout(1, 2));
    this.add(game_grid);
    this.add(right_panel);
    this.setBackground(BACKGROUND_COLOR);
    this.validate();
  }
 public void Execute() {
   p.setBackground(Color.black);
 }
Exemplo n.º 14
0
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    Panel = new javax.swing.JPanel();
    LabelCAS = new javax.swing.JLabel();
    BookingButton = new javax.swing.JLabel();
    PerawatanButton = new javax.swing.JLabel();
    CatatDataButton = new javax.swing.JLabel();
    StatistikButton = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Class Administration System");
    setName("MainFrame"); // NOI18N
    setResizable(false);

    Panel.setBackground(new java.awt.Color(136, 201, 162));

    LabelCAS.setFont(new java.awt.Font("Georgia", 0, 70)); // NOI18N
    LabelCAS.setForeground(new java.awt.Color(255, 255, 255));
    LabelCAS.setText("Class Administration System");

    BookingButton.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Image/Button1.png"))); // NOI18N
    BookingButton.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            BookingButtonMouseClicked(evt);
          }
        });

    PerawatanButton.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Image/Button2.png"))); // NOI18N
    PerawatanButton.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            PerawatanButtonMouseClicked(evt);
          }
        });

    CatatDataButton.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Image/Button3.png"))); // NOI18N
    CatatDataButton.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            CatatDataButtonMouseClicked(evt);
          }
        });

    StatistikButton.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/Image/Button4.png"))); // NOI18N
    StatistikButton.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            StatistikButtonMouseClicked(evt);
          }
        });

    javax.swing.GroupLayout PanelLayout = new javax.swing.GroupLayout(Panel);
    Panel.setLayout(PanelLayout);
    PanelLayout.setHorizontalGroup(
        PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                PanelLayout.createSequentialGroup()
                    .addGroup(
                        PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                PanelLayout.createSequentialGroup()
                                    .addGap(233, 233, 233)
                                    .addComponent(LabelCAS))
                            .addGroup(
                                PanelLayout.createSequentialGroup()
                                    .addGap(146, 146, 146)
                                    .addGroup(
                                        PanelLayout.createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(BookingButton)
                                            .addComponent(CatatDataButton))
                                    .addGap(26, 26, 26)
                                    .addGroup(
                                        PanelLayout.createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(StatistikButton)
                                            .addComponent(PerawatanButton))))
                    .addGap(146, 146, 146)));
    PanelLayout.setVerticalGroup(
        PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                PanelLayout.createSequentialGroup()
                    .addGap(45, 45, 45)
                    .addComponent(LabelCAS)
                    .addGap(55, 55, 55)
                    .addGroup(
                        PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(BookingButton)
                            .addComponent(PerawatanButton))
                    .addGap(28, 28, 28)
                    .addGroup(
                        PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(CatatDataButton)
                            .addComponent(StatistikButton))
                    .addContainerGap(35, Short.MAX_VALUE)));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(
                        Panel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(
                        Panel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)));

    pack();
  } // </editor-fold>//GEN-END:initComponents