Esempio n. 1
0
 @Override
 public Component getListCellRendererComponent(
     JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) {
   label.setText(Objects.toString(value, ""));
   this.list = list;
   this.index = index;
   if (isSelected) {
     setBackground(list.getSelectionBackground());
     label.setForeground(list.getSelectionForeground());
   } else {
     setBackground(index % 2 == 0 ? EVEN_COLOR : list.getBackground());
     label.setForeground(list.getForeground());
   }
   MutableComboBoxModel m = (MutableComboBoxModel) list.getModel();
   if (index < 0 || m.getSize() - 1 <= 0) {
     setOpaque(false);
     deleteButton.setVisible(false);
     label.setForeground(list.getForeground());
   } else {
     boolean f = index == rolloverIndex;
     setOpaque(true);
     deleteButton.setVisible(true);
     deleteButton.getModel().setRollover(f);
     deleteButton.setForeground(f ? Color.WHITE : list.getForeground());
   }
   return this;
 }
Esempio n. 2
0
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==b)
		{
			temp=tf.getText();
			temp1[]=ta.getText().split();
			index=0;
			index=temp1[].indexOf(temp,index);
			ta.select(index, index+temp.length());
			b.setVisible(false);
			b1.setVisible(true);
		}
		if(e.getSource()==b1)
		{
			index=temp1.indexOf(temp,index+temp.length());
			if(index!=-1)
			{
				ta.requestFocusInWindow();
				ta.select(index, index+temp.length());
			}
			else
			{
				b.setVisible(true);
				b1.setVisible(false);
				index=0;
			}
		}
	}	
  /**
   * This function takes the given customer or waiter object and changes the information panel to
   * hold that person's info.
   *
   * @param person customer or waiter object
   */
  public void updateInfoPanel(Object person) {
    stateCB.setVisible(true);
    changeOrder.setVisible(false);
    currentPerson = person;

    if (person instanceof CustomerAgent) {
      CustomerAgent customer = (CustomerAgent) person;
      stateCB.setText("Hungry?");
      changeOrder.setVisible(true);
      // changeOrder.setText("Change Order?");
      // changeOrder.setSelected(customer.waiter.requestingChange(customer));
      // changeOrder.setEnabled(!customer.waiter.requestingChange(customer));
      stateCB.setSelected(customer.isHungry());
      stateCB.setEnabled(!customer.isHungry());
      infoLabel.setText("<html><pre>     Name: " + customer.getName() + " </pre></html>");

    } else if (person instanceof WaiterAgent) {
      WaiterAgent waiter = (WaiterAgent) person;
      // stateCB.setText("On Break?");
      // stateCB.setSelected(waiter.isOnBreak());
      // stateCB.setEnabled(true);
      requestBreak.setVisible(true);
      stateCB.setVisible(false);
      changeOrder.setVisible(false);
      infoLabel.setText("<html><pre>     Name: " + waiter.getName() + " </html>");
    }

    infoPanel.validate();
  }
  public void stop() {
    started = false;
    runner = null;

    startBtn.setText("Start");
    writeBtn.setVisible(true);
    paramsBtn.setVisible(true);
  }
 public void setPlayerControlsVisible(boolean b) {
   boolean oldValue = forwardButton.isVisible();
   if (oldValue != b) {
     forwardButton.setVisible(b);
     rewindButton.setVisible(b);
     startButton.setVisible(b);
     slider.setVisible(b);
     spacer.setVisible(!b);
     revalidate();
   }
 }
Esempio n. 6
0
 @Override
 public void valueChanged(ListSelectionEvent lsEve) {
   int rowNum = table.getSelectedRow();
   int colNum = table.getSelectedColumn();
   //            System.out.println("Reached in else");
   if (colNum > 0) {
     selectAllCB.setVisible(false);
     deleteBut.setVisible(false);
     new MessagePan(rowNum, workingSet);
     backBut.setVisible(true);
     Home.home.homeFrame.setVisible(true);
   }
 }
Esempio n. 7
0
 @Override
 public void mouseClicked(MouseEvent e) {
   ArrayList list = getSelectedMessages();
   if (list.size() == 0) {
     deleteBut.setVisible(false);
     restoreBut.setVisible(false);
   } else {
     deleteBut.setVisible(true);
     if (Home.titlePan.getTitle().equals("Trash")) {
       restoreBut.setVisible(true);
       System.out.println("Here inside");
     }
   }
 }
Esempio n. 8
0
  public void run() {
    for (int j = 0; j < 20; j++) butI[j].removeActionListener(this);

    Wait.manySec(10);
    if (but.getIcon() == butn.getIcon()) {
      but.setVisible(false);
      butn.setVisible(false);
    } else {
      but.setIcon(iconOrg);
      butn.setIcon(iconOrg);
    }

    isVisibl();
    for (int j = 0; j < 20; j++) butI[j].addActionListener(this);
  }
 public void start() {
   // initialise();
   lastDrawn = 0;
   savedd = new int[maxRun];
   saveddsq = new int[maxRun];
   dCount = new int[gSize];
   ;
   started = true;
   if (runner == null) {
     runner = new Thread(this);
   }
   runner.start(); // not the same as this method!
   startBtn.setText("Stop");
   writeBtn.setVisible(false);
   paramsBtn.setVisible(false);
 }
Esempio n. 10
0
 public EnhancedLockableUI(LayerEffect... lockedEffects) {
   super(lockedEffects);
   unlockButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           setLocked(false);
         }
       });
   unlockButton.setVisible(false);
 }
Esempio n. 11
0
  void isVisibl() {
    int cnt = 0;
    boolean vis;

    for (int j = 0; j < 20; j++) {
      vis = butI[j].isVisible();
      if (!vis) cnt++;
    }

    if (cnt == 20) {
      score();
      DigitalClock.flag = false;
      lblCongrt.setVisible(true);
      lblCongrt.setText("Congratulations you Scored : " + score + " marks");
      lblContestant.setVisible(true);
      lblContestant.setText("Contestant Name : " + name);
      butnPlayAgn.setVisible(true);
      butnQuit.setVisible(true);
    }
  }
Esempio n. 12
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == easy) {
      invSpeed = 50000;
      bombN = 1;
      timeDifficulty1 = 1000;
      distanceLimit = 400;
      monsterMultiplier = 1;
      multiplier = 1;
      setup();
    } else if (e.getSource() == hard) {
      invSpeed = 30000;
      bombN = 4;
      timeDifficulty1 = 500;
      distanceLimit = 200;
      monsterMultiplier = 2;
      multiplier = 2;
      setup();
    } else if (e.getSource() == back) {
      r = null;
      menu.setVisible(true);
      back.setVisible(false);
      this.revalidate();
      repaint();
    } else if (e.getSource() == howTo) {
      menu.removeAll();

      menu.add(howToBack);
      menu.add(howToIMGL);

      menu.revalidate();
      menu.repaint();
    } else if (e.getSource() == howToBack) {
      menu.remove(howToIMGL);
      menu.remove(howToBack);

      menu.add(keyboardSpeedL1);
      menu.add(keyboardSpeedL2);
      menu.add(easy);
      menu.add(hard);
      menu.add(howTo);
      menu.add(onePlayerRB);
      menu.add(twoPlayerRB);
      menu.add(mouseRB);
      menu.add(keyboardRB);
      menu.add(keyboardSpeedS1);
      menu.add(keyboardSpeedS2);
      menu.add(musicCB);
      menu.add(highscoreL);
      menu.add(menuIMGL);

      menu.revalidate();
      menu.repaint();
    }
  }
Esempio n. 13
0
  /**
   * Builds the components from the file and displays it.
   *
   * @param strFile the file to be read.
   */
  public void build(int nType, String strFile, String strhelpfile) {
    m_nType = nType;
    m_strPath = (strFile != null) ? FileUtil.openPath(strFile) : "";
    m_strHelpFile = strhelpfile;
    boolean bValidate = false;
    boolean bChecksum = false;

    if (nType == CONFIG) {
      setTitle("Configuration");
      buildConfig();
    } else {
      JComponent compDisplay = null;
      if (nType == DEFAULT) {
        m_pnlAccPolicy = new AccPolicyPanel(m_strPath);
        compDisplay = m_pnlAccPolicy;
        setTitle("Password Configuration");
      } else if (nType == CHECKSUM) {
        m_pnlChecksum = new ChecksumPanel(m_strPath);
        compDisplay = m_pnlChecksum;
        setTitle("Checksum Configuration");
        bValidate = true;
        bChecksum = true;
      } else {
        setTitle("Perform System Validation");
        compDisplay = new JTextArea();
        ((JTextArea) compDisplay).setEditable(false);
        bValidate = true;
        doBlink();
      }
      m_pnlDisplay.removeAll();
      m_pnlDisplay.setLayout(new BorderLayout());
      m_pnlDisplay.add(compDisplay, BorderLayout.CENTER);
      setVisible(true);
    }
    validateButton.setVisible(bValidate);
    // abandonButton.setVisible(!bValidate);
    setAbandonEnabled(bValidate);
    m_btnChecksum.setVisible(bChecksum);
  }
Esempio n. 14
0
  public Splitter() {
    super(new BorderLayout());

    // Create the demo's UI.
    startButton = new JButton("Start");
    startButton.setActionCommand("start");
    startButton.addActionListener(this);
    startButton.setVisible(false);

    taskOutput = new JTextArea(30, 130);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);

    JPanel panel = new JPanel();
    panel.add(startButton);

    add(panel, BorderLayout.PAGE_START);
    add(new JScrollPane(taskOutput), BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    startButton.doClick();
  }
Esempio n. 15
0
	Swing4(String s)
	{
		f=new JFrame(s);
		
		ta=new JTextArea();
		ta.setBounds(50,50,400,200);
		f.add(ta);
		
		tf=new JTextField();
		tf.setBounds(50,300,100,50);
		f.add(tf);
		
		b=new JButton("FIND");
		b.setBounds(200,300,100,50);
		b.addActionListener(this);
		f.add(b);
		
		b1=new JButton("NEXT");
		b1.setBounds(350,300,100,50);
		b1.addActionListener(this);
		b1.setVisible(false);
		f.add(b1);
		
		tf1=new JTextField();
		tf1.setBounds(50,400,100,50);
		f.add(tf1);
		
		b2=new JButton("REPLACE");
		b2.setBounds(200,400,100,50);
		b2.addActionListener(this);
		f.add(b2);
		
		f.setLayout(null);
		f.setSize(500,500);
		f.setVisible(true);
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
Esempio n. 16
0
 public void setHelpEnabled(boolean b) {
   helpButton.setEnabled(b);
   helpButton.setVisible(b);
   enableControlPanel();
 }
Esempio n. 17
0
 public void setCloseEnabled(boolean b) {
   closeButton.setEnabled(b);
   closeButton.setVisible(b);
   enableControlPanel();
 }
Esempio n. 18
0
  public Fenetre(String titre) {
    super(titre);

    // Gauche de l'application
    jp_gauche = new JPanel();
    String nomJ1 = "Joueur 1";
    // nomJ1 = JOptionPane.showInputDialog("Quel est votre nom de capitaine ?");  //(Chiant)
    nom_J1 = new JLabel(nomJ1);

    // grille J1
    jp_grille1 = new JPanel(new GridLayout(10, 10));
    tabbout1 = new JButton[10][10];
    for (int i = 0; i < 10; i++) // ligne
    {
      for (int j = 0; j < 10; j++) // colonne
      {
        JButton boutton = new JButton(new ImageIcon("src/eau.png"));
        boutton.setMargin(m);
        jp_grille1.add(boutton);
        // boutton.addActionListener(ecouteur);
        tabbout1[i][j] = boutton;
      }
    }

    jp_gauche.add(nom_J1, BorderLayout.NORTH);
    jp_gauche.add(jp_grille1, BorderLayout.CENTER);

    // bas pour le J1
    b_new = new JButton("Nouvelle partie");

    jpg_bas = new JPanel();
    jpg_bas.add(b_new);

    jb_sub = new JButton("Sous-marin");
    jb_avion = new JButton("Porte-avion");
    jb_cuir = new JButton("Cuirrassé");

    this.al_sub =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (nbsub) {
              Partie.demande(submarin, J1);
              majgrid1(J1);
              nbsub = false;
            } else {
              JOptionPane.showMessageDialog(
                  null,
                  "Vous avez déjà placé votre sous-marin",
                  "Erreur 005",
                  JOptionPane.ERROR_MESSAGE);
            }
          }
        };
    this.jb_sub.addActionListener(al_sub);

    this.al_cuir =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (nbcuir) {
              Partie.demande(battleship, J1);
              majgrid1(J1);
              nbcuir = false;
            } else {
              JOptionPane.showMessageDialog(
                  null,
                  "Vous avez déjà placé votre cuirrassé",
                  "Erreur 004",
                  JOptionPane.ERROR_MESSAGE);
            }
          }
        };
    this.jb_cuir.addActionListener(al_cuir);

    this.al_avion =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (nbavion) {
              Partie.demande(aircraft, J1);
              majgrid1(J1);
              nbavion = false;
            } else {
              JOptionPane.showMessageDialog(
                  null,
                  "Vous avez déjà placé votre porte-avion",
                  "Erreur 003",
                  JOptionPane.ERROR_MESSAGE);
            }
          }
        };
    this.jb_avion.addActionListener(al_avion);

    jb_sub.setVisible(false);
    jb_cuir.setVisible(false);
    jb_avion.setVisible(false);

    jpg_bas.add(jb_sub);
    jpg_bas.add(jb_cuir);
    jpg_bas.add(jb_avion);

    jp_gauche.add(jpg_bas, BorderLayout.SOUTH);

    // Droite de l'application
    jp_droite = new JPanel();
    String nomJ2 = "Joueur 2";
    nom_J2 = new JLabel(nomJ2); // Nom du joueur 2 à récupéré sur le serveur
    jp_droite.add(nom_J2);

    // grille J2
    jp_grille2 = new JPanel(new GridLayout(10, 10));
    tabbout2 = new JButton[10][10];
    for (int i = 0; i < 10; i++) // ligne
    {
      for (int j = 0; j < 10; j++) // colonne
      {
        JButton boutton = new JButton(new ImageIcon("src/brouillard.png"));
        boutton.setMargin(m);
        jp_grille2.add(boutton);
        tabbout2[i][j] = boutton;
      }
    }
    jp_droite.add(nom_J2, BorderLayout.NORTH);
    jp_droite.add(jp_grille2, BorderLayout.SOUTH);

    // Mise en page
    this.add(jp_gauche, BorderLayout.WEST);
    this.add(jp_droite, BorderLayout.EAST);

    // bouton b_new commence une partie
    this.al_new =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            jeu = new Partie();
            J1 = new Player();
            jb_sub.setVisible(true);
            jb_cuir.setVisible(true);
            jb_avion.setVisible(true);

            b_new.setVisible(false);

            nbavion = true;
            nbcuir = true;
            nbsub = true;
          }
        };
    this.b_new.addActionListener(al_new);

    // algo
    //        boolean test = true;
    //        while(test){
    //            if( nbavion == false && nbcuir == false && nbsub == false && b_new.isVisible() ==
    // false ) {
    //                System.out.print("OUIIIIIIIII");
    //                while(P1.isDestroyed() || P2.isDestroyed()){
    //                    if(P1 != game.getCurrentEnnemy()){
    //                        String x = JOptionPane.showInputDialog("Sur quel ligne voulez vous
    // tirez ?");
    //                        String y = JOptionPane.showInputDialog("Sur quel collonne voulez vous
    // tirez ?");
    //                        int res = game.fire(Integer.parseInt(x),Integer.parseInt(y));
    //                        //majgrid2(res);
    //                        game.nextTurn();
    //                        }
    //                    else{
    //                        game.waitt();
    //                        game.nextTurn();
    //                    }
    //                }
    //
    //            test = false;
    //            }
    //            else
    //            {
    //                System.out.print("CACA");
    //            }
    // }

  }
Esempio n. 19
0
  /** Creates the GUI. */
  public void majorLayout() {
    //
    // Setup Menu
    //
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu(ResourceHandler.getMessage("menu.file"));
    file.setMnemonic(ResourceHandler.getAcceleratorKey("menu.file"));

    file.add(exitMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.exit")));
    exitMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.exit"));
    exitMenuItem.addActionListener(this);
    menuBar.add(file);

    JMenu edit = new JMenu(ResourceHandler.getMessage("menu.edit"));
    edit.setMnemonic(ResourceHandler.getAcceleratorKey("menu.edit"));

    edit.add(optionMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.option")));
    optionMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.option"));
    optionMenuItem.addActionListener(this);
    menuBar.add(edit);

    JMenu help = new JMenu(ResourceHandler.getMessage("menu.help"));
    help.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(helpMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.help")));
    helpMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(new JSeparator());
    help.add(aboutMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.about")));
    aboutMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.about"));
    helpMenuItem.addActionListener(this);
    aboutMenuItem.addActionListener(this);
    menuBar.add(help);

    setJMenuBar(menuBar);

    //
    // Setup main GUI
    //

    dirLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel0"));
    dirTF = new JTextField();
    dirBttn = new JButton(ResourceHandler.getMessage("button.browse.dir"));
    dirBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.dir"));

    matchingLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel1"));
    matchingTF = new JTextField(ResourceHandler.getMessage("converter_gui.lablel2"));
    recursiveCheckBox = new JCheckBox(ResourceHandler.getMessage("converter_gui.lablel3"));
    recursiveCheckBox.setMnemonic(ResourceHandler.getAcceleratorKey("converter_gui.lablel3"));

    backupLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel5"));
    backupTF = new JTextField();
    backupBttn = new JButton(ResourceHandler.getMessage("button.browse.backup"));
    backupBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.backup"));

    templateLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel7"));
    templateCh = new TemplateFileChoice();

    staticVersioningLabel = new JLabel(ResourceHandler.getMessage("static.versioning.label"));
    String version = System.getProperty("java.version");
    if (version.indexOf("-") > 0) {
      version = version.substring(0, version.indexOf("-"));
    }
    int dotIndex = version.indexOf(".");
    dotIndex = version.indexOf(".", dotIndex + 1);
    String familyVersion = version.substring(0, dotIndex);

    MessageFormat formatter =
        new MessageFormat(ResourceHandler.getMessage("static.versioning.radio.button"));
    staticVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {version}));
    staticVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("static.versioning.radio.button"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.radio.button"));
    dynamicVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {familyVersion}));
    dynamicVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("dynamic.versioning.radio.button"));

    staticVersioningTextArea = new JTextArea(ResourceHandler.getMessage("static.versioning.text"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.text"));
    dynamicVersioningTextArea = new JTextArea(formatter.format(new Object[] {familyVersion}));

    ButtonGroup versioningButtonGroup = new ButtonGroup();
    versioningButtonGroup.add(staticVersioningRadioButton);
    versioningButtonGroup.add(dynamicVersioningRadioButton);

    runBttn = new JButton(ResourceHandler.getMessage("button.convert"));
    runBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.convert"));

    recursiveCheckBox.setOpaque(false);
    staticVersioningRadioButton.setOpaque(false);
    dynamicVersioningRadioButton.setOpaque(false);

    staticVersioningTextArea.setEditable(false);
    staticVersioningTextArea.setLineWrap(true);
    staticVersioningTextArea.setWrapStyleWord(true);
    dynamicVersioningTextArea.setEditable(false);
    dynamicVersioningTextArea.setLineWrap(true);
    dynamicVersioningTextArea.setWrapStyleWord(true);

    staticVersioningPanel.setLayout(new BorderLayout());
    staticVersioningPanel.add(staticVersioningTextArea, "Center");
    staticVersioningPanel.setBorder(new LineBorder(Color.black));

    dynamicVersioningPanel.setLayout(new BorderLayout());
    dynamicVersioningPanel.add(dynamicVersioningTextArea, "Center");
    dynamicVersioningPanel.setBorder(new LineBorder(Color.black));

    if (converter.isStaticVersioning()) {
      staticVersioningRadioButton.setSelected(true);
    } else {
      dynamicVersioningRadioButton.setSelected(true);
    }

    addListeners();

    final int buf = 10, // Buffer (between components and form)
        sp = 10, // Space between components
        vsp = 5, // Vertical space
        indent = 20; // Indent between form (left edge) and component

    GridBagConstraints gbc = new GridBagConstraints();
    GridBagLayout gbl = new GridBagLayout();
    getContentPane().setLayout(gbl);

    //
    // Setup top panel
    //
    GridBagLayout topLayout = new GridBagLayout();
    JPanel topPanel = new JPanel();
    topPanel.setOpaque(false);
    topPanel.setLayout(topLayout);

    topLayout.setConstraints(
        dirLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirTF,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirBttn,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingLabel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingTF,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        recursiveCheckBox,
        new GridBagConstraints(
            2,
            1,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupLabel,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupTF,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupBttn,
        new GridBagConstraints(
            2,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateLabel,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateCh,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep1,
        new GridBagConstraints(
            0,
            5,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 10, 10),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningLabel,
        new GridBagConstraints(
            0,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningRadioButton,
        new GridBagConstraints(
            0,
            7,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningPanel,
        new GridBagConstraints(
            0,
            8,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 10, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningRadioButton,
        new GridBagConstraints(
            0,
            9,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningPanel,
        new GridBagConstraints(
            0,
            10,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep2,
        new GridBagConstraints(
            0,
            11,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 0, 10),
            0,
            0));

    invisibleBttn = new JButton();
    invisibleBttn.setVisible(false);
    topLayout.setConstraints(
        invisibleBttn,
        new GridBagConstraints(
            2,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.CENTER,
            new Insets(indent, sp, 0, 0),
            0,
            0));

    topPanel.add(dirLabel);
    topPanel.add(dirTF);
    topPanel.add(dirBttn);
    topPanel.add(matchingLabel);
    topPanel.add(matchingTF);
    topPanel.add(recursiveCheckBox);
    topPanel.add(backupLabel);
    topPanel.add(backupTF);
    topPanel.add(backupBttn);
    topPanel.add(templateLabel);
    topPanel.add(templateCh);
    topPanel.add(sep1);
    topPanel.add(staticVersioningLabel);
    topPanel.add(staticVersioningRadioButton);
    topPanel.add(staticVersioningPanel);
    topPanel.add(dynamicVersioningRadioButton);
    topPanel.add(dynamicVersioningPanel);
    topPanel.add(sep2);
    topPanel.add(invisibleBttn);

    //
    // Setup bottom panel
    //
    GridBagLayout buttomLayout = new GridBagLayout();
    JPanel buttomPanel = new JPanel();
    buttomPanel.setOpaque(false);
    buttomPanel.setLayout(buttomLayout);

    buttomLayout.setConstraints(
        runBttn,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(sp, 0, 0, 0),
            0,
            0));
    buttomPanel.add(runBttn);

    //
    // Setup main panel
    //
    GridBagLayout mainLayout = new GridBagLayout();
    JPanel mainPanel = new JPanel();

    mainPanel.setOpaque(false);
    mainPanel.setLayout(mainLayout);

    mainLayout.setConstraints(
        topPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(buf, buf, 0, buf),
            0,
            0));
    mainLayout.setConstraints(
        buttomPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1,
            1,
            GridBagConstraints.SOUTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, buf, buf, buf),
            0,
            0));
    mainPanel.add(topPanel);
    mainPanel.add(buttomPanel);

    Border border = BorderFactory.createEtchedBorder();
    mainPanel.setBorder(border);

    GridBagLayout layout = new GridBagLayout();
    getContentPane().setLayout(layout);

    layout.setConstraints(
        mainPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    getContentPane().add(mainPanel);

    pack();
    setResizable(false);
  }
Esempio n. 20
0
 public void setLocked(boolean isLocked) {
   super.setLocked(isLocked);
   unlockButton.setVisible(isLocked);
 }
Esempio n. 21
0
  public void setContent(String cat) {
    cat = cat.trim();
    selectAllCB.setVisible(false);
    selectAllCB.setSelected(false);
    deleteBut.setVisible(false);
    restoreBut.setVisible(false);
    refreshBut.setVisible(true);
    Object columns[] = null;
    int count = 0;
    switch (cat) {
      case "Inbox":
        columns = new Object[] {"", "From", "Date", "Subject", "Content"};
        count = Database.getCount("Inbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc");
        ;
        break;
      case "SentMail":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Sentmail");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc");
        break;
      case "Draft":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Draft");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc");
        break;
      case "Outbox":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Outbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc");
        break;
      case "Trash":
        //                restoreBut.setVisible(true);
        columns = new Object[] {"", "To/From", "Date", "Subject", "Content"};
        count = Database.getCount("Trash");
        workingSet =
            db.getData(
                "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc");
        break;
      default:
        System.out.println("in default case");
    }
    if (count > 0) {
      selectAllCB.setVisible(true);
      rows = new Object[count][];
      msgID = new int[count];
      try {
        workingSet.beforeFirst();
        for (int i = 0; i < count && workingSet.next(); i++) {
          msgID[i] = workingSet.getInt(1);
          rows[i] =
              new Object[] {
                false,
                workingSet.getString(2),
                workingSet.getDate(3),
                workingSet.getString(4),
                workingSet.getString(5)
              };
        }
      } catch (SQLException sqlExc) {
        JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE);
        sqlExc.printStackTrace();
      }

      tableModel = new MyDefaultTableModel(rows, columns);
      table = new JTable(tableModel);
      table.getSelectionModel().addListSelectionListener(this);
      table.addMouseListener(this);
      table.getTableHeader().setOpaque(true);
      table.getTableHeader().setReorderingAllowed(false);
      //            table.getTableHeader().setBackground(Color.blue);
      table.getTableHeader().setForeground(Color.blue);
      //        table.setRowSelectionAllowed(false);
      //            table.setColumnSelectionAllowed(false);
      table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
      table.setRowHeight(20);
      table.setFillsViewportHeight(true);

      TableColumn column = null;
      for (int i = 0; i < 5; i++) {
        column = table.getColumnModel().getColumn(i);
        if (i == 0) {
          column.setPreferredWidth(6);
        } else if (i == 3) {
          column.setPreferredWidth(250);
        } else if (i == 4) {
          column.setPreferredWidth(450);
        } else {
          column.setPreferredWidth(40);
        }
      }
      table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

      remove(contentPan);
      contentPan = new JScrollPane(table);
      contentPan.setBackground(Color.orange);
      contentPan.setOpaque(true);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      Home.home.homeFrame.setVisible(true);
    } else {
      JPanel centPan = new JPanel(new GridBagLayout());
      centPan.setBackground(new Color(52, 86, 70));
      JLabel label = new JLabel("No Messages In This Category");
      label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22));
      label.setForeground(Color.orange);
      centPan.add(label);
      remove(contentPan);
      contentPan = new JScrollPane(centPan);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      contentPan.repaint();
    }
  }
Esempio n. 22
0
  public void createGUI() {
    setLayout(new BorderLayout());
    toolBar = new JToolBar("options", JToolBar.HORIZONTAL);
    toolBar.setFloatable(false);
    toolBar.setOpaque(true);
    toolBar.setBackground(new Color(154, 12, 12));
    toolBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15));
    selectAllCB = new JCheckBox("Select All");
    selectAllCB.setVisible(false);
    selectAllCB.setForeground(Color.white);
    selectAllCB.addActionListener(this);
    refreshBut = new JButton(new ImageIcon(this.getClass().getResource("/images/reloadIcon.png")));
    refreshBut.setVisible(false);
    refreshBut.setToolTipText("Refresh");
    refreshBut.setForeground(new Color(20, 88, 49));
    refreshBut.addActionListener(this);
    backBut = new JButton(new ImageIcon(this.getClass().getResource("/images/backIcon.png")));
    backBut.setVisible(false);
    backBut.setToolTipText("Back");
    backBut.setForeground(new Color(20, 88, 49));
    backBut.addActionListener(this);
    deleteBut = new JButton(new ImageIcon(this.getClass().getResource("/images/trashIcon.png")));
    deleteBut.setToolTipText("Delete");
    deleteBut.setForeground(Color.red);
    deleteBut.setVisible(false);
    deleteBut.addActionListener(this);
    deleteBut.setBackground(Color.red);
    restoreBut = new JButton(new ImageIcon(this.getClass().getResource("/images/restoreIcon.png")));
    restoreBut.setToolTipText("Restore");
    restoreBut.setForeground(Color.blue);
    restoreBut.setVisible(false);
    restoreBut.addActionListener(this);
    toolBar.addSeparator(new Dimension(10, 5));
    toolBar.add(selectAllCB);
    toolBar.add(backBut);
    toolBar.add(refreshBut);
    toolBar.add(deleteBut);
    toolBar.add(restoreBut);
    add(toolBar, "North");
    JPanel centPan = new JPanel(new GridBagLayout());
    centPan.setBackground(new Color(52, 86, 70));
    JLabel label = new JLabel("Select A Category From Left Pane");
    label.setFont(new Font("arial", Font.BOLD, 35));
    label.setForeground(Color.yellow);
    centPan.add(label);
    contentPan = new JScrollPane(centPan);
    contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    add(contentPan, "Center");
    contentPan.repaint();

    db = new Database();
    //        inboxSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id
    // desc");
    //        sentmailSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id
    // desc");
    //        draftSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id
    // desc");
    //        outboxSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id
    // desc");
    //        trashSet = db.getData("SELECT * FROM messages,trash WHERE messages.tag='trash' and
    // messages.msg_id=trash.msg_id ORDER BY deleted_at desc");

  }
Esempio n. 23
0
  private void makeMenuScreen() {
    menu = new JPanel();
    menu.setBackground(Color.BLACK);
    menu.setLayout(null);
    menu.setBounds(0, 0, width, height);

    try {
      BufferedImage menuIMG =
          ImageIO.read(this.getClass().getResource("/Resources/MenuBackground.png"));
      // BufferedImage menuIMG = ImageIO.read(new
      // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/MenuBackground.png"));
      menuIMGL =
          new JLabel(
              new ImageIcon(
                  menuIMG.getScaledInstance(
                      (int) (width * 0.8), (int) (height * 0.8), Image.SCALE_SMOOTH)));
      menuIMGL.setBounds(0, 0, width, height);
    } catch (Exception e) {
    }

    highscoreL = new JLabel(String.valueOf(highscore));
    highscoreL.setBackground(Color.darkGray);
    highscoreL.setBounds((width / 2) + 100, (height / 2) + 70, 500, 100);
    highscoreL.setForeground(Color.white);

    easy = new JButton("Easy");
    hard = new JButton("Hard");

    easy.addActionListener(this);
    hard.addActionListener(this);

    easy.setBounds((width / 2) - 60, (height / 2) - 50, 120, 20);
    hard.setBounds((width / 2) - 60, height / 2 - 10, 120, 20);

    onePlayerRB = new JRadioButton("One Player");
    twoPlayerRB = new JRadioButton("Two Player");
    mouseRB = new JRadioButton("Mouse (Player 1)");
    keyboardRB = new JRadioButton("Keyboard (Player 1)");
    keyboardSpeedS1 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50);
    keyboardSpeedS2 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50);
    musicCB = new JCheckBox("Music");

    onePlayerRB.setBackground(null);
    twoPlayerRB.setBackground(null);
    mouseRB.setBackground(null);
    keyboardRB.setBackground(null);
    keyboardSpeedS1.setBackground(null);
    keyboardSpeedS2.setBackground(null);
    musicCB.setBackground(null);

    onePlayerRB.setForeground(Color.WHITE);
    twoPlayerRB.setForeground(Color.WHITE);
    mouseRB.setForeground(Color.WHITE);
    keyboardRB.setForeground(Color.WHITE);
    keyboardSpeedS1.setForeground(Color.WHITE);
    keyboardSpeedS2.setForeground(Color.WHITE);
    musicCB.setForeground(Color.WHITE);

    ButtonGroup playerChoice = new ButtonGroup();
    playerChoice.add(onePlayerRB);
    playerChoice.add(twoPlayerRB);
    onePlayerRB.setSelected(true);

    ButtonGroup peripheralChoice = new ButtonGroup();
    peripheralChoice.add(mouseRB);
    peripheralChoice.add(keyboardRB);
    mouseRB.setSelected(true);

    musicCB.setSelected(true);

    onePlayerRB.setBounds((width / 2) + 100, (height / 2) - 50, 100, 20);
    twoPlayerRB.setBounds((width / 2) + 100, (height / 2) - 30, 100, 20);
    mouseRB.setBounds((width / 2) + 100, (height / 2), 200, 20);
    keyboardRB.setBounds((width / 2) + 100, (height / 2) + 20, 200, 20);
    keyboardSpeedS1.setBounds(width / 2 - 120, height / 2 + 100, 200, 50);
    keyboardSpeedS2.setBounds(width / 2 - 120, height / 2 + 183, 200, 50);
    musicCB.setBounds((width / 2) + 100, (height / 2) + 50, 100, 20);

    keyboardSpeedL1 = new JLabel("Keyboard Speed (Player One)");
    keyboardSpeedL1.setForeground(Color.WHITE);
    keyboardSpeedL1.setBounds(width / 2 - 113, height / 2 + 67, 200, 50);

    keyboardSpeedL2 = new JLabel("Keyboard Speed (Player Two)");
    keyboardSpeedL2.setForeground(Color.WHITE);
    keyboardSpeedL2.setBounds(width / 2 - 113, height / 2 + 150, 200, 50);

    howTo = new JButton("How To Play");
    howTo.addActionListener(this);
    howTo.setBounds((width / 2) - 60, height / 2 + 30, 120, 20);

    try {
      BufferedImage howToIMG = ImageIO.read(this.getClass().getResource("/Resources/HowTo.png"));
      // BufferedImage howToIMG = ImageIO.read(new
      // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/HowTo.png"));
      howToIMGL = new JLabel(new ImageIcon(howToIMG));
      howToIMGL.setBounds(
          width / 2 - howToIMG.getWidth() / 2,
          height / 2 - howToIMG.getHeight() / 2,
          howToIMG.getWidth(),
          howToIMG.getHeight());
    } catch (Exception e) {
    }

    howToBack = new JButton("X");
    howToBack.setBounds(
        (int) (width / 2 + width * 0.25) - 50, (int) (height / 2 - height * 0.25), 50, 50);
    howToBack.setBackground(Color.BLACK);
    howToBack.setForeground(Color.WHITE);
    howToBack.addActionListener(this);

    menu.add(easy);
    menu.add(hard);
    menu.add(howTo);
    menu.add(highscoreL);
    menu.add(onePlayerRB);
    menu.add(twoPlayerRB);
    menu.add(mouseRB);
    menu.add(keyboardRB);
    menu.add(keyboardSpeedL1);
    menu.add(keyboardSpeedL2);
    menu.add(keyboardSpeedS1);
    menu.add(keyboardSpeedS2);
    menu.add(musicCB);
    menu.add(menuIMGL);

    back = new JButton("Back");
    back.setBounds(width / 2 - 40, height / 2, 100, 20);
    back.addActionListener(this);
    back.setVisible(false);
    this.add(back);
  }
Esempio n. 24
0
  @Override
  public void actionPerformed(ActionEvent axnEve) {
    Object obj = axnEve.getSource();

    if (obj == selectAllCB) {
      Boolean state;
      if (selectAllCB.isSelected()) {
        state = true;
        deleteBut.setVisible(true);
        if (Home.titlePan.getTitle().equals("Trash")) {
          restoreBut.setVisible(true);
        }
      } else {
        state = false;
        deleteBut.setVisible(false);
        if (Home.titlePan.getTitle().equals("Trash")) {
          restoreBut.setVisible(false);
        }
      }
      for (int i = 0; i < table.getRowCount(); i++) {
        table.setValueAt(state, i, 0);
      }
    } else if (obj == refreshBut || obj == backBut) {
      setContent(Home.titlePan.getTitle());
      backBut.setVisible(false);
    } else if (obj == deleteBut) {
      ArrayList selectedMessages = getSelectedMessages();
      if (selectedMessages.isEmpty()) {
        FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE);
      } else {
        int option =
            JOptionPane.showConfirmDialog(
                Home.home.homeFrame,
                "Are You Sure?",
                "DELETE",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (option == 0) {
          Database.deleteMessages(selectedMessages, Home.titlePan.getTitle());
          setContent(Home.titlePan.getTitle());
        }
      }
    } else if (obj == restoreBut) {
      ArrayList selectedMessages = getSelectedMessages();
      if (selectedMessages.isEmpty()) {
        FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE);
      } else {
        int option =
            JOptionPane.showConfirmDialog(
                Home.home.homeFrame,
                "Are You Sure?",
                "RESTORE",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (option == 0) {
          Database.restoreMessages(selectedMessages);
          setContent(Home.titlePan.getTitle());
        }
      }
    }
  }
Esempio n. 25
0
 public void setAbandonEnabled(boolean b) {
   abandonButton.setEnabled(b);
   abandonButton.setVisible(b);
   enableControlPanel();
 }
  private void makeFrame(final Editor editor) {
    dialog = new JFrame(title);
    dialog.setMinimumSize(new Dimension(750, 500));
    tabbedPane = new JTabbedPane();

    makeAndShowTab(false, true);

    tabbedPane.addTab("Libraries", null, librariesContributionTab.panel, "Libraries");
    tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

    tabbedPane.addTab("Modes", null, modesContributionTab.panel, "Modes");
    tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);

    tabbedPane.addTab("Tools", null, toolsContributionTab.panel, "Tools");
    tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);

    tabbedPane.addTab("Examples", null, examplesContributionTab.panel, "Examples");
    tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);

    tabbedPane.addTab("Updates", null, updatesContributionTab.panel, "Updates");
    tabbedPane.setMnemonicAt(4, KeyEvent.VK_5);

    tabbedPane.setUI(new SpacedTabbedPaneUI());
    tabbedPane.setBackground(new Color(0x132638));
    tabbedPane.setOpaque(true);

    for (int i = 0; i < 5; i++) {
      tabbedPane.setToolTipTextAt(i, null);
    }

    makeAndSetTabComponents();

    tabbedPane.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            for (int i = 0; i < 4; i++) {
              tabLabels[i].setBackground(new Color(0x2d4251));
              tabLabels[i].setForeground(Color.WHITE);
            }
            updateTabPanel.setBackground(new Color(0x2d4251));
            updateTabLabel.setForeground(Color.WHITE);
            int currentIndex = tabbedPane.getSelectedIndex();
            if (currentIndex != 4) {
              tabbedPane
                  .getTabComponentAt(tabbedPane.getSelectedIndex())
                  .setBackground(new Color(0xe0fffd));
              tabbedPane
                  .getTabComponentAt(tabbedPane.getSelectedIndex())
                  .setForeground(Color.BLACK);
            } else {
              updateTabPanel.setBackground(new Color(0xe0fffd));
              updateTabLabel.setForeground(Color.BLACK);
            }
            getActiveTab().contributionListPanel.scrollPane.requestFocusInWindow();
            //        // When the tab is changed update status to the current selected panel
            //        ContributionPanel currentPanel = getActiveTab().contributionListPanel
            //          .getSelectedPanel();
            //        if (currentPanel != null) {
            //          getActiveTab().contributionListPanel.setSelectedPanel(currentPanel);
            //        }
          }
        });

    //    tabbedPane.setSize(450, 400);
    setLayout();

    restartButton = new JButton(Language.text("contrib.restart"));
    restartButton.setVisible(false);
    restartButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            Iterator<Editor> iter = editor.getBase().getEditors().iterator();
            while (iter.hasNext()) {
              Editor ed = iter.next();
              if (ed.getSketch().isModified()) {
                int option =
                    Messages.showYesNoQuestion(
                        editor,
                        title,
                        Language.text("contrib.unsaved_changes"),
                        Language.text("contrib.unsaved_changes.prompt"));

                if (option == JOptionPane.NO_OPTION) return;
                else break;
              }
            }

            // Thanks to http://stackoverflow.com/a/4160543
            StringBuilder cmd = new StringBuilder();
            cmd.append(
                System.getProperty("java.home")
                    + File.separator
                    + "bin"
                    + File.separator
                    + "java ");
            for (String jvmArg : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
              cmd.append(jvmArg + " ");
            }
            cmd.append("-cp ")
                .append(ManagementFactory.getRuntimeMXBean().getClassPath())
                .append(" ");
            cmd.append(Base.class.getName());

            try {
              Runtime.getRuntime().exec(cmd.toString());
              System.exit(0);
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        });

    Toolkit.setIcon(dialog);
    registerDisposeListeners();

    dialog.pack();
    dialog.setLocationRelativeTo(null);
  }
Esempio n. 27
0
 public void setUndoEnabled(boolean b) {
   undoButton.setEnabled(b);
   undoButton.setVisible(b);
   enableControlPanel();
 }
Esempio n. 28
0
 public void setOKVisiable(boolean isVis) {
   bOk.setVisible(isVis);
 }
Esempio n. 29
0
 public void setButtonVisible(boolean flag) {
   button.setVisible(flag);
 }
Esempio n. 30
0
  /** Constructor for RestaurantGui class. Sets up all the gui components. */
  public RestaurantGui() {
    int WINDOWX = 600;
    int WINDOWY = 500;

    ButtonPanel = new JPanel();
    MrKrabs = new ImageIcon(getClass().getResource("/resources/MrKrabs.png"));
    Ramsay = new ImageIcon(getClass().getResource("/resources/Ramsay.png"));

    RestaurantPortion.setLayout(new BorderLayout());
    InformationPanel = new JPanel();
    InformationPanel.setLayout(new BorderLayout());
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new BorderLayout());

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(25, 25, WINDOWX + 650, WINDOWY + 170);
    setVisible(true);

    setLayout(new BorderLayout());
    Dimension restDim = new Dimension(WINDOWX, (int) (WINDOWY * .86));
    restPanel.setPreferredSize(restDim);
    restPanel.setMinimumSize(restDim);
    restPanel.setMaximumSize(restDim);

    // pauseButton = new JButton("PAUSE");
    // pauseButton.addActionListener(this);
    refreshButton = new JButton("REFRESH");
    refreshButton.addActionListener(this);

    // CUSTOMER PANEL INFORMATION
    Dimension infoDimCustomer = new Dimension(WINDOWX, (int) (WINDOWY * .12));
    customerInformationPanel = new JPanel();
    customerInformationPanel.setPreferredSize(infoDimCustomer);
    customerInformationPanel.setMinimumSize(infoDimCustomer);
    customerInformationPanel.setMaximumSize(infoDimCustomer);
    customerInformationPanel.setBorder(BorderFactory.createTitledBorder("Customers"));

    customerStateCheckBox = new JCheckBox();
    customerStateCheckBox.setVisible(false);
    customerStateCheckBox.addActionListener(this);

    customerInformationPanel.setLayout(new GridLayout(1, 2, 30, 0));

    infoCustomerLabel = new JLabel();
    infoCustomerLabel.setText("<html><pre><i>There are no restaurant customers.</i></pre></html>");
    customerInformationPanel.add(infoCustomerLabel);
    customerInformationPanel.add(customerStateCheckBox);

    // WAITER PANEL INFORMATION/*
    /*
    Dimension infoDimWaiter = new Dimension(WINDOWX, (int) (WINDOWY * .12));
    waiterInformationPanel = new JPanel();
    waiterInformationPanel.setPreferredSize(infoDimWaiter);
    waiterInformationPanel.setMinimumSize(infoDimWaiter);
    waiterInformationPanel.setMaximumSize(infoDimWaiter);
    waiterInformationPanel.setBorder(BorderFactory.createTitledBorder("Waiters"));

    waiterON.addActionListener(this);
    waiterOFF.addActionListener(this);
    */
    // waiterInformationPanel.setLayout(new GridLayout(1, 2, 30, 0));

    infoWaiterLabel = new JLabel();
    infoWaiterLabel.setText("<html><pre><i>Click Add to make waiters</i></pre></html>");
    // waiterInformationPanel.add(infoWaiterLabel);
    waiterON.setVisible(false);
    waiterOFF.setVisible(false);
    // waiterInformationPanel.add(waiterON);
    // waiterInformationPanel.add(waiterOFF);
    RestaurantPortion.add(restPanel, BorderLayout.NORTH);
    InformationPanel.add(customerInformationPanel, BorderLayout.CENTER);
    MrKrabsButton = new JButton(MrKrabs);
    RamsayButton = new JButton(Ramsay);
    MrKrabsButton.addActionListener(this);
    RamsayButton.addActionListener(this);
    ButtonPanel.setLayout(new BorderLayout());
    ButtonPanel.add(MrKrabsButton, BorderLayout.WEST);
    ButtonPanel.add(RamsayButton, BorderLayout.EAST);
    InformationPanel.add(ButtonPanel, BorderLayout.SOUTH);
    // InformationPanel.add(waiterInformationPanel, BorderLayout.CENTER);
    RestaurantPortion.add(InformationPanel, BorderLayout.CENTER);
    // buttonPanel.add(pauseButton, BorderLayout.CENTER);
    buttonPanel.add(refreshButton, BorderLayout.CENTER);
    RestaurantPortion.add(buttonPanel, BorderLayout.SOUTH);

    add(animationPanel, BorderLayout.CENTER);
    add(RestaurantPortion, BorderLayout.EAST);
  }