Example usage for java.awt.event MouseEvent getComponent

List of usage examples for java.awt.event MouseEvent getComponent

Introduction

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

Prototype

public Component getComponent() 

Source Link

Document

Returns the originator of the event.

Usage

From source file:brainflow.app.toplevel.BrainFlow.java

private void showActionMenu(MouseEvent e) {
    Component c = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
    java.util.List<Action> actionList = new ArrayList<Action>();
    while (true) {
        if (c instanceof IActionProvider) {
            IActionProvider provider = (IActionProvider) c;
            provider.addActions(e, actionList);
        } else if (c instanceof JComponent) {
            JComponent jc = (JComponent) c;

            Object provider = jc.getClientProperty(IActionProvider.KEY);
            if (provider != null) {
                ((IActionProvider) provider).addActions(e, actionList);
            }/*from  w w w.ja  v a2  s. c  om*/
        }

        Component p = c.getParent();
        if (p != null) {
            c = p;
        } else {
            break;
        }

    }

    if (actionList.size() > 0) {
        createPopup(actionList).setVisible(true);
    }

}

From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java

/**
 * Cree un JTable contenant les ecritures du compte pass en argument
 * //from ww w .j  a  va2 s . c o  m
 * @param compte
 * @return null si aucune ecriture
 */
private JTable createJTableCompte(Compte compte) {

    // on cree la JTable
    final JTable tableTmp = creerJTable(compte);

    if (tableTmp != null) {

        // On met en place le renderer
        EcritureGrandLivreRenderer ecritureRenderer = new EcritureGrandLivreRenderer(
                ((TableSorter) tableTmp.getModel()));

        for (int j = 0; j < tableTmp.getColumnCount(); j++) {
            tableTmp.getColumnModel().getColumn(j).setCellRenderer(ecritureRenderer);
        }

        // Gestion de la souris sur la JTable
        tableTmp.addMouseListener(new MouseAdapter() {

            public void mousePressed(final MouseEvent mE) {

                if (mE.getButton() == MouseEvent.BUTTON3) {
                    JPopupMenu menuDroit = new JPopupMenu();

                    menuDroit.add(new AbstractAction("Voir la source") {

                        public void actionPerformed(ActionEvent e) {
                            int row = tableTmp.rowAtPoint(mE.getPoint());

                            TableSorter s = (TableSorter) tableTmp.getModel();

                            int modelIndex = s.modelIndex(row);
                            ConsultCompteModel consultCompteModel = ((ConsultCompteModel) s.getTableModel());
                            Ecriture ecriture = consultCompteModel.getEcritures().get(modelIndex);

                            MouvementSQLElement.showSource(ecriture.getIdMvt());

                        }
                    });
                    menuDroit.show(mE.getComponent(), mE.getX(), mE.getY());
                }
            }
        });

    }
    return tableTmp;
}

From source file:org.yccheok.jstock.gui.charting.InvestmentFlowLayerUI.java

private void processEvent(MouseEvent e, JXLayer layer) {
    if (MouseEvent.MOUSE_DRAGGED == e.getID()) {
        return;/* www  . ja  v  a  2  s  .c  o  m*/
    }

    if (MouseEvent.MOUSE_CLICKED == e.getID()) {
        // Transfer focus to chart if user clicks on the chart.
        this.investmentFlowChartJDialog.getChartPanel().requestFocus();
    }

    final Point mousePoint = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), layer);

    final boolean status0 = this.updateInvestPoint(mousePoint);
    final boolean status1 = this.updateROIPoint(mousePoint);

    if (status0 || status1) {
        this.setDirty(true);
    }
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopTree.java

public DesktopTree() {
    layout = new MigLayout("flowy, fill, insets 0", "", "[min!][fill]");
    panel = new JPanel(layout);

    topPanel = new JPanel(new BorderLayout());
    topPanel.setVisible(false);/*ww w  .  j  a  va2 s.  c  om*/
    panel.add(topPanel, "growx");

    impl = new JTree();
    treeView = new JScrollPane(impl);
    panel.add(treeView, "grow");

    impl.setRootVisible(false);
    impl.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    impl.setExpandsSelectedPaths(true);

    impl.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            showPopup(e);
        }

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

        private void showPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                // select row
                Point p = e.getPoint();
                TreePath treePath = impl.getPathForLocation(p.x, p.y);
                if (treePath != null) {
                    TreeSelectionModel model = impl.getSelectionModel();
                    model.setSelectionPath(treePath);
                }
                // show popup menu
                createPopupMenu().show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });

    impl.addKeyListener(new KeyAdapter() {
        protected static final int ENTER_CODE = 10;

        @Override
        public void keyPressed(KeyEvent e) {
            if (ENTER_CODE == e.getKeyCode() && e.getComponent() == DesktopTree.this.getComponent()) {
                if (enterPressAction != null) {
                    enterPressAction.actionPerform(DesktopTree.this);
                } else {
                    handleClickAction();
                }
            }
        }
    });
}

From source file:edu.ku.brc.af.ui.forms.ResultSetController.java

/**
 * Creates the UI for the controller.//  ww w.j a v  a2 s .  co  m
 * @param addNewBtn indicates it should include the "Add" (New Object) button
 * @param addDelBtn indicates it should include Delete button
 * @param objTitle the title of a single object in the controller (used for building tooltips)
 */
protected void buildRecordNavBar(final boolean addNewBtn, final boolean addDelBtn, final boolean addSearchBtn,
        final String objTitle) {
    String colDef = "p,2dlu,p,2dlu,max(50dlu;p):grow,2dlu,p,2dlu,p" + (addNewBtn ? ",12px,p" : "")
            + (addDelBtn ? ",2dlu,p" : "") + (addSearchBtn ? ",2dlu,p" : "");

    Insets insets = new Insets(1, 1, 1, 1);
    DefaultFormBuilder rowBuilder = new DefaultFormBuilder(new FormLayout(colDef, "p"));

    firstBtn = UIHelper.createIconBtn("FirstRec", null, null);
    prevBtn = UIHelper.createIconBtn("PrevRec", null, null);
    btnsHash.put(CommandType.Previous, prevBtn);
    btnsHash.put(CommandType.First, firstBtn);

    recDisp = createLabel("  ");
    recDisp.setHorizontalAlignment(SwingConstants.CENTER);
    recDisp.setOpaque(true);
    recDisp.setBackground(Color.WHITE);
    recDisp.setBorder(enabledBorder);
    recDisp.setFont(recDisp.getFont().deriveFont(recDisp.getFont().getSize2D() - 2));

    MouseListener mouseListener = new MouseAdapter() {
        private boolean showIfPopupTrigger(MouseEvent mouseEvent) {
            if (mouseEvent.isPopupTrigger()) {
                JPopupMenu popupMenu = createPopupMenu();
                if (popupMenu != null && popupMenu.getComponentCount() > 0) {
                    popupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
                    return true;
                }
            }
            return false;
        }

        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            showIfPopupTrigger(mouseEvent);
        }

        @Override
        public void mouseReleased(MouseEvent mouseEvent) {
            showIfPopupTrigger(mouseEvent);
        }

        /* (non-Javadoc)
         * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
         */
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                if (numRecords == 1) {
                    UIRegistry.writeTimedSimpleGlassPaneMsg(getResourceString("OnlyOneRrecordInCon"));
                } else {
                    showGotoRecDlg();
                }
            }
        }
    };
    recDisp.addMouseListener(mouseListener);

    nextBtn = UIHelper.createIconBtn("NextRec", null, null);
    lastBtn = UIHelper.createIconBtn("LastRec", null, null);
    btnsHash.put(CommandType.Next, nextBtn);
    btnsHash.put(CommandType.Last, lastBtn);

    firstBtn.setToolTipText(createTooltip("GotoFirstRecordTT", objTitle));
    prevBtn.setToolTipText(createTooltip("GotoPreviousRecordTT", objTitle));
    nextBtn.setToolTipText(createTooltip("GotoNextRecordTT", objTitle));
    lastBtn.setToolTipText(createTooltip("GotoLastRecordTT", objTitle));

    firstBtn.setOpaque(false);
    prevBtn.setOpaque(false);
    nextBtn.setOpaque(false);
    lastBtn.setOpaque(false);

    CellConstraints cc = new CellConstraints();
    rowBuilder.add(firstBtn, cc.xy(1, 1));
    rowBuilder.add(prevBtn, cc.xy(3, 1));
    rowBuilder.add(recDisp, cc.xy(5, 1));
    rowBuilder.add(nextBtn, cc.xy(7, 1));
    rowBuilder.add(lastBtn, cc.xy(9, 1));
    int col = 11;

    if (addNewBtn) {
        if (false) {
            newRecBtn = new JButton("+") {
                public void setEnabled(boolean enable) {
                    //log.debug("newRecBtn - RS: "+ formValidator.getName() + " " + newRecBtn.hashCode() + " "+enable+"  isNewObj: "+isNewObj);
                    if (formValidator != null && formValidator.getName() != null
                            && formValidator.getName().equals("Collection Object")) {
                        int x = 0;
                        x++;
                        if (enable) {
                            int y = 0;
                            y++;
                        }
                    }
                    if (enable) {
                        int x = 0;
                        x++;
                    }
                    super.setEnabled(enable);
                }
            };
            setControlSize(newRecBtn);

            ActionListener l = new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    for (ResultSetControllerListener rscl : listeners) {
                        rscl.newRecordAdded();
                    }
                }
            };
            newRecBtn.addActionListener(l);

        } else {
            newRecBtn = UIHelper.createIconBtn("NewRecord", null, new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    for (ResultSetControllerListener rscl : listeners) {
                        rscl.newRecordAdded();
                    }
                }
            });
        }

        newRecBtn.setToolTipText(createTooltip("NewRecordTT", objTitle));
        newRecBtn.setEnabled(true);
        newRecBtn.setMargin(insets);
        btnsHash.put(CommandType.NewItem, newRecBtn);

        if (doLayoutBtns) {
            rowBuilder.add(newRecBtn, cc.xy(col, 1));
            col += 2;
        }
    }

    if (addDelBtn) {
        if (false) {
            delRecBtn = new JButton("-") {
                public void setEnabled(boolean enable) {
                    //log.debug("delRecBtn - RS: "+formValidator.getName() + " " + hashCode() + " "+enable);
                    if (formValidator != null && formValidator.getName() != null
                            && formValidator.getName().equals("Permit")) {
                        int x = 0;
                        x++;
                    }
                    if (!enable) {
                        int x = 0;
                        x++;
                    }
                    super.setEnabled(enable);
                }
            };
        } else {
            delRecBtn = UIHelper.createIconBtn("DeleteRecord", null, null);
        }
        delRecBtn.setToolTipText(createTooltip("DeleteRecordTT", objTitle));
        delRecBtn.setMargin(insets);
        btnsHash.put(CommandType.DelItem, delRecBtn);

        if (doLayoutBtns) {
            rowBuilder.add(delRecBtn, cc.xy(col, 1));
            col += 2;
        }
    }

    if (addSearchBtn) {
        searchRecBtn = UIHelper.createIconBtn("Search", IconManager.IconSize.Std16, null, null);
        searchRecBtn.setToolTipText(createTooltip("SearchForRecordTT", objTitle));
        searchRecBtn.setMargin(insets);

        if (doLayoutBtns) {
            rowBuilder.add(searchRecBtn, cc.xy(col, 1));
            col += 2;
        }
    }

    firstBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            firstRecord();
        }
    });
    prevBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            prevRecord();
        }
    });
    nextBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            nextRecord();
        }
    });
    lastBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            lastRecord();
        }
    });

    // Make sure it gets centered
    rowBuilder.getPanel().setOpaque(false);
    DefaultFormBuilder outerCenteredPanel = new DefaultFormBuilder(new FormLayout("c:p:g", "p"));
    outerCenteredPanel.add(rowBuilder.getPanel(), cc.xy(1, 1));
    panel = outerCenteredPanel.getPanel();
    panel.setOpaque(false);
}

From source file:game.Clue.ClueGameUI.java

public void mousePressed(MouseEvent e) {
    //player=null;
    Component j = e.getComponent();
    //System.out.println("Click component is : \n"+j.toString()+"\n "+(e.getSource().toString());
    Component c = gameBoard.findComponentAt(e.getX(), e.getY());
    if (c instanceof JPanel) {
        System.out.println("No character chosen");
        return;//ww w  .j a  v a 2 s .  co  m
    }

    Point parentLocation = c.getParent().getLocation();
    xAdjustment = parentLocation.x - e.getX();
    yAdjustment = parentLocation.y - e.getY();
    player = (JLabel) c;
    previous_room_x = parentLocation.x + xAdjustment;
    previous_room_y = parentLocation.y + yAdjustment;
    player.setLocation(e.getX() + xAdjustment, e.getY() + yAdjustment);
    player.setSize(player.getWidth(), player.getHeight());
    jLayeredPane5.add(player, JLayeredPane.DRAG_LAYER);

}

From source file:org.parosproxy.paros.view.SiteMapPanel.java

/**
 * This method initializes treeSite//from  w  w w  . j  a v a  2 s .  co m
 * 
 * @return JTree
 */
public JTree getTreeSite() {
    if (treeSite == null) {
        treeSite = new JTree();
        treeSite.setShowsRootHandles(true);
        treeSite.setName("treeSite");
        treeSite.setToggleClickCount(1);
        treeSite.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
                    // ZAP: Select site list item on right click
                    TreePath tp = treeSite.getPathForLocation(e.getPoint().x, e.getPoint().y);
                    if (tp != null) {
                        boolean select = true;
                        // Only select a new item if the current item is not
                        // already selected - this is to allow multiple items
                        // to be selected
                        if (treeSite.getSelectionPaths() != null) {
                            for (TreePath t : treeSite.getSelectionPaths()) {
                                if (t.equals(tp)) {
                                    select = false;
                                    break;
                                }
                            }
                        }
                        if (select) {
                            treeSite.getSelectionModel().setSelectionPath(tp);
                        }
                    }

                    View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
                }
            }
        });

        treeSite.addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
                HttpMessage msg = null;
                SiteNode node = (SiteNode) treeSite.getLastSelectedPathComponent();
                if (node == null) {
                    return;
                }
                if (!node.isRoot()) {
                    try {
                        msg = node.getHistoryReference().getHttpMessage();
                    } catch (Exception e1) {
                        // ZAP: Log exceptions
                        log.warn(e1.getMessage(), e1);
                        return;
                    }

                    HttpPanel reqPanel = getView().getRequestPanel();
                    HttpPanel resPanel = getView().getResponsePanel();
                    reqPanel.setMessage(msg, true);
                    resPanel.setMessage(msg, false);

                    // ZAP: Call SiteMapListenners
                    for (SiteMapListener listener : listenners) {
                        listener.nodeSelected(node);
                    }
                }
            }
        });
    }
    return treeSite;
}

From source file:edu.ku.brc.specify.tasks.RecordSetTask.java

/**
 * Adds the Context PopupMenu for the RecordSet.
 * @param roc the RolloverCommand btn to add the pop to
 *///from  w  w w .ja v  a  2  s. co m
public void addPopMenu(final RolloverCommand roc, final boolean isOKDelete, final boolean isOKModify) {
    if (roc.getLabelText() != null) {
        final JPopupMenu popupMenu = new JPopupMenu();

        if (isOKModify) {
            JMenuItem renameMenuItem = new JMenuItem(UIRegistry.getResourceString("Rename"));
            renameMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent actionEvent) {
                    roc.startEditting(RecordSetTask.this);
                }
            });
            popupMenu.add(renameMenuItem);
        }

        if (isOKDelete) {
            JMenuItem delMenuItem = new JMenuItem(UIRegistry.getResourceString("Delete"));
            delMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent actionEvent) {
                    CommandDispatcher.dispatch(new CommandAction(RECORD_SET, DELETE_CMD_ACT, roc));
                }
            });
            popupMenu.add(delMenuItem);
        }

        JMenuItem viewMenuItem = new JMenuItem(UIRegistry.getResourceString("View"));
        viewMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                CommandAction cmdAction = new CommandAction("Express_Search", "ViewRecordSet", roc);
                cmdAction.setProperty("canModify", isOKDelete);
                CommandDispatcher.dispatch(cmdAction);
            }
        });
        popupMenu.add(viewMenuItem);

        MouseListener mouseListener = new MouseAdapter() {
            private boolean showIfPopupTrigger(MouseEvent mouseEvent) {
                if (roc.isEnabled() && mouseEvent.isPopupTrigger() && popupMenu.getComponentCount() > 0) {
                    popupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
                    return true;
                }
                return false;
            }

            @Override
            public void mousePressed(MouseEvent mouseEvent) {
                if (roc.isEnabled()) {
                    showIfPopupTrigger(mouseEvent);
                }
            }

            @Override
            public void mouseReleased(MouseEvent mouseEvent) {
                if (roc.isEnabled()) {
                    showIfPopupTrigger(mouseEvent);
                }
            }
        };
        roc.addMouseListener(mouseListener);
    }
}

From source file:org.zaproxy.zap.extension.multiFuzz.impl.http.HttpFuzzerContentPanel.java

public JXTreeTable getFuzzResultTable() {
    if (fuzzResultTable == null) {
        resetFuzzResultTable();/*  w w  w  .  j a  va  2  s . c  o  m*/
        fuzzResultTable = new JXTreeTable(getResultsModel());
        fuzzResultTable.setName("HttpFuzzResultTable");
        fuzzResultTable.setDoubleBuffered(true);
        fuzzResultTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        fuzzResultTable.setFont(new java.awt.Font("Default", java.awt.Font.PLAIN, 12));
        fuzzResultTable.setDefaultRenderer(Pair.class, new IconTableCellRenderer());

        int[] widths = { 10, 25, 550, 30, 85, 55, 40, 70 };
        for (int i = 0, count = widths.length; i < count; i++) {
            TableColumn column = fuzzResultTable.getColumnModel().getColumn(i);
            column.setPreferredWidth(widths[i]);
        }
        fuzzResultTable.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            @Override
            public void mouseReleased(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            private void showPopupMenuIfTriggered(java.awt.event.MouseEvent e) {
                if (e.isPopupTrigger() && SwingUtilities.isRightMouseButton(e)) {
                    // Select list item on right click
                    JTable table = (JTable) e.getSource();
                    int row = table.rowAtPoint(e.getPoint());

                    if (!table.isRowSelected(row)) {
                        table.changeSelection(row, 0, false, false);
                    }
                    View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
                }
            }

        });

        fuzzResultTable.getSelectionModel()
                .addListSelectionListener(new javax.swing.event.ListSelectionListener() {

                    @Override
                    public void valueChanged(javax.swing.event.ListSelectionEvent e) {
                        if (!e.getValueIsAdjusting()) {
                            if (fuzzResultTable.getSelectedRowCount() == 0) {
                                return;
                            }
                            final int row = fuzzResultTable.getSelectedRow();
                            if (getEntry(row) instanceof HttpFuzzRequestRecord) {
                                final HistoryReference historyReference = ((HttpFuzzRequestRecord) getEntry(
                                        row)).getHistory();
                                try {
                                    displayMessage(historyReference.getHttpMessage());
                                } catch (HttpMalformedHeaderException | SQLException ex) {
                                    logger.error(ex.getMessage(), ex);
                                }
                            }
                        }
                    }
                });
        fuzzResultTable.getTableHeader().addMouseListener(new MouseListener() {
            int sortedOn = -1;

            @Override
            public void mouseReleased(MouseEvent arg0) {
            }

            @Override
            public void mousePressed(MouseEvent arg0) {
            }

            @Override
            public void mouseExited(MouseEvent arg0) {
            }

            @Override
            public void mouseEntered(MouseEvent arg0) {
            }

            @Override
            public void mouseClicked(MouseEvent e) {
                int index = fuzzResultTable.columnAtPoint(e.getPoint());
                List<HttpFuzzRecord> list = getResultsModel().getEntries();
                if (list.size() == 0) {
                    return;
                }
                HttpFuzzRecordComparator comp = new HttpFuzzRecordComparator();
                comp.setFeature(index);
                if (index == sortedOn) {
                    Collections.sort(list, comp);
                    Collections.reverse(list);
                    sortedOn = -1;
                } else {
                    Collections.sort(list, comp);
                    sortedOn = index;
                }
                fuzzResultTable.updateUI();
            }
        });
        fuzzResultTable.setRootVisible(false);
        fuzzResultTable.setVisible(true);
    }
    return fuzzResultTable;
}

From source file:Citas.FrameCita.java

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

    JSONArray citasporfecha;/*from  w w  w. 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();
}