List of usage examples for javax.swing SwingUtilities getRoot
@SuppressWarnings("deprecation") public static Component getRoot(Component c)
From source file:ffx.ui.MainPanel.java
/** * <p>/*from w ww .j a v a 2s.c om*/ * platformLookAndFeel</p> */ public void platformLookAndFeel() { try { if (SystemUtils.IS_OS_LINUX) { UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); } else { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this)); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { logger.log(Level.WARNING, "Can''t set look and feel: {0}", e); } }
From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java
/** * Implementation of the mouse move. The mouse is moved into the graphics component. * @param graphicsComponent The component to move to * @param constraints The more specific constraints. Use this, for example * when you want the click point to be relative to a part * of the component (e.g. tree node, table cell, etc) * rather than the overall component itself. May be * <code>null</code>. * @param xPos xPos in component * @param yPos yPos in component/* w ww . j a va2 s . co m*/ * @param xAbsolute true if x-position should be absolute * @param yAbsolute true if y-position should be absolute * @param clickOptions The click options * @throws StepExecutionException If the click delay is interrupted or the * event confirmation receives a timeout. */ private void moveImpl(Object graphicsComponent, final Rectangle constraints, final int xPos, final boolean xAbsolute, final int yPos, final boolean yAbsolute, ClickOptions clickOptions) throws StepExecutionException { if (clickOptions.isScrollToVisible()) { ensureComponentVisible((Component) graphicsComponent, constraints); m_eventFlusher.flush(); } Component component = (Component) graphicsComponent; Rectangle bounds = null; bounds = new Rectangle(getLocation(component, new Point(0, 0))); bounds.width = component.getWidth(); bounds.height = component.getHeight(); if (constraints != null) { bounds.x += constraints.x; bounds.y += constraints.y; bounds.height = constraints.height; bounds.width = constraints.width; } Point p = PointUtil.calculateAwtPointToGo(xPos, xAbsolute, yPos, yAbsolute, bounds); // Move if necessary if (isMouseMoveRequired(p)) { if (log.isDebugEnabled()) { log.debug("Moving mouse to: " + p); //$NON-NLS-1$ } IRobotEventConfirmer confirmer = null; if (clickOptions.isConfirmClick()) { InterceptorOptions options = new InterceptorOptions( new long[] { AWTEvent.MOUSE_MOTION_EVENT_MASK }); confirmer = m_interceptor.intercept(options); } Point startpoint = m_mouseMotionTracker.getLastMousePointOnScreen(); if (startpoint == null) { // If there is no starting point the center of the root component is used Component root = SwingUtilities.getRoot(component); Component c = (root != null) ? root : component; startpoint = getLocation(c, null); } Point[] mouseMove = MouseMovementStrategy.getMovementPath(startpoint, p, clickOptions.getStepMovement(), clickOptions.getFirstHorizontal()); for (int i = 0; i < mouseMove.length; i++) { m_robot.mouseMove(mouseMove[i].x, mouseMove[i].y); m_eventFlusher.flush(); } if (confirmer != null) { confirmer.waitToConfirm(component, new MouseMovedAwtEventMatcher()); } } }
From source file:org.openconcerto.erp.core.finance.accounting.element.AnalytiqueSQLElement.java
private void actionModifierAxe(MouseEvent e, final int index) { if (index == -1) return;/*from ww w. ja v a 2s .c o m*/ Component comp = (Component) e.getSource(); JFrame frame = (JFrame) SwingUtilities.getRoot(comp); this.windowChangeNom = new JWindow(frame); Container container = this.windowChangeNom.getContentPane(); container.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.insets = new Insets(0, 0, 0, 0); c.weightx = 1; this.editedAxeIndex = index; this.text = new JTextField(" " + this.tabAxes.getTitleAt(index) + " "); this.text.setEditable(true); container.add(this.text, c); this.text.setBorder(null); // text.setBackground(this.tabAxes.getBackground()); this.text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_ENTER) { validAxeText(); } } }); this.windowChangeNom.pack(); int ecartY = this.tabAxes.getBoundsAt(index).height - this.text.getBounds().height + 2; int ecartX = this.tabAxes.getBoundsAt(index).width - this.text.getBounds().width; this.windowChangeNom.setLocation( comp.getLocationOnScreen().x + this.tabAxes.getBoundsAt(index).getLocation().x + ecartX / 2, comp.getLocationOnScreen().y + this.tabAxes.getBoundsAt(index).getLocation().y + ecartY / 2); this.windowChangeNom.setVisible(true); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.BilanPanel.java
public BilanPanel() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.add(new JLabel("Vous allez gnrer le fichier result_2033A.pdf contenant le bilan simplifi."), c); c.gridy++;/*from www . j ava 2s. c o m*/ try { this.add(new JLabel("Il se trouvera dans le dossier " + new File(TemplateNXProps.getInstance().getStringProperty("Location2033APDF")) .getCanonicalPath()), c); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } /* * PdfGenerator_2033A p = new PdfGenerator_2033A(); p.generateFrom(new * Map2033A().getMap2033A()); */ JButton buttonFermer = new JButton("Fermer"); buttonFermer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(BilanPanel.this)).dispose(); } }); JButton buttonOuvrirDossier = new JButton("Ouvrir dossier"); buttonOuvrirDossier.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String file = TemplateNXProps.getInstance().getStringProperty("Location2033APDF"); File f = new File(file); FileUtils.browseFile(f); }; }); // FIXME impossible de gnrer si le fichier est ouvert JButton buttonGenerer = new JButton("Gnrer"); buttonGenerer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Map2033A map = new Map2033A(new JProgressBar()); map.generateMap2033A(); }; }); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 0; c.fill = GridBagConstraints.NONE; this.add(buttonOuvrirDossier, c); c.gridy++; c.anchor = GridBagConstraints.EAST; c.weightx = 1; buttonGenerer.setHorizontalAlignment(SwingConstants.RIGHT); this.add(buttonGenerer, c); c.weightx = 0; this.add(buttonFermer, c); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.ClotureMensuellePayePanel.java
public ClotureMensuellePayePanel() { super();//from w w w . j a va 2 s . com this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(2, 2, 1, 2); c.weightx = 0; c.weighty = 0; c.gridheight = 1; c.gridwidth = 1; c.gridx = 0; c.gridy = 0; JLabel labelMois = new JLabel("Cloture du mois de "); this.add(labelMois, c); final ElementComboBox selMois = new ElementComboBox(true, 25); selMois.init(((ComptaPropsConfiguration) Configuration.getInstance()).getDirectory() .getElement(MoisSQLElement.class)); selMois.setButtonsVisible(false); c.gridx++; this.add(selMois, c); JLabel labelAnnee = new JLabel("Anne"); c.gridx++; this.add(labelAnnee, c); final JTextField textAnnee = new JTextField(5); c.gridx++; this.add(textAnnee, c); DateFormat format = new SimpleDateFormat("yyyy"); textAnnee.setText(format.format(new Date())); c.gridy++; c.gridx = 0; final JCheckBox boxValid = new JCheckBox("Valider toutes les payes du mois"); final JCheckBox boxCompta = new JCheckBox("Gnrer les critures comptables associes"); c.gridwidth = GridBagConstraints.REMAINDER; this.add(boxValid, c); boxValid.setSelected(true); c.gridy++; this.add(boxCompta, c); JButton buttonClot = new JButton("Clturer"); JButton buttonFermer = new JButton("Fermer"); JPanel panelButton = new JPanel(); panelButton.add(buttonClot); panelButton.add(buttonFermer); c.anchor = GridBagConstraints.SOUTHEAST; c.fill = GridBagConstraints.NONE; c.weighty = 1; c.gridy++; this.add(panelButton, c); buttonFermer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(ClotureMensuellePayePanel.this)).dispose(); } }); buttonClot.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // Valider les fiches non valids des salaris actifs if (boxValid.isSelected()) { SQLSelect selFiche = new SQLSelect(); SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE"); SQLTable tableSalarie = ClotureMensuellePayePanel.this.base.getTable("SALARIE"); SQLTable tableInfosSal = ClotureMensuellePayePanel.this.base.getTable("INFOS_SALARIE_PAYE"); selFiche.addSelect(tableFiche.getField("ID")); selFiche.setWhere(new Where(tableFiche.getField("VALIDE"), "=", Boolean.FALSE)); selFiche.andWhere(new Where(tableFiche.getField("ID_MOIS"), "=", selMois.getSelectedId())); selFiche.andWhere( new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText()))); selFiche.andWhere( new Where(tableSalarie.getField("ID"), "=", tableFiche.getField("ID_SALARIE"))); selFiche.andWhere(new Where(tableInfosSal.getField("ID"), "=", tableSalarie.getField("ID_INFOS_SALARIE_PAYE"))); // FIXME ne pas valider les fiches d'un employ renvoy // Where w2 = new Where(tableInfosSal.getField("DATE_SORTIE"), "IS", // "NULL"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DATE, 1); cal.set(Calendar.MONTH, selMois.getSelectedId() - 2); cal.set(Calendar.YEAR, Integer.parseInt(textAnnee.getText())); cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE)); Where w = new Where(tableInfosSal.getField("DATE_SORTIE"), "<=", cal.getTime()); w = w.or(new Where(tableInfosSal.getField("DATE_SORTIE"), "=", (Object) null)); selFiche.andWhere(w); String req = selFiche.asString(); System.err.println(req); List l = (List) ClotureMensuellePayePanel.this.base.getDataSource().execute(req, new ArrayListHandler()); for (int i = 0; i < l.size(); i++) { Object[] tmp = (Object[]) l.get(i); SQLRow rowFicheTmp = tableFiche.getRow(Integer.parseInt(tmp[0].toString())); System.err.println(rowFicheTmp); FichePayeSQLElement.validationFiche(rowFicheTmp.getID()); } } // cloture du mois et generation compta SQLSelect selFiche = new SQLSelect(ClotureMensuellePayePanel.this.base); SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE"); SQLTable tableMois = ClotureMensuellePayePanel.this.base.getTable("MOIS"); selFiche.addSelect(tableFiche.getField("ID")); selFiche.setWhere(new Where(tableFiche.getField("VALIDE"), "=", Boolean.TRUE)); selFiche.andWhere(new Where(tableFiche.getField("ID_MOIS"), "=", selMois.getSelectedId())); selFiche.andWhere( new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText()))); String req = selFiche.asString(); List l = (List) ClotureMensuellePayePanel.this.base.getDataSource().execute(req, new ArrayListHandler()); if (l != null && l.size() > 0) { int[] idS = new int[l.size()]; SQLRow rowMois = tableMois.getRow(selMois.getSelectedId()); for (int i = 0; i < l.size(); i++) { Object[] tmp = (Object[]) l.get(i); idS[i] = Integer.parseInt(tmp[0].toString()); SQLRow rowFiche = tableFiche.getRow(idS[i]); FichePayeSQLElement.clotureMensuelle(selMois.getSelectedId(), Integer.parseInt(textAnnee.getText()), rowFiche.getInt("ID_SALARIE")); } if (boxCompta.isSelected()) { new GenerationMvtFichePaye(idS, rowMois.getString("NOM"), textAnnee.getText()); } } System.err.println( "ClotureMensuellePayePanel.ClotureMensuellePayePanel().new ActionListener() {...}.actionPerformed()"); JOptionPane.showMessageDialog(null, "Clture termine"); } catch (Exception ex) { ExceptionHandler.handle("Unable to complete operation", ex); } } }); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.CloturePanel.java
public CloturePanel() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.gridx = 0;/* ww w . j a v a 2 s. co m*/ c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.weightx = 0; c.weighty = 0; JLabel rappel = new JLabelBold("Oprations effectuer avant de continuer: "); JLabel label = new JLabel("- report des charges et produits constats d'avance"); JLabel label2 = new JLabel("- report des charges payer et produits recevoir"); JLabel label3 = new JLabel("- impression du bilan, compte de rsultat, grand livre, journaux et balance"); JLabel label5 = new JLabel("- gnration les critures comptables des payes"); JLabel label4 = new JLabel("Il est prfrable de raliser une sauvegarde avant de continuer."); JLabel op = new JLabelBold("Oprations qui vont etre effectues: "); JLabel labelValid = new JLabel( "- validation de toutes les critures concernant la priode de l'exercice."); JLabel labelSoldeGestion = new JLabel("- soldes de tous les comptes de gestions 6* et 7*"); JLabel labelSoldeBilan = new JLabel("- soldes de tous les comptes de bilan"); JLabel labelAN = new JLabel("- report des nouveaux"); c.gridy = GridBagConstraints.RELATIVE; c.gridx = 0; // Date de l'ancien exercice Calendar dDebut = this.rowExercice.getDate("DATE_DEB"); Calendar dFin = this.rowExercice.getDate("DATE_FIN"); JLabel labelAncienExercice = new JLabel("Clture de l'exercice du " + dateFormat.format(dDebut.getTime()) + " au " + dateFormat.format(dFin.getTime())); this.add(labelAncienExercice, c); c.insets = new Insets(10, 2, 1, 2); this.add(rappel, c); this.add(label, c); this.add(label2, c); this.add(label3, c); this.add(label5, c); this.add(label4, c); c.insets = new Insets(15, 2, 1, 2); this.add(op, c); c.insets = new Insets(10, 2, 1, 2); this.add(labelValid, c); this.add(labelSoldeGestion, c); this.add(labelSoldeBilan, c); this.add(labelAN, c); // Date du prochain exercice c.gridwidth = 1; c.gridy = GridBagConstraints.RELATIVE; c.gridx = 0; c.gridx = GridBagConstraints.RELATIVE; c.fill = GridBagConstraints.NONE; this.add(new JLabel("Date du nouvel exercice du "), c); dDebut.set(Calendar.YEAR, dDebut.get(Calendar.YEAR) + 1); this.dateOuv.setValue(dDebut.getTime()); this.add(this.dateOuv, c); this.add(new JLabel("au"), c); dFin.set(Calendar.YEAR, dFin.get(Calendar.YEAR) + 1); this.dateFerm.setValue(dFin.getTime()); this.add(this.dateFerm, c); c.gridx = 0; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = 2; c.weightx = 1; this.add(this.opEnCours, c); c.gridwidth = 4; c.gridx = 0; c.weightx = 1; this.add(this.bar, c); // this.add(this.boxValid, c); // Button final JPanel buttonBar = new JPanel(); buttonBar.add(this.valider); buttonBar.add(this.annul); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; c.gridx = 0; this.add(buttonBar, c); final PropertyChangeListener listener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { CloturePanel.this.valider.setEnabled(isDateValid()); } }; this.dateFerm.addValueListener(listener); this.dateOuv.addValueListener(listener); // TODO afficher le deroulement de etapes apres validation this.valider.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { clotureExercice(); // show OK works fine Component comp = SwingUtilities.getRoot(CloturePanel.this); JOptionPane.showMessageDialog(CloturePanel.this, "Exercice cltur", "Fin de la clture", JOptionPane.INFORMATION_MESSAGE); ((JFrame) comp).dispose(); } catch (Exception ex) { ExceptionHandler.handle("Erreur lors de la clture", ex); } } }); this.valider.setEnabled(isDateValid()); this.boxValid.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CloturePanel.this.valider.setEnabled(isDateValid()); } }); this.annul.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(CloturePanel.this)).dispose(); } }); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java
public EtatJournauxPanel() { super();//from ww w . ja va 2 s .com this.tabbedJournaux = new JTabbedPane(); this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.NORTHWEST; c.gridwidth = 2; c.gridheight = 1; c.weightx = 1; c.weighty = 1; this.add(this.tabbedJournaux, c); JButton buttonImpression = new JButton("Impression"); JButton buttonClose = new JButton("Fermer"); c.gridx = 0; c.gridy++; c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; this.add(buttonImpression, c); c.gridx++; c.weightx = 0; this.add(buttonClose, c); buttonClose.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(EtatJournauxPanel.this)).dispose(); }; }); buttonImpression.addActionListener(new ImpressionJournauxAction()); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java
private JPanel creerJournalMoisPanel(final Date date, long debit, long credit, final Journal jrnl) { final JPanel panelMoisCompte = new JPanel(); panelMoisCompte.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0;/* w w w . java 2s .co m*/ c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; panelMoisCompte.setBorder(BorderFactory.createTitledBorder(dateFormat.format(date))); // Date du mois panelMoisCompte.add(new JLabel(dateFormat.format(date)), c); // Totaux du mois c.gridx++; panelMoisCompte.add(new JLabel(" dbit : " + GestionDevise.currencyToString(debit)), c); c.gridx++; panelMoisCompte.add(new JLabel(" crdit : " + GestionDevise.currencyToString(credit)), c); // Bouton dtails JButton boutonShow = new JButton("+/-"); boutonShow.setOpaque(false); boutonShow.setHorizontalAlignment(SwingConstants.LEFT); c.weightx = 0; c.gridx++; panelMoisCompte.add(boutonShow, c); boutonShow.addActionListener(new ActionListener() { private boolean isShow = false; private ListPanelEcritures listEcriture; public void actionPerformed(ActionEvent e) { System.err.println(this.isShow); // Afficher la JTable du compte if (!this.isShow) { final SQLElement element = Configuration.getInstance().getDirectory().getElement("ECRITURE"); final SQLTable ecrTable = element.getTable(); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.DATE, 1); Date inf = cal.getTime(); cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE)); Date sup = cal.getTime(); System.out.println("Inf : " + inf + " Sup : " + sup); Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", jrnl.getId()); Where w2 = new Where(ecrTable.getField("DATE"), inf, sup); if (!UserManager.getInstance().getCurrentUser().getRights() .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) { // TODO Show Restricted acces in UI w = w.and(new Where(ecrTable.getField("COMPTE_NUMERO"), "LIKE", "411%")); } this.listEcriture = new ListPanelEcritures(element, w.and(w2)); this.listEcriture.setModificationVisible(false); this.listEcriture.setAjoutVisible(false); this.listEcriture.setSuppressionVisible(false); this.listEcriture.getListe().setSQLEditable(false); Dimension d; // Taille limite 200 maximum if (this.listEcriture.getListe().getPreferredSize().height > 200) { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, 200); } else { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, this.listEcriture.getListe().getPreferredSize().height + 30); } this.listEcriture.getListe().setPreferredSize(d); // c.gridy = 2; c.gridx = 0; c.gridy = 1; c.gridwidth = 4; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; this.listEcriture.getListe().setSQLEditable(false); panelMoisCompte.add(this.listEcriture, c); this.listEcriture.getListe().getJTable().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { JPopupMenu menu = new JPopupMenu(); menu.add(new AbstractAction("Voir la source") { public void actionPerformed(ActionEvent e) { SQLRow row = base.getTable("ECRITURE") .getRow(listEcriture.getListe().getSelectedId()); MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT")); } }); menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y); } } }); } else { panelMoisCompte.remove(this.listEcriture); System.out.println("Hide ListEcriture"); panelMoisCompte.repaint(); panelMoisCompte.revalidate(); } this.isShow = !this.isShow; SwingUtilities.getRoot(panelMoisCompte).repaint(); } }); return panelMoisCompte; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java
public GrandLivrePanel() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.weightx = 1;/*from w w w . j a v a 2s . co m*/ this.tabbedClasse = new JTabbedPane(); c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; c.gridx = 0; c.gridy = 0; c.gridwidth = 2; this.add(this.tabbedClasse, c); JButton buttonImpression = new JButton("Impression"); JButton buttonClose = new JButton("Fermer"); c.gridx = 0; c.gridy++; c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; this.add(buttonImpression, c); c.gridx++; c.weightx = 0; this.add(buttonClose, c); buttonClose.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(GrandLivrePanel.this)).dispose(); }; }); buttonImpression.addActionListener(new ImpressionGrandLivreAction()); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java
private JPanel creerComptePanel(final Compte compte) { final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = GridBagConstraints.RELATIVE; c.gridy = 0;/* w ww . jav a 2 s . co m*/ c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; // Intitul du compte final JPanel panelCompte = new JPanel(); panelCompte.setOpaque(false); panelCompte.setLayout(new GridBagLayout()); panelCompte.setBorder(BorderFactory.createTitledBorder(compte.getNumero() + " " + compte.getNom())); // Bouton Dtails +/- du compte JButton boutonShow = new JButton("+/-"); boutonShow.setOpaque(false); boutonShow.setHorizontalAlignment(SwingConstants.RIGHT); // Total du Compte JLabel labelCompteDebit = new JLabel( "Total Debit : " + GestionDevise.currencyToString(compte.getTotalDebit())); JLabel labelCompteCredit = new JLabel( " Credit : " + GestionDevise.currencyToString(compte.getTotalCredit())); // labelCompte.setFont(new Font(labelCompte.getFont().getFontName(), Font.BOLD, 12)); labelCompteDebit.setHorizontalAlignment(SwingUtilities.LEFT); labelCompteCredit.setHorizontalAlignment(SwingUtilities.LEFT); JLabel labelTmp = new JLabel(compte.getNumero() + " " + compte.getNom()); labelTmp.setHorizontalAlignment(SwingUtilities.LEFT); panelCompte.add(labelTmp, c); panelCompte.add(labelCompteDebit, c); panelCompte.add(labelCompteCredit, c); c.weightx = 1; c.anchor = GridBagConstraints.NORTHEAST; panelCompte.add(boutonShow, c); boutonShow.addActionListener(new ActionListener() { private boolean isShow = false; private JScrollPane scroll = null; public void actionPerformed(ActionEvent e) { System.err.println(this.isShow); // Afficher la JTable du compte if (!this.isShow) { // if (this.scroll == null) { System.err.println(compte); JTable tableCpt = createJTableCompte(compte); this.scroll = new JScrollPane(tableCpt); // calcul de la taille du JScrollPane Dimension d; System.err.println(tableCpt); if (tableCpt.getPreferredSize().height > 200) { d = new Dimension(this.scroll.getPreferredSize().width, 200); } else { d = new Dimension(this.scroll.getPreferredSize().width, tableCpt.getPreferredSize().height + 30); } this.scroll.setPreferredSize(d); c.gridy++; c.gridwidth = 4; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; panelCompte.add(this.scroll, c); /* * } else { this.scroll.setVisible(true); } */ } else { // if (this.scroll != null) { panelCompte.remove(this.scroll); System.out.println("Hide scrollPane"); // this.scroll.setVisible(false); // this.scroll.repaint(); panelCompte.repaint(); panelCompte.revalidate(); // } } this.isShow = !this.isShow; SwingUtilities.getRoot(panelCompte).repaint(); } }); return panelCompte; }