/** Shuffle the numbers on the buttons */
  private void shuffle() {
    // Randomize the order
    if (solution) solution = false;
    else Collections.shuffle(current);

    // Reset the stats
    moves = 0;
    solved = false;

    // Reset each of the buttons to reflect the randomized
    // order
    for (int i = 0; i < buttons.size(); i++) {
      JButton b = (JButton) buttons.get(i);
      String value = (String) current.get(i);
      int val = Integer.parseInt(value) - 1;
      b.setText(value);
      b.setBackground(java.awt.Color.orange);
      b.setIcon(icons[val]);
      if (value.equals("16")) {
        b.setVisible(false);
        hiddenIndex = i;
      } else {
        b.setVisible(true);
      }
    }

    // Reset the status line
    getStatusLabel().setText("Number of moves: " + moves);
  }
Example #2
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;
 }
  public void stop() {
    started = false;
    runner = null;

    startBtn.setText("Start");
    writeBtn.setVisible(true);
    paramsBtn.setVisible(true);
  }
Example #4
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);
   }
 }
Example #5
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");
     }
   }
 }
    public void mousePressed(java.awt.event.MouseEvent e) {
      isClick = true;
      JButton b = (JButton) e.getSource();
      // check to see if the target button can be moved
      if (!solved && check(buttons.indexOf(b))) {
        // hide the target button
        b.setVisible(false);

        // Figure out the bounds of the areas where source
        // and target buttons are located
        int menuOffset = getJMenuBar().getHeight();
        dragSourceArea = b.getBounds();
        dragTargetArea = ((JButton) buttons.get(hiddenIndex)).getBounds();
        dragSourceArea.translate(0, menuOffset);
        dragTargetArea.translate(0, menuOffset);

        // setup the bounds of the panel to limit the locations on the drag
        // layer
        panelArea = new Rectangle(0, menuOffset, getJPanel().getWidth(), getJPanel().getHeight());

        // Setup and show the drag button on the upper layer
        getDragButton().setText(b.getText());
        getDragButton().setBounds(dragSourceArea);
        getDragButton().setVisible(true);

        // Offset when repositioning the drag button later
        cursorOffset = new Point(e.getX(), e.getY());
      }
    }
 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);
 }
 /**
  * This method initializes dragButton
  *
  * @return JButton
  */
 private JButton getDragButton() {
   if (dragButton == null) {
     dragButton = new JButton();
     dragButton.setVisible(false);
     dragButton.setBackground(new java.awt.Color(51, 102, 255));
   }
   return dragButton;
 }
  /**
   * React to the pushing of the given button
   *
   * @param index The number of the button pushed
   */
  private void slide(int index) {

    // Don't do anything if the puzzle is solved
    if (solved) return;

    // if not a valid click return
    if (!check(index)) {
      return;
    }

    // swap positions
    current.set(index, current.set(hiddenIndex, current.get(index)));

    // swap strings
    JButton b = (JButton) buttons.get(index);
    b.setText((String) current.get(index));
    b.setIcon(icons[Integer.parseInt(current.get(index)) - 1]);
    b.setVisible(false);
    b = (JButton) buttons.get(hiddenIndex);
    b.setText((String) current.get(hiddenIndex));
    b.setIcon(icons[Integer.parseInt(current.get(hiddenIndex)) - 1]);
    b.setVisible(true);

    // update the position of the blanked spot
    hiddenIndex = index;

    // Increment the number of moves and update status
    moves++;
    getStatusLabel().setText("Number of moves: " + moves);

    // if you've won
    if (current.equals(correct)) {
      solved = true;
      getStatusLabel().setText("Solved the game in " + moves + " moves.");
      // Change the buttons colors to green
      Iterator itr = buttons.iterator();
      while (itr.hasNext()) {
        ((JButton) itr.next()).setBackground(java.awt.Color.green);
      }
    }
  }
Example #10
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);
  }
    public void mouseReleased(java.awt.event.MouseEvent e) {
      if (dragTargetArea != null) {

        // Turn off the drag button and feedback
        getDragButton().setVisible(false);
        paintTargetFeedback(-1, -1);

        e.translatePoint(dragSourceArea.x, dragSourceArea.y);
        Point p = makeSafePoint(e.getX(), e.getY());

        JButton b = (JButton) e.getSource();
        if (isClick || dragTargetArea.contains(p.x, p.y)) {
          // if we're considered a simple click, or the dragging ended
          // within the target area, perform the move.
          slide(buttons.indexOf(b));
        } else {
          // The drag finished outside the target, so just show the
          // hidden button and don't move anything.
          b.setVisible(true);
        }
        dragTargetArea = null;
        dragSourceArea = null;
      }
    }
Example #12
0
  public WinSize() {
    super(windowTitle);
    int i;
    int currentPanel; // Value to specify which is the current panel in the vector
    int X = 0;
    int Y = 0;
    PSlider slider = null;
    JPanel subPanel = new JPanel(); // value used when adding sliders to the frame
    Runtime program = Runtime.getRuntime();
    Container content = getContentPane();

    createSliderVector();
    createPanelVector();
    /** Get current OS of the system. */
    if (System.getProperty("os.name").startsWith("Windows")) isWindows = true;
    else isWindows = false;
    /** Set interactive buttons for the user interface */
    JButton exeButton = new JButton("Execute");
    exeButton.setToolTipText("Re-execute the program");
    JButton resetButton = new JButton("Reset");
    resetButton.setToolTipText("Reset Value");
    JButton exitButton = new JButton("Exit");
    exitButton.setToolTipText("Exit the Program");

    if (COMPONENTS == 0) {
      exeButton.setVisible(false);
      resetButton.setVisible(false);
    }

    JPanel mainPanel = new JPanel();
    JPanel subPanel1 = new JPanel();
    JPanel subPanel2 = new JPanel();

    // JScrollPane scrollPane = new JScrollPane(); // main text pane with scroll bars
    content.add(mainPanel, BorderLayout.SOUTH);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    content.add(scrollPane, BorderLayout.CENTER);
    scrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
    scrollPane.getViewport().add(textPane);

    mainPanel.add(subPanel1);
    mainPanel.add(subPanel2);
    subPanel1.setLayout(new GridLayout(0, 1));
    /** Add subPanel elements to the subPanel1, each would be a row of sliders */
    for (i = 0; i < ROWS; i++) subPanel1.add((JPanel) vSubPanel.elementAt(i));
    /** Set the first element in the Panel Vector as the current subPanel. */
    currentPanel = 0;
    subPanel = (JPanel) vSubPanel.elementAt(currentPanel);
    /** Allocate sliders to the sub-panels. */
    for (i = 0; i < COMPONENTS; i++) {
      slider = (PSlider) vSlider.elementAt(i);
      if (slider.getResideValue() == 'n') {
        currentPanel += 1;
        subPanel = (JPanel) vSubPanel.elementAt(currentPanel);
      }
      subPanel.add((PSlider) vSlider.elementAt(i));
    }

    /** Set and view the source code on the frame */
    textPane.setEditable(false);
    textPane.setContentType("text/html; charset=EUC-JP");

    subPanel2.setLayout(new GridLayout(0, 3));
    subPanel2.add(exeButton);
    exeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doExeCommand();
          }
        });
    subPanel2.add(resetButton);
    resetButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doResetCommand();
          }
        });
    subPanel2.add(exitButton);
    exitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doExitCommand();
          }
        });

    /** Run the illustrated program */
    slider = (PSlider) vSlider.elementAt(0);
    X = slider.getIntDefaultValue();
    slider = (PSlider) vSlider.elementAt(1);
    Y = slider.getIntDefaultValue();

    try {
      pid = program.exec(cmd + " " + X + " " + Y);
      if (isWindows == false) {
        Process pid2 = null;
        pid2 = program.exec("getpid WinSize");
      }
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      System.exit(-1);
    }
    /** Set the initial status for the window */
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            // File fp = new File("link");
            // boolean delete = fp.delete();
            doResetCommand();
            pid.destroy();
          }
        });
    doSourceFileUpdate();
    setSize(WIDTH, HEIGHT);
    setLocation(500, 0);
    setVisible(true);
  }
Example #13
0
 public void setUndoEnabled(boolean b) {
   undoButton.setEnabled(b);
   undoButton.setVisible(b);
   enableControlPanel();
 }
Example #14
0
 public void setAbandonEnabled(boolean b) {
   abandonButton.setEnabled(b);
   abandonButton.setVisible(b);
   enableControlPanel();
 }
Example #15
0
 public void setHelpEnabled(boolean b) {
   helpButton.setEnabled(b);
   helpButton.setVisible(b);
   enableControlPanel();
 }
Example #16
0
 public void setCloseEnabled(boolean b) {
   closeButton.setEnabled(b);
   closeButton.setVisible(b);
   enableControlPanel();
 }
Example #17
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);
  }
  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);
  }
  public CAStatic(int size) {

    // size is the size of the area containing cells
    dsize = size;
    gSize = size + 2 * maxit;
    int wscale = 6; // scale for main panel
    int btnHeight = 480 - 384; // found by trial and error - must be a better way!

    // experiment = new CAGridStatic(size, maxC);
    // int tint = (int)Math.ceil((double)(400*maxit)/(double)gSize)+(480-384);
    // int tint = (int)Math.ceil((double)(400*(50+maxit))/(double)gSize)+(480-384);
    int tint = (maxit + rowstoDraw) * wscale + btnHeight;
    // only going to show up to 50 dots in lower panel
    // add 20 to x and 60 to y bcos not printing onto the full frame
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container mainWindow = getContentPane();
    mainWindow.setLayout(new BorderLayout());
    setSize(gSize * wscale, tint);

    buttonHolder = new JPanel();
    buttonHolder.setLayout(new GridLayout(2, 2));

    SpinnerNumberModel model3 = new SpinnerNumberModel(50, 0, 100, 5);
    JSpinner spinner3 = new JSpinner(model3);
    writeBtn = new JButton("Output Results to file");
    writeBtn.addActionListener(this);

    startBtn = new JButton("Start");
    startBtn.addActionListener(this);

    paramsBtn = new JButton("Set Probabilities");
    paramsBtn.addActionListener(this);

    wrapBtn = new JButton("Toggle wrap");
    wrapBtn.addActionListener(this);

    buttonHolder.add(writeBtn);
    writeBtn.setVisible(false);
    buttonHolder.add(paramsBtn);
    buttonHolder.add(wrapBtn);
    buttonHolder.add(startBtn);

    mainWindow.add(buttonHolder, BorderLayout.SOUTH);

    msgBtn = new JTextArea(" Default Parameter Values: " + CAGridStatic.params);
    msgBtn.setEditable(false);

    mainWindow.add(msgBtn, BorderLayout.NORTH);

    CApicture = new CAImagePanel();
    CApicture.rowstoShow = rowstoDraw;
    mainWindow.add(CApicture, BorderLayout.CENTER);

    // not here - doesn't work: CApicture.setScale(gSize,maxit,scale);

    // pack();

    setVisible(true);
    setpalette();
    iterations = 0;
    savedvals = new int[maxRun][maxit];
    outPrinter = new ResultsPrinter(this);
  }
Example #20
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();
    }
  }
Example #21
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");

  }
Example #22
0
  private void initializeComponents() {
    this.setTitle("Synchro - Kopierassistent");
    this.setBounds(0, 0, 550, 600);

    this.setResizable(true);
    this.setLayout(null);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(this);

    mainPanel = new JPanel();
    mainPanel.setBounds(0, 0, this.getWidth() - 20, 25);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    mainPanel.setLayout(null);

    btnBackup = new JButton("Backup");
    btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight());
    btnBackup.addActionListener(this);
    mainPanel.add(btnBackup);

    this.add(mainPanel);

    fcPanel = new JPanel();
    fcPanel.setBounds(10, 40, this.getWidth(), 260);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    fcPanel.setLayout(null);

    quellLabel = new JLabel("Bitte Quellverzeichnis auswählen");
    quellLabel.setBounds(10, 5, 320, 20);
    fcPanel.add(quellLabel);

    quellListModel = new DefaultListModel<>();
    quellJList = new JList<ListItem>(quellListModel);
    quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    quellJList.setLayoutOrientation(JList.VERTICAL);
    quellJList.addListSelectionListener(this);

    listBoxScroller = new JScrollPane(quellJList);
    listBoxScroller.setBounds(0, 30, 315, 100);
    fcPanel.add(listBoxScroller);

    btnQAuswahl = new JButton("Quellverz. hinzufügen");
    btnQAuswahl.setBounds(320, 30, 200, 25);
    btnQAuswahl.addActionListener(this);
    fcPanel.add(btnQAuswahl);
    btnQEntfernen = new JButton("Quellverz. entfernen");
    btnQEntfernen.setBounds(320, 60, 200, 25);
    btnQEntfernen.addActionListener(this);
    fcPanel.add(btnQEntfernen);

    zielLabel = new JLabel("Bitte Zielverzeichnis auswählen");
    zielLabel.setBounds(10, 135, 320, 20);
    fcPanel.add(zielLabel);

    zielListModel = new DefaultListModel<>();
    zielJList = new JList<ListItem>(zielListModel);
    zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    zielJList.setLayoutOrientation(JList.VERTICAL);
    zielJList.addListSelectionListener(this);

    listBoxScroller2 = new JScrollPane(zielJList);
    listBoxScroller2.setBounds(0, 160, 315, 100);
    fcPanel.add(listBoxScroller2);

    btnZAuswahl = new JButton("Zielverz. hinzufügen");
    btnZAuswahl.setBounds(320, 160, 200, 25);
    btnZAuswahl.addActionListener(this);
    fcPanel.add(btnZAuswahl);
    btnZEntfernen = new JButton("Zielverz. entfernen");
    btnZEntfernen.setBounds(320, 190, 200, 25);
    btnZEntfernen.addActionListener(this);
    fcPanel.add(btnZEntfernen);
    this.add(fcPanel);

    ButtonGroup bGrp = new ButtonGroup();

    optionPanel = new JPanel();
    optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90);
    optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90));
    // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    optionPanel.setLayout(new GridLayout(3, 1));

    nUebSchr = new JRadioButton("Keine Dateien überschreiben");
    nUebSchr.addItemListener(this);
    bGrp.add(nUebSchr);
    optionPanel.add(nUebSchr);

    ueSchr = new JRadioButton("Neuere Dateien überschreiben");
    ueSchr.addItemListener(this);
    bGrp.add(ueSchr);
    optionPanel.add(ueSchr);

    aUeSchr = new JRadioButton("Alle Dateien überschreiben");
    aUeSchr.addItemListener(this);
    bGrp.add(aUeSchr);
    optionPanel.add(aUeSchr);

    this.add(optionPanel);

    syncPanel = new JPanel();
    syncPanel.setBounds(
        10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25);
    // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    syncPanel.setLayout(new BorderLayout());

    btnSync = new JButton("Sync it!");
    btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnSync.addActionListener(this);
    btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    syncPanel.add(btnSync, BorderLayout.LINE_START);

    btnAbbruch = new JButton("Abbrechen");
    btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnAbbruch.addActionListener(this);
    btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setVisible(false);
    syncPanel.add(btnAbbruch, BorderLayout.LINE_END);

    progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    progressBar.setBorderPainted(true);
    progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3)));
    progressBar.setForeground(Color.RED);
    progressBar.setStringPainted(true);
    progressBar.setVisible(true);
    syncPanel.add(progressBar, BorderLayout.CENTER);
    this.add(syncPanel);

    logPanel = new JPanel();
    logPanel.setBounds(
        10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105);
    logPanel.setLayout(new BorderLayout());

    textArea = new JTextArea();
    textArea.setMargin(new Insets(3, 3, 3, 3));
    textArea.setBackground(Color.black);
    textArea.setForeground(Color.LIGHT_GRAY);
    textArea.setAutoscrolls(true);
    textArea.setFocusable(false);
    textAreaScroller = new JScrollPane(textArea);
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50);

    logPanel.add(textAreaScroller, BorderLayout.CENTER);
    this.add(logPanel, BorderLayout.SOUTH);
  }
Example #23
0
  public void actionPerformed(ActionEvent event) {

    if (posicion == -2) posicion = indexaux;

    // Abrir nueva imagen
    if (event.getSource() == carpeta) {

      siguiente.setEnabled(true);
      atras.setEnabled(true);
      presentacion.setEnabled(true);
      grid.setEnabled(true);
      bcomentario.setEnabled(true);
      zoom.setEnabled(true);

      imagenesbean.clear();

      if (imagenes != null) {
        imagenes.clear();
      }

      returnChooser = chooser.showOpenDialog(ArcViewer.this);
      imagenes = lista.Miranda(chooser, returnChooser);

      for (int asd1 = 0; asd1 < imagenes.size(); asd1++) {
        imagenesbean.add(new ImagenBean(imagenes.get(asd1), 0, 0));
      }

      String getImgSelected = chooser.getSelectedFile().getPath();

      for (int index = 0; index < imagenesbean.size(); index++) {
        if (getImgSelected.equals(imagenesbean.get(index).getIcon())) {
          imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon()));
          indexaux = index;
        }
      }
    }

    // Imagen siguiente
    if (event.getSource() == siguiente) {
      posicion++;
      if (posicion >= imagenesbean.size()) {
        posicion = 0;
      }

      imagen.setIcon(
          ajustar.ajusteImg(
              new ImageIcon(imagenesbean.get(posicion).getIcon()),
              imagenesbean.get(posicion).getAncho(),
              imagenesbean.get(posicion).getAlto(),
              areaventana.getWidth() - 50,
              areaventana.getHeight()));
    }

    // Imagen anterior
    if (event.getSource() == atras) {
      posicion--;
      if (posicion == -1) {
        posicion = imagenesbean.size() - 1;
      }

      imagen.setIcon(
          ajustar.ajusteImg(
              new ImageIcon(imagenesbean.get(posicion).getIcon()),
              imagenesbean.get(posicion).getAncho(),
              imagenesbean.get(posicion).getAlto(),
              areaventana.getWidth() - 50,
              areaventana.getHeight()));
    }

    // Presentacion iniciar/detener
    if (event.getSource() == presentacion) {

      if (isPresentacion == false) {
        grid.setVisible(false);
        atras.setVisible(false);
        siguiente.setVisible(false);
        carpeta.setVisible(false);
        bcomentario.setVisible(false);
        zoom.setVisible(false);
        ptiempo.setVisible(true);
      }

      if (isPresentacion == true) {
        grid.setVisible(true);
        atras.setVisible(true);
        siguiente.setVisible(true);
        carpeta.setVisible(true);
        bcomentario.setVisible(true);
        zoom.setVisible(true);
        ptiempo.setVisible(false);
      }

      if (presentacion.getIcon() == imgPausa) {
        slide.detener();
        posicion = slide.getPosicion();
        presentacion.setIcon(imgPlay);
        isPresentacion = false;
        return;
      }

      if (presentacion.getIcon() == imgPlay) {
        slide.setTodo(posicion, imagen, imagenesbean, areaventana, ptiempo);
        new Thread(slide, "prueba").start();
        presentacion.setIcon(imgPausa);
        isPresentacion = true;
        return;
      }
    }

    // Modo rejilla
    if (event.getSource() == grid) {

      imagen.setVisible(false);
      siguiente.setVisible(false);
      atras.setVisible(false);
      presentacion.setVisible(false);
      grid.setVisible(false);
      bcomentario.setVisible(false);
      zoom.setVisible(false);
      carpeta.setVisible(false);
      ptiempo.setVisible(false);

      // desplazamiento.setVisible(true);

      if (corrobora == true) {
        for (int celular = 0; celular < imgButtonArray.length; celular++) {
          imgButtonArray[celular].setVisible(true);
        }
      }

      if (corrobora == false) {
        imgButtonArray = new JButton[imagenesbean.size()];

        for (int goku = 0; goku < imagenesbean.size(); goku++) {
          areaventana.add(imgButtonArray[goku] = new JButton());
          imgButtonArray[goku].setPreferredSize(new Dimension(200, 200));
          imgButtonArray[goku].addActionListener(this);
          imgButtonArray[goku].setBackground(colorGris);
          imgButtonArray[goku].setIcon(
              ajustar.ajusteCuadrado(new ImageIcon(imagenesbean.get(goku).getIcon())));
          corrobora = true;
        }
      }
    }

    // Comentario
    if (event.getSource() == bcomentario) {
      new Comentario(imagenesbean.get(posicion), posicion);
    }

    // Cuando se apreta un boton de la rejilla
    if (corrobora == true) {
      for (int alice = 0; alice < imgButtonArray.length; alice++) {
        if (event.getSource() == imgButtonArray[alice]) {
          for (int wonderland = 0; wonderland < imgButtonArray.length; wonderland++) {
            imgButtonArray[wonderland].setVisible(false);
          }
          posicion = alice;

          imagen.setIcon(
              ajustar.ajusteImg(
                  new ImageIcon(imagenesbean.get(posicion).getIcon()),
                  imagenesbean.get(posicion).getAncho(),
                  imagenesbean.get(posicion).getAlto(),
                  areaventana.getWidth() - 50,
                  areaventana.getHeight()));

          imagen.setVisible(true);
          siguiente.setVisible(true);
          atras.setVisible(true);
          presentacion.setVisible(true);
          grid.setVisible(true);
          bcomentario.setVisible(true);
          zoom.setVisible(true);
          carpeta.setVisible(true);
        }
      }
    }

    if (event.getSource() == zoom) {
      System.out.println("Haciendo un ZOOOOOOOOOOOOM");
    }
  }
Example #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());
        }
      }
    }
  }