Example usage for java.awt.event MouseListener MouseListener

List of usage examples for java.awt.event MouseListener MouseListener

Introduction

In this page you can find the example usage for java.awt.event MouseListener MouseListener.

Prototype

MouseListener

Source Link

Usage

From source file:org.openconcerto.task.TodoListPanel.java

private void initTable(int mode) {
    this.t.setBlockRepaint(true);

    this.t.setBlockEventOnColumn(true);
    this.model.setMode(mode);

    this.t.getColumnModel().getColumn(0).setCellRenderer(this.a);
    this.t.getColumnModel().getColumn(0).setCellEditor(this.a);
    this.t.setBlockEventOnColumn(true);
    setIconForColumn(0, this.iconTache);
    setIconForColumn(1, this.iconPriorite);
    this.t.setBlockEventOnColumn(true);

    this.t.getColumnModel().getColumn(1).setCellEditor(this.iconEditor);
    final JTextField textField = new JTextField() {
        @Override//from www  .j  a  v a2 s  .  co  m
        public void paint(Graphics g) {
            super.paint(g);
            g.setColor(TodoListPanel.this.t.getGridColor());
            g.fillRect(getWidth() - 19, 0, 1, getHeight());
            g.setColor(new Color(250, 250, 250));
            g.fillRect(getWidth() - 18, 0, 18, getHeight());
            g.setColor(Color.BLACK);
            for (int i = 0; i < 3; i++) {
                int x = getWidth() - 14 + i * 4;
                int y = getHeight() - 5;
                g.fillRect(x, y, 1, 2);
            }
        }
    };
    textField.setBorder(BorderFactory.createEmptyBorder());
    final DefaultCellEditor defaultCellEditor = new DefaultCellEditor(textField);
    textField.addMouseListener(new MouseListener() {

        public void mouseClicked(MouseEvent e) {

        }

        public void mouseEntered(MouseEvent e) {
            // TODO Auto-generated method stub

        }

        public void mouseExited(MouseEvent e) {
            // TODO Auto-generated method stub

        }

        public void mousePressed(MouseEvent e) {

        }

        public void mouseReleased(MouseEvent e) {
            if (e.getX() > textField.getWidth() - 19) {
                TodoListElement l = getTaskAt(
                        SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), TodoListPanel.this.t));
                TodoListPanel.this.t.editingCanceled(new ChangeEvent(this));
                JFrame f = new JFrame(TM.tr("details"));
                f.setContentPane(new TodoListElementEditorPanel(l));
                f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                f.setSize(500, 200);
                f.setLocation(50, e.getYOnScreen() + TodoListPanel.this.t.getRowHeight());
                f.setVisible(true);
            }

        }
    });
    this.t.getColumnModel().getColumn(2).setCellEditor(defaultCellEditor);
    this.t.getColumnModel().getColumn(3).setMaxWidth(300);
    this.t.getColumnModel().getColumn(3).setMinWidth(100);

    this.timestampTableCellEditorCreated.stopCellEditing();
    this.timestampTableCellEditorDone.stopCellEditing();
    this.timestampTableCellEditorDeadLine.stopCellEditing();

    if (this.model.getMode() == TodoListModel.EXTENDED_MODE) {
        this.t.getColumnModel().getColumn(3).setCellRenderer(this.timestampTableCellRendererCreated);
        this.t.getColumnModel().getColumn(3).setCellEditor(this.timestampTableCellEditorCreated);

        this.t.getColumnModel().getColumn(4).setCellRenderer(this.timestampTableCellRendererDone);
        this.t.getColumnModel().getColumn(4).setCellEditor(this.timestampTableCellEditorDone);

        this.t.getColumnModel().getColumn(5).setCellRenderer(this.timestampTableCellRendererDeadLine);
        this.t.getColumnModel().getColumn(5).setCellEditor(this.timestampTableCellEditorDeadLine);
    } else {
        this.t.getColumnModel().getColumn(3).setCellRenderer(this.timestampTableCellRendererDeadLine);
        this.t.getColumnModel().getColumn(3).setCellEditor(this.timestampTableCellEditorDeadLine);
    }

    final TableColumn userColumn = this.t.getColumnModel()
            .getColumn(this.t.getColumnModel().getColumnCount() - 1);
    userColumn.setCellRenderer(this.userTableCellRenderer);
    userColumn.setMaxWidth(150);
    userColumn.setMinWidth(100);
    t.setEnabled(false);
    initUserCellEditor(userColumn);

    this.t.setBlockEventOnColumn(false);
    this.t.setBlockRepaint(false);
    this.t.getColumnModel().getColumn(1).setCellRenderer(this.iconRenderer);
    // Better look
    this.t.setShowHorizontalLines(false);
    this.t.setGridColor(new Color(230, 230, 230));
    this.t.setRowHeight(new JTextField(" ").getPreferredSize().height + 4);
    AlternateTableCellRenderer.UTILS.setAllColumns(this.t);
    this.t.repaint();

}

From source file:org.revager.gui.findings_list.FindingsListFrame.java

private void createAttPanel() {
    GridLayout grid = new GridLayout(4, 1);
    grid.setVgap(8);//from  ww  w  .j  a va  2  s . c  om

    JPanel attendeeButtons = new JPanel(grid);

    addResiAtt = GUITools.newImageButton();
    addResiAtt.setIcon(Data.getInstance().getIcon("addResiAtt_25x25_0.png"));
    addResiAtt.setRolloverIcon(Data.getInstance().getIcon("addResiAtt_25x25.png"));
    addResiAtt.setToolTipText(translate("Add Attendee from the Attendee Pool"));
    addResiAtt.addActionListener(ActionRegistry.getInstance().get(AddResiAttToProtAction.class.getName()));
    attendeeButtons.add(addResiAtt);

    JButton addAttendee = GUITools.newImageButton();
    addAttendee.setIcon(Data.getInstance().getIcon("addAttendee_25x25_0.png"));
    addAttendee.setRolloverIcon(Data.getInstance().getIcon("addAttendee_25x25.png"));
    addAttendee.setToolTipText(translate("Add Attendee"));
    addAttendee.addActionListener(ActionRegistry.getInstance().get(AddAttToProtAction.class.getName()));
    attendeeButtons.add(addAttendee);

    removeAttendee = GUITools.newImageButton();
    removeAttendee.setIcon(Data.getInstance().getIcon("removeAttendee_25x25_0.png"));
    removeAttendee.setRolloverIcon(Data.getInstance().getIcon("removeAttendee_25x25.png"));
    removeAttendee.setToolTipText(translate("Remove Attendee"));
    removeAttendee.addActionListener(ActionRegistry.getInstance().get(RemAttFromProtAction.class.getName()));
    attendeeButtons.add(removeAttendee);

    editAttendee = GUITools.newImageButton();
    editAttendee.setIcon(Data.getInstance().getIcon("editAttendee_25x25_0.png"));
    editAttendee.setRolloverIcon(Data.getInstance().getIcon("editAttendee_25x25.png"));
    editAttendee.setToolTipText(translate("Edit Attendee"));
    editAttendee.addActionListener(ActionRegistry.getInstance().get(EditAttFromProtAction.class.getName()));
    attendeeButtons.add(editAttendee);

    editAttendee.setEnabled(false);
    removeAttendee.setEnabled(false);

    presentAttTable.setRowHeight(55);
    presentAttTable.getColumnModel().getColumn(0).setMaxWidth(55);
    presentAttTable.setShowHorizontalLines(false);
    presentAttTable.setShowVerticalLines(true);
    presentAttTable.setShowGrid(true);
    presentAttTable.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                ActionRegistry.getInstance().get(EditAttFromProtAction.class.getName()).actionPerformed(null);
            }
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }
    });

    TableCellRenderer renderer = (table, value, isSelected, hasFocus, row, column) -> {
        JLabel label = new JLabel((String) value);
        label.setOpaque(true);
        label.setBorder(new EmptyBorder(5, 5, 5, 5));

        label.setFont(UI.VERY_LARGE_FONT);

        if (isSelected) {
            label.setBackground(presentAttTable.getSelectionBackground());
        } else {
            if (row % 2 == 0) {
                label.setBackground(UI.TABLE_ALT_COLOR);
            } else {
                label.setBackground(presentAttTable.getBackground());
            }
        }
        return label;
    };

    for (int i = 1; i <= 4; i++) {
        presentAttTable.getColumnModel().getColumn(i).setCellRenderer(renderer);
    }

    TableColumn col = presentAttTable.getColumnModel().getColumn(0);
    col.setCellRenderer((table, value, isSelected, hasFocus, row, column) -> {
        JPanel localPnl = new JPanel();
        localPnl.add(new JLabel(Data.getInstance().getIcon("attendee_40x40.png")));
        if (isSelected) {
            localPnl.setBackground(presentAttTable.getSelectionBackground());
        } else {
            if (row % 2 == 0) {
                localPnl.setBackground(UI.TABLE_ALT_COLOR);
            } else {
                localPnl.setBackground(presentAttTable.getBackground());
            }
        }
        return localPnl;
    });
    presentAttTable.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            updateAttButtons();
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }
    });

    scrllP = GUITools.setIntoScrollPane(presentAttTable);
    scrllP.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    scrllP.setToolTipText(translate("Add Attendee to Meeting"));
    scrllP.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (isAddResiAttPossible()) {
                ActionRegistry.getInstance().get(AddResiAttToProtAction.class.getName()).actionPerformed(null);
            } else {
                ActionRegistry.getInstance().get(AddAttToProtAction.class.getName()).actionPerformed(null);
            }
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }
    });

    JLabel labelAttendees = new JLabel(translate("Attendees of the current meeting:"));
    labelAttendees.setFont(UI.HUGE_FONT_BOLD);

    GUITools.addComponent(attPanel, gbl, labelAttendees, 0, 0, 2, 1, 1.0, 0.0, 20, 20, 0, 20,
            GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
    GUITools.addComponent(attPanel, gbl, scrllP, 0, 1, 1, 1, 1.0, 1.0, 20, 20, 0, 20, GridBagConstraints.BOTH,
            GridBagConstraints.NORTHWEST);
    GUITools.addComponent(attPanel, gbl, attendeeButtons, 1, 1, 1, 1, 0, 0, 20, 0, 20, 20,
            GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
}

From source file:client.InterfaceJeu.java

public void distribuerCartes(String cartesList) {
    //System.out.println("distribution des cartes");
    nettoyerMain();//from www  .  j a v a  2  s. c o  m
    if (!cartesList.equals("[]")) {
        try {
            this.cartes = (JSONArray) parser.parse(cartesList);
        } catch (Exception e) {
            System.out.println("error json : " + e.getLocalizedMessage());
        }
        Iterator it = cartes.iterator();
        int i = 0;
        int j = 0;
        while (it.hasNext()) {
            obj = (JSONObject) it.next();
            auxName = obj.get("hauteur").toString() + '-' + obj.get("couleur").toString();
            // System.out.println(auxName);
            /*ImageIcon img=new ImageIcon(ClassLoader.getSystemResource("images/"+auxName));
            System.out.println(img);
            JLabel label = new JLabel();
            label.setPreferredSize(new Dimension(img.getIconWidth(), img.getIconHeight()));
            //label.setIcon(img);
            label.setText("youpi!!");
            jPanel2.add(label);
            jPanel2.revalidate(); 
            jPanel2.repaint(); */
            imgCartes.add(
                    new JLabel(new ImageIcon(ClassLoader.getSystemResource("images/" + auxName + ".gif"))));
            imgCartes.get(i).setLayout(new BorderLayout());
            imgCartes.get(i).setSize(62, 89);
            imgCartes.get(i).setName(auxName);
            imgCartes.get(i).addMouseListener(new MouseListener() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    //verifier si c'est son tour d'abord
                    if ((tourName.equals(c.pseudo) && !interSession)
                            || (interSession && (role.equals("president") || role.equals("vicepresident")))) {
                        if (cartesSelectionnees.contains(e.getComponent())) {
                            deselectionnerCarte(e.getComponent());
                        } else {
                            selectionnerCarte(e.getComponent());
                        }
                    }
                    //System.out.println(e.getComponent().getClass());
                }

                @Override
                public void mousePressed(MouseEvent e) {
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                }

                @Override
                public void mouseExited(MouseEvent e) {
                }
            });
            imgCartes.get(i).setLocation(j, jPanel1.getHeight() - 92);
            this.jPanel1.add(imgCartes.get(i), BorderLayout.CENTER);
            i++;
            j = j + 28;

            jPanel1.repaint();
            //                ImageIcon tempImg=new ImageIcon("../images/"+auxName+".gif");
            //                imgCartes.add(tempImg);
            //                Image b=tempImg.getImage();
            //                this.getGraphics().drawImage(b, 192, 280, null);
            //                tempImg.paintIcon(this, null, 192, 280);
            //                this.jPanel2.add(tempImg);
        }

        jButton1.setVisible(true);
        jButton1.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (jButton1.isEnabled()) {
                    if (interSession) {
                        donnerCartes();
                    } else {
                        jouerCartes();
                    }
                }
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }
        });

        jButton2.setVisible(true);
        jButton2.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (jButton2.isEnabled()) {
                    passer();
                }
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }
        });
    }
}

From source file:com.limegroup.gnutella.gui.search.ResultPanel.java

/**
 * Sets extra values for non dummy ResultPanels.
 * (Used for all tables that will have results.)
 *
 * Currently:/*  w ww.  j  a v  a2 s .  c o  m*/
 * - Sorts the count column, if it is visible & real-time sorting is on.
 * - Adds listeners, so the filters can be displayed when necessary.
 */
private void setupRealTable() {
    SearchTableColumns columns = ((ResultPanelModel) DATA_MODEL).getColumns();
    LimeTableColumn countColumn = columns.getColumn(SearchTableColumns.COUNT_IDX);
    if (SETTINGS.REAL_TIME_SORT.getValue() && TABLE.isColumnVisible(countColumn.getId())) {
        DATA_MODEL.sort(SearchTableColumns.COUNT_IDX); // ascending
        DATA_MODEL.sort(SearchTableColumns.COUNT_IDX); // descending
    }

    MouseListener filterDisplayer = new MouseListener() {
        public void mouseClicked(MouseEvent e) {
            if (e.isConsumed())
                return;
            e.consume();
            SearchMediator.panelSelected(ResultPanel.this);
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }
    };
    // catches around the button area.
    MAIN_PANEL.addMouseListener(filterDisplayer);
    // catches the blank area before results fill in
    SCROLL_PANE.addMouseListener(filterDisplayer);
    // catches selections on the table
    TABLE.addMouseListener(filterDisplayer);
    // catches the table header
    TABLE.getTableHeader().addMouseListener(filterDisplayer);
}

From source file:Citas.FrameCita.java

public void setCitas()
        throws IOException, ClientProtocolException, JSONException, ParseException, java.text.ParseException {

    JSONArray citasporfecha;// w ww  . j  av  a2  s . co m
    JSONArray pacienteporid;
    JSONObject paciente;
    jCalendar1.setTodayButtonVisible(false);
    jCalendar1.setForeground(Color.BLUE);//Pinta todas las fechas en azul, las que estan ocupadas se pintaran de rojo abajo
    jCalendar1.getDayChooser().addDateEvaluator(new DJFechasEspInv());//Pinta las Fechas ocupadas en rojo
    BorrarTextFields();
    PanelCita.removeAll();
    PanelCita.revalidate();
    PanelCita.repaint();
    PanelCita.setLayout(new GridBagLayout());
    SimpleDateFormat formato = new SimpleDateFormat("yyyy-MM-dd");
    FechaLbl.setText(formato.format(jCalendar1.getDate()));
    dibujarPanelCita(medico);//Dibuja la "libreta" de las citas

    font = font = font.deriveFont(Font.BOLD, 17);
    disenoLabel(FechaLbl);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 0.5;
    gbc.weighty = 0.5;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.NONE;
    PanelCita.add(FechaLbl, gbc);
    //Aqui se busca esta fecha (jCalendar1.getDate()) en la base de datos y se traen las citas 
    citasporfecha = rutasLeer
            .leer("http://localhost/API_Citas/public/Citas/porFecha/" + formato.format(jCalendar1.getDate()));

    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    int total = 0;
    for (int i = 0; i < citasporfecha.length(); i++) {
        JSONObject obj = (JSONObject) citasporfecha.get(i);
        System.out.println("ENTRE EN EL FOR " + i + ": " + obj.toString());

        for (int j = 0; j < citas.length; j++) {

            if (citas[j].getHora().equals(obj.get("hora"))) {
                pacienteporid = rutasLeer
                        .leer("http://localhost/API_Citas/public/Pacientes/porId/" + obj.get("paciente"));
                paciente = (JSONObject) pacienteporid.get(0);
                citas[j].setText(citas[j].getText() + " " + obj.get("paciente") + " " + paciente.get("cedula"));
                total++;
            }
        }
        //if(citas [i].getHora() == citasporfecha.get("id"))
        System.out.println("voy a agregar las citas");
        //citas [i] = new Citas (i);  
        citas[i].setBorder(BorderFactory.createLineBorder(Color.black));
        citas[i].setOpaque(true);

        citas[i].addMouseListener(new MouseListener() {
            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }

            @Override
            public void mouseClicked(MouseEvent e) {

                Citas seleccion = new Citas();
                seleccion = (Citas) e.getComponent();
                System.out.println("Label  clickeado" + seleccion.getText());
                acciones(seleccion);
            }
        });

        gbc.gridy = i + 1;
        PanelCita.add(citas[i], gbc);

    }
    if (total == medico.getCitasPorDia()) {
        JSONObject fecha = new org.json.JSONObject();
        fecha.put("diasOcupados", formato.format(jCalendar1.getDate()));
        //rutasAdd.add("http://localhost/API_Citas/public/Diasocupados/insertarfecha", fecha);
        jCalendar1.getDayChooser().addDateEvaluator(new DJFechasEspInv());//Pinta las Fechas ocupadas en rojo 
    }
    jCalendar1.setDate(jCalendar1.getDate());
    jCalendar1.revalidate();
    jCalendar1.repaint();
    PanelCita.revalidate();
    PanelCita.repaint();
}

From source file:graphics.MainWindow.java

private void createChartPanel(JPanel panel, final int pos) {
    JPanel Panel = new JPanel();

    Panel.setBackground(new Color(157, 191, 160));
    final ChartPanel chart = this.World.getChart(pos);
    chart.setPreferredSize(new Dimension(100, 100));
    Panel.add(chart);/*  w w  w.ja  v a  2  s  .com*/

    chart.addMouseListener(new MouseListener() {

        public void mouseClicked(MouseEvent arg0) {
            World.showChart(pos);
        }

        public void mousePressed(MouseEvent arg0) {
            World.showChart(pos);
        }

        public void mouseReleased(MouseEvent arg0) {
            World.showChart(pos);
        }

        public void mouseEntered(MouseEvent arg0) {
        }

        public void mouseExited(MouseEvent arg0) {
        }
    });
    panel.add("ChartPanel", Panel);
    ((CardLayout) panel.getLayout()).show(panel, "ChartPanel");
}

From source file:ResultScreen.java

private void initButtons() {
    updateButton1.addActionListener((ActionEvent e) -> {
        showGraphics();//from w  ww  . j  a va  2  s.  c o m
    });

    updateButton.addActionListener((ActionEvent e) -> {
        showGraphics2();
    });

    besselButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            EspectroForm spectro = new EspectroForm(modulate.getSpectro());
            spectro.setVisible(true);
        }
    });

    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    calculosMenu.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {

        }

        @Override
        public void mousePressed(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            CalculosForm c = new CalculosForm(modulate);
            c.setVisible(true);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseExited(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });
}

From source file:org.richie.codeGen.ui.GenAndPreviewUI.java

/**
 * tab? ??tab/*from w  ww  . j  av  a  2  s . com*/
 */
private void addTabbedPaneMouseListener() {
    mainPanel.addMouseListener(new MouseListener() {

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                int closeTabNumber = mainPanel.getSelectedIndex();
                if (closeTabNumber != 0) {
                    mainPanel.removeTabAt(closeTabNumber);
                }
            }

        }
    });
}

From source file:Citas.FrameCita.java

private void dibujarPanelCita(Medico medico) {
    min = medico.getMinutosDeAtencionxPaciente();
    int horaInicio;
    int minInicio;
    int horaActual;
    int minActual;

    GridBagConstraints gbc = new GridBagConstraints();

    horaInicio = medico.getHoraInicio();
    horaActual = medico.getHoraInicio();
    minInicio = medico.getMinInicio();/*from   w ww .j  a  v a2s  . co  m*/
    minActual = medico.getMinInicio();
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;

    for (int i = 0; i < medico.getCitasPorDia(); i++) {
        minActual += medico.getMinutosDeAtencionxPaciente();
        if (minActual == 60) {
            horaActual += 1;
            minActual = 0;
        }
        gbc.gridy = i + 1;
        System.out.print(String.format("%02d", horaInicio));
        citas[i] = new Citas(
                ("" + String.format("%02d", horaInicio) + ":" + String.format("%02d", minInicio) + " - "
                        + String.format("%02d", horaActual) + ":" + String.format("%02d", minActual)),
                ("" + String.format("%02d", horaInicio) + ":" + String.format("%02d", minInicio) + ":"
                        + String.format("%02d", 0)));
        citas[i].setBorder(BorderFactory.createLineBorder(Color.black));
        citas[i].setOpaque(true);
        citas[i].addMouseListener(new MouseListener() {
            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }

            @Override
            public void mouseClicked(MouseEvent e) {
                fechaJ.setText(jCalendar1.getDate().toString());
                fechaJ.setEnabled(true);
                acciones(null);
            }
        });
        PanelCita.add(citas[i], gbc);
        System.out.print(i);
        horaInicio = horaActual;
        minInicio = minActual;
    }

}

From source file:org.richie.codeGen.ui.GenAndPreviewUI.java

/**
 * table cell/*from  w ww  .  j a va  2s.  c o m*/
 */
private void addTableListener() {
    table.addMouseListener(new MouseListener() {

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            int col = table.getSelectedColumn();
            int row = table.getSelectedRow();
            if (col == 1) {
                List<CodeTemplateVo> list = complateModel.getTemplateList();
                CodeTemplateVo vo = list.get(row);
                try {
                    vo = GlobalData.getTemplateByName(vo.getTemplateName());
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
                table.updateUI();
            } else if (col == 7) {
                List<CodeTemplateVo> list = complateModel.getTemplateList();
                if (list != null && list.size() > 0) {
                    CodeTemplateVo vo = list.get(row);
                    previewCode(vo);
                }
            } else if (col == 9) {
                complateModel.removeRow(row);
                table.updateUI();
            }
        }
    });
}