List of usage examples for javax.swing SwingConstants RIGHT
int RIGHT
To view the source code for javax.swing SwingConstants RIGHT.
Click Source Link
From source file:org.javaswift.cloudie.CloudiePanel.java
public JMenuBar createMenuBar() { JMenuBar bar = new JMenuBar(); JMenu accountMenu = new JMenu("Account"); JMenu containerMenu = new JMenu("Container"); JMenu storedObjectMenu = new JMenu("StoredObject"); JMenu helpMenu = new JMenu("Help"); accountMenu.setMnemonic('A'); containerMenu.setMnemonic('C'); storedObjectMenu.setMnemonic('O'); helpMenu.setMnemonic('H'); bar.add(accountMenu);/*from w w w . j a v a 2s . c o m*/ bar.add(containerMenu); bar.add(storedObjectMenu); bar.add(helpMenu); JPanel panel = new JPanel(new FlowLayout(SwingConstants.RIGHT, 0, 0)); JLabel label = new JLabel(getIcon("zoom.png")); label.setLabelFor(searchTextField); label.setDisplayedMnemonic('f'); panel.add(label); panel.add(searchTextField); bar.add(panel); // accountMenu.add(new JMenuItem(accountLoginAction)); accountMenu.add(new JMenuItem(accountLogoutAction)); accountMenu.addSeparator(); accountMenu.add(new JMenuItem(accountQuitAction)); // containerMenu.add(new JMenuItem(containerRefreshAction)); containerMenu.add(new JMenuItem(containerViewMetaData)); containerMenu.addSeparator(); containerMenu.add(new JMenuItem(containerCreateAction)); containerMenu.add(new JMenuItem(containerDeleteAction)); containerMenu.addSeparator(); containerMenu.add(new JMenuItem(containerEmptyAction)); containerMenu.addSeparator(); containerMenu.add(new JMenuItem(containerPurgeAction)); // storedObjectMenu.add(new JMenuItem(storedObjectPreviewAction)); storedObjectMenu.add(new JMenuItem(storedObjectOpenAction)); storedObjectMenu.add(new JMenuItem(storedObjectViewMetaData)); storedObjectMenu.addSeparator(); storedObjectMenu.add(new JMenuItem(storedObjectCreateAction)); storedObjectMenu.add(new JMenuItem(storedObjectDownloadAction)); storedObjectMenu.addSeparator(); storedObjectMenu.add(new JMenuItem(storedObjectDeleteAction)); // helpMenu.add(new JMenuItem(aboutAction)); // return bar; }
From source file:org.kepler.gui.DialogGeneralTab.java
/** * getTopPanel//from www . j a v a2 s. co m * * @return Component */ protected Component getTopPanel() { Box topPanel = Box.createHorizontalBox(); JLabel nameLbl = WidgetFactory.makeJLabel( StaticResources.getDisplayString("dialogs." + _targetType + ".general.name", ""), TabbedDialog.jLabelDims); topPanel.add(nameLbl); nameTxtFld = WidgetFactory.makeJTextField((_target != null ? _target.getName() : ""), TabbedDialog.textFieldDims); topPanel.add(nameTxtFld); JLabel idLbl = WidgetFactory.makeJLabel( StaticResources.getDisplayString("dialogs." + _targetType + ".general.id", ""), TabbedDialog.idLabelDims); idLbl.setHorizontalAlignment(SwingConstants.RIGHT); topPanel.add(idLbl); topPanel.add(WidgetFactory.getDefaultSpacer()); JLabel idFieldLbl = WidgetFactory.makeJLabel(getLSIDString(_target), TabbedDialog.idValueDims); topPanel.add(idFieldLbl); topPanel.add(Box.createHorizontalGlue()); return topPanel; }
From source file:org.n52.ifgicopter.spf.gui.SPFMainFrame.java
/** * helper method. creates tab labels with icons on the left side. */// w ww . j av a 2 s. c om private void addTab(Component tab, String title, Icon icon) { this.pane.add(tab); // Create bespoke component for rendering the tab. JLabel lbl = new JLabel(title); lbl.setIcon(icon); // Add some spacing between text and icon, and position text to the RHS. lbl.setIconTextGap(2); lbl.setHorizontalTextPosition(SwingConstants.RIGHT); this.pane.setTabComponentAt(this.pane.getTabCount() - 1, lbl); }
From source file:org.notebook.gui.widget.GuiUtils.java
/** * Returns the component orientation as a SwingConstant. * // w ww.j av a 2 s . c o m * @return The component orientation as a SwingConstant */ public static int getComponentOrientationAsSwingConstant() { if (componentOrientation == null) { setComponentOrientation(); } return componentOrientation.isLeftToRight() ? SwingConstants.LEFT : SwingConstants.RIGHT; }
From source file:org.nuclos.client.customcomp.resplan.AbstractResPlanExportDialog.java
@PostConstruct private void init() { double border = 10; double inset = 5; double size[][] = { { border, 100, inset, 200, inset, 30, inset, 65, border }, // Columns { border, 20, inset, 20, inset, 30, border } }; // Rows final TableLayout tl = new TableLayout(size); setLayout(tl);/*from w w w . j av a2 s . co m*/ final SpringLocaleDelegate sld = getSpringLocaleDelegate(); final JLabel fileLabel = new JLabel(sld.getText("nuclos.resplan.dialog.file"), SwingConstants.RIGHT); add(fileLabel, "1, 1"); file = new JTextField(); file.setText(save.getPath()); add(file, "3, 1"); final JButton browse = new JButton("..."); add(browse, "5, 1"); final JLabel typeLabel = new JLabel(sld.getText("nuclos.resplan.dialog.type"), SwingConstants.RIGHT); add(typeLabel, "1, 3"); fileTypes = new JComboBox(new String[] { ImageType.SVG.getFileExtension(), ImageType.EMF.getFileExtension(), ImageType.PNG.getFileExtension() }); fileTypes.setSelectedItem(defaultFileType); fileTypes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { checkFile(); } }); add(fileTypes, "3, 3"); browse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser chooser = new JFileChooser(save.getParent()); chooser.setAcceptAllFileFilterUsed(false); chooser.addChoosableFileFilter(new MyFileFilter((String) fileTypes.getSelectedItem())); // chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); final int returnVal = chooser.showSaveDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { save = chooser.getSelectedFile(); checkFile(); } } }); final JPanel buttons = new JPanel(new FlowLayout()); add(buttons, "1, 5, 7, 5"); final JButton export = new JButton(sld.getText("nuclos.resplan.dialog.export")); buttons.add(export); export.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String filePath = file.getText(); if (!filePath.equals(save.getPath())) { save = new File(filePath); } checkFile(); if (save.exists()) { String file = save.getAbsolutePath(); if (save.canWrite()) { int ans = JOptionPane.showConfirmDialog(AbstractResPlanExportDialog.this, sld.getMessage("general.overwrite.file", "general.overwrite.file", file), sld.getMessage("general.overwrite.file.title", "general.overwrite.file.title"), JOptionPane.OK_CANCEL_OPTION); if (ans != JOptionPane.YES_OPTION) { return; } } else { JOptionPane.showMessageDialog(AbstractResPlanExportDialog.this, sld.getMessage("general.notwritable.file", "general.notwritable.file", file), sld.getMessage("general.notwritable.file.title", "general.notwritable.file.title"), JOptionPane.ERROR_MESSAGE); return; } } export(); storePreferences(); dispose(); } }); final JButton cancel = new JButton(sld.getText("general.cancel")); buttons.add(cancel); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); pack(); setLocationRelativeTo(parent); setVisible(true); }
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private boolean setupPreviewPanel(List<PreviewPart> previewParts) { boolean blnTransferWithWarnings = false; jpnPreviewHeader.removeAll();// w ww. j a va2 s .c o m jpnPreviewFooter.removeAll(); // setup parameter scroll pane jpnPreviewContent.removeAll(); double[] rowContraints = new double[previewParts.size()]; for (int i = 0; i < previewParts.size(); i++) rowContraints[i] = TableLayout.PREFERRED; final int iWidthBeginnigSpace = 3; final int iWidthSeparator = 6; final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); JLabel lbPreviewHeaderEntity = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.11", "Entit\u00e4t")); JLabel lbPreviewHeaderTable = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.12", "Tabellenname")); JLabel lbPreviewHeaderRecords = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.4", "Datens\u00e4tze")); lbPreviewHeaderRecords.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.5", "Anzahl der betroffenen Datens\u00e4tze")); utils.initJPanel(jpnPreviewContent, new double[] { iWidthBeginnigSpace, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED }, rowContraints); int iWidthEntityLabelSize = 0; int iWidthTableLabelSize = 0; int iWidthRecordsLabelSize = 0; int iCountNew = 0; int iCountDeleted = 0; int iCountChanged = 0; int iRow = 0; for (final PreviewPart pp : previewParts) { String tooltip = ""; JLabel lbEntity = new JLabel(pp.getEntity()); JLabel lbTable = new JLabel(pp.getTable()); JLabel lbRecords = new JLabel(String.valueOf(pp.getDataRecords())); lbRecords.setHorizontalAlignment(SwingConstants.RIGHT); if (lbEntity.getPreferredSize().width < lbPreviewHeaderEntity.getPreferredSize().width) lbEntity.setPreferredSize(lbPreviewHeaderEntity.getPreferredSize()); if (lbTable.getPreferredSize().width < lbPreviewHeaderTable.getPreferredSize().width) lbTable.setPreferredSize(lbPreviewHeaderTable.getPreferredSize()); if (lbRecords.getPreferredSize().width < lbPreviewHeaderRecords.getPreferredSize().width) lbRecords.setPreferredSize(lbPreviewHeaderRecords.getPreferredSize()); iWidthEntityLabelSize = iWidthEntityLabelSize < lbEntity.getPreferredSize().width ? lbEntity.getPreferredSize().width : iWidthEntityLabelSize; iWidthTableLabelSize = iWidthTableLabelSize < lbTable.getPreferredSize().width ? lbTable.getPreferredSize().width : iWidthTableLabelSize; iWidthRecordsLabelSize = iWidthRecordsLabelSize < lbRecords.getPreferredSize().width ? lbRecords.getPreferredSize().width : iWidthRecordsLabelSize; Icon icoStatement = null; switch (pp.getType()) { case PreviewPart.NEW: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.6", "Entit\u00e4t wird hinzugef\u00fcgt"); icoStatement = ParameterEditor.COMPARE_ICON_NEW; iCountNew++; break; case PreviewPart.CHANGE: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.7", "Entit\u00e4t wird ge\u00e4ndert"); icoStatement = ParameterEditor.COMPARE_ICON_VALUE_CHANGED; iCountChanged++; break; case PreviewPart.DELETE: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.8", "Entit\u00e4t wird gel\u00f6scht"); icoStatement = ParameterEditor.COMPARE_ICON_DELETED; iCountDeleted++; break; } JLabel lbIcon = new JLabel(icoStatement); JLabel lbStatemnts = new JLabel("<html><u>" + localeDelegate.getMessage("dbtransfer.import.step1.9", "Script anzeigen") + "...</u></html>"); lbStatemnts.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lbStatemnts.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) { String statements = ""; for (String statement : pp.getStatements()) { statements = statements + statement + ";\n\n"; } JTextArea txtArea = new JTextArea(statements); txtArea.setEditable(false); txtArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JScrollPane scroll = new JScrollPane(txtArea); scroll.getVerticalScrollBar().setUnitIncrement(20); scroll.setPreferredSize(new Dimension(600, 300)); scroll.setBorder(BorderFactory.createEmptyBorder()); MainFrameTab overlayFrame = new MainFrameTab( localeDelegate.getMessage("dbtransfer.import.step1.10", "Script f\u00fcr") + " " + pp.getEntity() + " (" + pp.getTable() + ")"); overlayFrame.setLayeredComponent(scroll); ifrm.add(overlayFrame); } }); lbIcon.setToolTipText(tooltip); lbStatemnts.setToolTipText(tooltip); lbEntity.setToolTipText(tooltip); lbTable.setToolTipText(tooltip); jpnPreviewContent.add(lbEntity, "1," + iRow + ",l,c"); jpnPreviewContent.add(lbTable, "3," + iRow + ",l,c"); jpnPreviewContent.add(lbRecords, "5," + iRow + ",r,c"); jpnPreviewContent.add(lbIcon, "7," + iRow + ",l,c"); jpnPreviewContent.add(lbStatemnts, "8," + iRow + ",l,c"); if (pp.getWarning() > 0) { lbIcon.setIcon(Icons.getInstance().getIconPriorityCancel16()); blnTransferWithWarnings = true; } iRow++; } jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "2,0,2," + (iRow - 1)); jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "4,0,4," + (iRow - 1)); jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "6,0,6," + (iRow - 1)); // setup preview header utils.initJPanel(jpnPreviewHeader, new double[] { iWidthBeginnigSpace, iWidthEntityLabelSize, iWidthSeparator, iWidthTableLabelSize, iWidthSeparator, iWidthRecordsLabelSize, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); if (previewParts.isEmpty()) { jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.18", "Keine Struktur\u00e4nderungen am Datenbankschema.")), "0,0,8,0"); return blnTransferWithWarnings; } jpnPreviewHeader.add(lbPreviewHeaderEntity, "1,0"); jpnPreviewHeader.add(lbPreviewHeaderTable, "3,0"); jpnPreviewHeader.add(lbPreviewHeaderRecords, "5,0"); jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.13", "\u00c4nderung")), "7,0"); // setup preview footer utils.initJPanel(jpnPreviewFooter, new double[] { TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); final JLabel lbCompare = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.14", "\u00c4nderungen") + ":"); final JLabel lbCompareNew = new JLabel(iCountNew + ""); final JLabel lbCompareDeleted = new JLabel(iCountDeleted + ""); final JLabel lbCompareValueChanged = new JLabel(iCountChanged + ""); lbCompareNew.setIcon(ParameterEditor.COMPARE_ICON_NEW); lbCompareDeleted.setIcon(ParameterEditor.COMPARE_ICON_DELETED); lbCompareValueChanged.setIcon(ParameterEditor.COMPARE_ICON_VALUE_CHANGED); lbCompareNew.setToolTipText(localeDelegate.getMessage("dbtransfer.import.step1.15", "Neue Entit\u00e4ten")); lbCompareDeleted.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.17", "Gel\u00f6schte Entit\u00e4ten")); lbCompareValueChanged.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.16", "Ge\u00e4nderte Entit\u00e4ten")); jpnPreviewFooter.add(lbCompare, "1,0,r,c"); jpnPreviewFooter.add(lbCompareNew, "2,0,r,c"); jpnPreviewFooter.add(lbCompareValueChanged, "3,0,r,c"); jpnPreviewFooter.add(lbCompareDeleted, "4,0,r,c"); return blnTransferWithWarnings; }
From source file:org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { private Icon iconWarning = ImageIconWarning.getInstance(); public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); Set<Class<? extends SQLElement>> s = map.keySet(); final ArrayList<Class<? extends SQLElement>> list = new ArrayList<Class<? extends SQLElement>>(s); Collections.sort(list, new Comparator<Class<? extends SQLElement>>() { public int compare(Class<? extends SQLElement> o1, Class<? extends SQLElement> o2) { return o1.getSimpleName().toString().compareTo(o2.getSimpleName().toString()); };/*from w ww . ja v a 2s . c om*/ }); List<String> added = new ArrayList<String>(); for (Class<? extends SQLElement> class1 : list) { String prefix = map.get(class1); if (!added.contains(prefix)) { c.gridy++; c.gridx = 0; c.weightx = 0; added.add(prefix); SQLElement elt = Configuration.getInstance().getDirectory().getElement(class1); if (elt == null) { throw new IllegalArgumentException("Element null for class " + class1); } // Avoir JLabel labelAvoirFormat = new JLabel( StringUtils.firstUp(elt.getPluralName()) + " " + getLabelFor(prefix + FORMAT), SwingConstants.RIGHT); this.add(labelAvoirFormat, c); c.gridx++; c.weightx = 1; final JTextField fieldFormat = new JTextField(); this.add(fieldFormat, c); final JLabel labelAvoirStart = new JLabel(getLabelFor(prefix + START)); c.gridx++; c.weightx = 0; this.add(labelAvoirStart, c); c.gridx++; c.weightx = 1; final JTextField fieldStart = new JTextField(); this.add(fieldStart, c); final JLabel labelResult = new JLabel(); c.gridx++; c.weightx = 0; this.add(labelResult, c); if (getTable().getFieldsName().contains(prefix + AUTO_MONTH)) { final JCheckBox boxAuto = new JCheckBox(getLabelFor(prefix + AUTO_MONTH)); c.gridx++; c.weightx = 0; this.add(boxAuto, c); this.addSQLObject(boxAuto, prefix + AUTO_MONTH); } // Affichage dynamique du rsultat SimpleDocumentListener listener = new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { updateLabel(fieldStart, fieldFormat, labelResult); } }; fieldFormat.getDocument().addDocumentListener(listener); fieldStart.getDocument().addDocumentListener(listener); this.addRequiredSQLObject(fieldFormat, prefix + FORMAT); this.addRequiredSQLObject(fieldStart, prefix + START); } } // JLabel labelCodeLettrage = new JLabel(getLabelFor("CODE_LETTRAGE")); // c.gridy++; // c.gridx = 0; // c.weightx = 0; // this.add(labelCodeLettrage, c); // c.gridx++; // c.weightx = 1; // this.add(this.textCodeLettrage, c); // // c.gridx++; // c.weightx = 0; // labelNextCodeLettrage = new JLabel(); // this.add(labelNextCodeLettrage, c); JLabel labelExemple = new JLabel("Exemple de format : 'Fact'yyyy0000"); c.gridy++; c.gridx = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 1; c.anchor = GridBagConstraints.NORTHWEST; this.add(labelExemple, c); // this.textCodeLettrage.getDocument().addDocumentListener(this.listenText); } // private void updateLabelNextCode() { // String s = getNextCodeLetrrage(this.textCodeLettrage.getText()); // this.labelNextCodeLettrage.setText(donne + " " + s); // } private void updateLabel(JTextField textStart, JTextField textFormat, JLabel label) { if (textStart.getText().trim().length() > 0) { try { String numProposition = getNextNumero(textFormat.getText(), Integer.parseInt(textStart.getText()), new Date()); if (numProposition != null) { label.setText(" --> " + numProposition); label.setIcon(null); } else { label.setIcon(this.iconWarning); label.setText(""); } } catch (IllegalArgumentException e) { JOptionPane.showMessageDialog(null, "Le format " + textFormat.getText() + " n'est pas valide!"); } } else { label.setIcon(this.iconWarning); label.setText(""); } } }; }
From source file:org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.add(new JLabel(getLabelFor("CODE"), SwingConstants.RIGHT), c); c.gridx++;/*from w w w . j a v a2s .c o m*/ c.weightx = 1; c.fill = GridBagConstraints.NONE; final JTextField code = new JTextField(6); this.add(code, c); c.gridx = 0; c.gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; final JTextField nom = new JTextField(25); this.add(nom, c); c.gridy++; c.anchor = GridBagConstraints.NORTHWEST; c.weighty = 1; final JCheckBox checkBox = new JCheckBox(getLabelFor("TYPE_BANQUE")); this.add(checkBox, c); this.addView(nom, "NOM", REQ); this.addView(code, "CODE", REQ); this.addView(checkBox, "TYPE_BANQUE"); } @Override protected SQLRowValues createDefaults() { final SQLRowValues rowVals = new SQLRowValues(getTable()); rowVals.put("TYPE_BANQUE", Boolean.TRUE); return rowVals; } }; }
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 . ja va 2 s. 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.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;//from ww w . j av a2 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; }