List of usage examples for javax.swing JPanel remove
public void remove(int index)
From source file:com.osparking.osparking.Settings_System.java
private void changeTCP_VS_COM(DeviceType devType, int gateNo) { String devPrefix = devType.name() + gateNo; JComboBox comboBx = ((JComboBox) getComponentByName(devPrefix + "_connTypeCBox")); String item = (String) comboBx.getSelectedItem(); Component comIDcbBox = getComponentByName(devPrefix + "_comID_CBox"); Component comPortLabel = getComponentByName(devPrefix + "_comLabel"); Component ipAddrCompo = getComponentByName(devPrefix + "_IP_TextField"); Component portCompo = getComponentByName(devPrefix + "_Port_TextField"); JPanel devicePanel = (JPanel) getComponentByName(devPrefix + "Panel"); if (item.equals(ConnectionType.TCP_IP.getLabel())) { devicePanel.remove(comIDcbBox); devicePanel.remove(comPortLabel); devicePanel.add(ipAddrCompo);//from www .jav a2 s . c o m devicePanel.add(portCompo); } else if (item.equals(ConnectionType.RS_232.getLabel())) { devicePanel.remove(portCompo); devicePanel.remove(ipAddrCompo); devicePanel.add(comPortLabel); devicePanel.add(comIDcbBox); String IDstr = deviceComID[devType.ordinal()][gateNo]; if (IDstr.length() == 0) { ((JComboBox) comIDcbBox).setSelectedIndex(0); } else { ((JComboBox) comIDcbBox).setSelectedIndex(Integer.parseInt(IDstr) - 1); } } devicePanel.repaint(); }
From source file:app.RunApp.java
/** * Fill the table with coefficient values * /*from w w w . j a v a2s . c om*/ * @param dataset * @param pairs * @param type */ private void fillTableCoefficients(MultiLabelInstances dataset, String type) { double[][] pairLabelValues; //coocurrence values table if (type.equals("coocurrence")) { pairLabelValues = ChartUtils.getCoocurrences(dataset); coocurrenceCoefficients = pairLabelValues; } //heatmap values table else { pairLabelValues = getHeatMapCoefficients(); heatmapCoefficients = pairLabelValues.clone(); } /** **/ data = new Object[pairLabelValues.length][pairLabelValues.length + 1]; column = new Object[data.length + 1]; if (type.equals("coocurrence")) { for (int i = 0; i < pairLabelValues.length; i++) { for (int j = 0; j < pairLabelValues.length; j++) { if (j == 0) { data[i][j] = dataset.getLabelNames()[i]; } else if (i == (j - 1)) { data[i][j] = ""; } else if (j > i) { data[i][j] = ""; } else { if (pairLabelValues[j - 1][i] <= 0.0) { data[i][j] = ""; } else { data[i][j] = (int) pairLabelValues[j - 1][i]; } } } } } else { for (int i = 0; i < pairLabelValues.length; i++) { for (int j = 0; j < pairLabelValues.length + 1; j++) { if (j == 0) { data[i][j] = dataset.getLabelNames()[i]; } else { if (pairLabelValues[j - 1][i] <= 0.0) { data[i][j] = ""; } else { NumberFormat formatter = new DecimalFormat("#0.000"); data[i][j] = formatter.format(pairLabelValues[j - 1][i]).replace(",", "."); } } } } } for (int i = 0; i < column.length; i++) { if (i == 0) { column[i] = "Labels"; } else { column[i] = (dataset.getLabelNames()[i - 1]); } } AbstractTableModel1 fixedModel = new AbstractTableModel1(data, column); AbstractTableModel2 model = new AbstractTableModel2(data, column); JTable temp, fixedTable_temp; JPanel jpanel_temp; if (type.equals("coocurrence")) { temp = jTableCoocurrences; jpanel_temp = panelCoOcurrenceValues; fixedTable_temp = fixedTableCoocurrences; } else { temp = jTableHeatmap; jpanel_temp = panelHeatmapValues; fixedTable_temp = fixedTableHeatmap; } fixedTable_temp.setModel(fixedModel); temp.setModel(model); JScrollPane scroll = new JScrollPane(temp); JViewport viewport = new JViewport(); viewport.setView(fixedTable_temp); viewport.setPreferredSize(fixedTable_temp.getPreferredSize()); scroll.setRowHeaderView(viewport); scroll.setBounds(20, 20, 780, 390); scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedTable_temp.getTableHeader()); temp.setBorder(BorderFactory.createLineBorder(Color.black)); jpanel_temp.remove(0); jpanel_temp.add(scroll, BorderLayout.CENTER, 0); }
From source file:app.RunApp.java
/** * Create heatmap graph/* ww w. jav a 2 s. c o m*/ * * @param jpanel Panel * @param coefficients Coefficients * @param list List * @param oldHeatmap Old heatmap * @return Heatmap */ private HeatMap createHeatmapGraph(JPanel jpanel, double[][] coefficients, ArrayList<AttributesPair> list, HeatMap oldHeatmap) { Color[] colors = new Color[256]; for (int i = 0; i < colors.length; i++) { colors[i] = new Color(i, i, i); } HeatMap heatMap = null; double[][] newCoefs = coefficients.clone(); for (int i = 0; i < newCoefs.length; i++) { for (int j = 0; j < newCoefs.length; j++) { if (newCoefs[i][j] < 0) { newCoefs[i][j] = 0; } } } if ((list != null) && (list.size() > 0)) { HashSet<Integer> selected = new HashSet<>(); for (int i = 0; i < list.size(); i++) { selected.add(list.get(i).getAttribute1Index()); selected.add(list.get(i).getAttribute2Index()); } newCoefs = new double[selected.size()][selected.size()]; List sortedSelected = new ArrayList(selected); Collections.sort(sortedSelected); for (int i = 0; i < sortedSelected.size(); i++) { for (int j = 0; j < sortedSelected.size(); j++) { newCoefs[i][j] = coefficients[(int) sortedSelected.get(i)][(int) sortedSelected.get(j)]; } } } heatMap = new HeatMap(newCoefs, false, colors); if (oldHeatmap != null) { jpanel.remove(oldHeatmap); } jpanel.setLayout(new BorderLayout()); jpanel.setPreferredSize(new Dimension(550, 425)); jpanel.add(heatMap, BorderLayout.CENTER); jpanel.validate(); jpanel.repaint(); return heatMap; }
From source file:app.RunApp.java
/** * Create JGraphX chart// ww w . j ava 2 s. c o m * * @param jpanel Panel * @param list List * @param labelNames Names of labels * @param oldGraph Old graph * @return */ private mxGraphComponent createJGraphX(JPanel jpanel, ArrayList<AttributesPair> list, String[] labelNames, mxGraphComponent oldGraph) { mxGraph graph = new mxGraph(); Object parent = graph.getDefaultParent(); graph.getModel().beginUpdate(); graph.setLabelsClipped(true); Random rand = new Random(); Object[] corners = new Object[labelNames.length]; ImbalancedFeature current; double freq; int min = 0; int max = 1; int numIntervals = 10; int strength; try { //create vertices for (int i = 0; i < labelNames.length; i++) { current = DataInfoUtils.getLabelByLabelname(labelNames[i], labelsFreqSorted); freq = current.getAppearances() / (dataset.getNumInstances() * 1.0); strength = ChartUtils.getBorderStrength(min, max, numIntervals, freq); switch (strength) { case 1: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 6, 20); break; case 2: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "ROUNDED;strokeWidth=2"); break; case 3: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "ROUNDED;strokeWidth=3"); break; case 4: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "ROUNDED;strokeWidth=4"); break; case 5: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=5"); break; case 6: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=6"); break; case 7: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=7"); break; case 8: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=8"); break; case 9: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=9"); break; default: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=10"); break; } } ArrayList<String> otherList; //create edges if (!list.isEmpty()) { AttributesPair temp; for (int i = 0; i < labelNames.length; i++) { otherList = ChartUtils.getVertices(labelNames[i], list); for (String actual : otherList) { int index = DataInfoUtils.getLabelIndex(labelNames, actual); temp = AttributePairsUtils.searchAndGet(labelNames[i], actual, list); freq = temp.getAppearances() / (dataset.getNumInstances() * 1.0); strength = ChartUtils.getBorderStrength(min, max, numIntervals, freq); switch (strength) { case 1: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=1"); break; case 2: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=2"); break; case 3: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=3"); break; case 4: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=4"); break; case 5: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=5"); break; case 6: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=6"); break; case 7: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=7"); break; case 8: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=8"); break; case 9: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=9"); break; default: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=3"); break; } } } } } finally { graph.getModel().endUpdate(); } if (oldGraph != null) { jpanel.remove(oldGraph); } graph.setCellsEditable(false); graph.setAllowDanglingEdges(false); mxGraphComponent graphComponent = new mxGraphComponent(graph); graphComponent.getGraph().getModel().endUpdate(); jpanel.setLayout(new BorderLayout()); jpanel.setPreferredSize(new Dimension(550, 425)); jpanel.add(graphComponent, BorderLayout.CENTER); jpanel.validate(); jpanel.repaint(); return graphComponent; }
From source file:op.tools.SYSTools.java
public static void removeSearchPanels(JPanel panelSearch, int positionToAddPanels) { if (panelSearch.getComponentCount() > positionToAddPanels) { int count = panelSearch.getComponentCount(); for (int i = count - 1; i >= positionToAddPanels; i--) { panelSearch.remove(positionToAddPanels); }/*from w w w .j a v a2s . co m*/ } }
From source file:org.asciidoc.intellij.editor.AsciiDocPreviewEditor.java
@Contract("_, null, null -> fail") @NotNull/* w w w . j a v a 2 s . c om*/ private static AsciiDocHtmlPanel detachOldPanelAndCreateAndAttachNewOne(Document document, Path imagesDir, @NotNull JPanel panelWrapper, @Nullable AsciiDocHtmlPanel oldPanel, @Nullable AsciiDocHtmlPanelProvider newPanelProvider) { ApplicationManager.getApplication().assertIsDispatchThread(); if (oldPanel == null && newPanelProvider == null) { throw new IllegalArgumentException("Either create new one or leave the old"); } if (newPanelProvider == null) { return oldPanel; } if (oldPanel != null) { panelWrapper.remove(oldPanel.getComponent()); Disposer.dispose(oldPanel); } final AsciiDocHtmlPanel newPanel = newPanelProvider.createHtmlPanel(document, imagesDir); if (oldPanel != null) { newPanel.setEditor(oldPanel.getEditor()); } panelWrapper.add(newPanel.getComponent(), BorderLayout.CENTER); panelWrapper.repaint(); return newPanel; }
From source file:org.isatools.isacreator.wizard.GeneralCreationAlgorithm.java
public JPanel instantiatePanel() { final JPanel generalQuestionCont = new JPanel(); generalQuestionCont.setLayout(new BoxLayout(generalQuestionCont, BoxLayout.PAGE_AXIS)); generalQuestionCont.setBackground(UIHelper.BG_COLOR); JLabel info = new JLabel("<html><b>" + assay.getMeasurementEndpoint() + "</b> using <b>" + assay.getTechnologyType() + "</b></html>", JLabel.LEFT); UIHelper.renderComponent(info, UIHelper.VER_12_PLAIN, UIHelper.GREY_COLOR, false); if (assay.getTechnologyType().equals("")) { info.setText("<html><b>" + assay.getMeasurementEndpoint() + "</html>"); }/* ww w . j a va 2s .c o m*/ info.setPreferredSize(new Dimension(300, 40)); JPanel infoPanel = new JPanel(new GridLayout(1, 1)); infoPanel.setBackground(UIHelper.BG_COLOR); infoPanel.add(info); generalQuestionCont.add(infoPanel); JPanel labelPanel = new JPanel(new GridLayout(1, 2)); labelPanel.setBackground(UIHelper.BG_COLOR); labelCapture = new LabelCapture("Label"); labelCapture.setVisible(false); labelUsed = new JCheckBox("Label used?", false); UIHelper.renderComponent(labelUsed, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR); labelUsed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { labelCapture.setVisible(labelUsed.isSelected()); } }); labelPanel.add(labelUsed); labelPanel.add(labelCapture); generalQuestionCont.add(labelPanel); final JPanel extractPanel = new JPanel(new GridLayout(2, 2)); extractPanel.setBackground(UIHelper.BG_COLOR); extractDetails.clear(); JLabel extractsUsedLab = UIHelper.createLabel("Sample(s) used *"); extractsUsedLab.setHorizontalAlignment(JLabel.LEFT); extractsUsedLab.setVerticalAlignment(JLabel.TOP); final JPanel extractNameContainer = new JPanel(); extractNameContainer.setLayout(new BoxLayout(extractNameContainer, BoxLayout.PAGE_AXIS)); extractNameContainer.setBackground(UIHelper.BG_COLOR); extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); JLabel addButton = new JLabel("add sample", addRecordIcon, JLabel.RIGHT); UIHelper.renderComponent(addButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); addButton.setVerticalAlignment(JLabel.TOP); addButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); extractNameContainer.revalidate(); generalQuestionCont.revalidate(); } }); addButton.setToolTipText( "<html><b>add new sample</b><p>add another sample (e.g. Liver, Heart, Urine, Blood)</p></html>"); JLabel removeButton = new JLabel("remove sample", removeIcon, JLabel.RIGHT); removeButton.setVerticalAlignment(JLabel.TOP); UIHelper.renderComponent(removeButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); removeButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (extractDetails.size() > 1) { extract = extractDetails.get(extractDetails.size() - 1); extractDetails.remove(extract); extractNameContainer.remove(extract); generalQuestionCont.revalidate(); } } }); removeButton.setToolTipText( "<html><b>remove previously added sample</b><p>remove the sample field last added</p></html>"); extractPanel.add(extractsUsedLab); extractPanel.add(extractNameContainer); JPanel buttonContainer = new JPanel(new GridLayout(1, 2)); buttonContainer.setBackground(UIHelper.BG_COLOR); buttonContainer.add(addButton); buttonContainer.add(removeButton); extractPanel.add(new JLabel()); extractPanel.add(buttonContainer); generalQuestionCont.add(extractPanel); generalQuestionCont.add(Box.createVerticalStrut(5)); generalQuestionCont.add(Box.createHorizontalGlue()); generalQuestionCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 9), assay.getAssayReference(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); return generalQuestionCont; }
From source file:org.isatools.isacreator.wizard.MicroarrayCreationAlgorithm.java
private JPanel instantiatePanel() { final JPanel microArrayQuestionCont = new JPanel(); microArrayQuestionCont.setLayout(new BoxLayout(microArrayQuestionCont, BoxLayout.PAGE_AXIS)); microArrayQuestionCont.setOpaque(false); StringBuilder text = new StringBuilder("<html><b>" + assay.getMeasurementEndpoint() + "</b> using <b>" + assay.getTechnologyType() + "</b>"); if (!StringUtils.isEmpty(assay.getAssayPlatform())) { text.append(" on <b>").append(assay.getAssayPlatform()).append("</b>"); }/*from w w w .jav a2s.c om*/ JLabel info = new JLabel(text.append("</html>").toString(), JLabel.LEFT); UIHelper.renderComponent(info, UIHelper.VER_12_PLAIN, UIHelper.GREY_COLOR, false); info.setPreferredSize(new Dimension(300, 40)); JPanel infoPanel = new JPanel(new GridLayout(1, 1)); infoPanel.setOpaque(false); infoPanel.add(info); microArrayQuestionCont.add(infoPanel); // create reference sample used checkbox JPanel labelPanel = new JPanel(new GridLayout(2, 2)); labelPanel.setBackground(UIHelper.BG_COLOR); final DataEntryForm studyUISection = ApplicationManager.getUserInterfaceForISASection(study); System.out.println("Study user interface is null? " + (studyUISection == null)); System.out .println("Study user interface dep is null? " + (studyUISection.getDataEntryEnvironment() == null)); label1Capture = new LabelCapture("Label (e.g. Cy3)"); label2Capture = new LabelCapture("Label (e.g. Cy5)"); label2Capture.setVisible(false); // create dye swap check box dyeSwapUsed = new JCheckBox("dye-swap performed?", false); UIHelper.renderComponent(dyeSwapUsed, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); dyeSwapUsed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { label2Capture.setVisible(dyeSwapUsed.isSelected()); } }); labelPanel.add(UIHelper.createLabel("Label(s) used")); labelPanel.add(label1Capture); labelPanel.add(dyeSwapUsed); labelPanel.add(label2Capture); microArrayQuestionCont.add(labelPanel); final JPanel extractPanel = new JPanel(new GridLayout(2, 2)); extractPanel.setOpaque(false); extractDetails.clear(); JLabel extractsUsedLab = UIHelper.createLabel("sample(s) used *"); extractsUsedLab.setHorizontalAlignment(JLabel.LEFT); extractsUsedLab.setVerticalAlignment(JLabel.TOP); final JPanel extractNameContainer = new JPanel(); extractNameContainer.setLayout(new BoxLayout(extractNameContainer, BoxLayout.PAGE_AXIS)); extractNameContainer.setOpaque(false); extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), studyUISection.getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); JLabel addExtractButton = new JLabel("add sample", addRecordIcon, JLabel.RIGHT); UIHelper.renderComponent(addExtractButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); addExtractButton.setVerticalAlignment(JLabel.TOP); addExtractButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), studyUISection.getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); extractNameContainer.revalidate(); microArrayQuestionCont.revalidate(); } }); addExtractButton.setToolTipText( "<html><b>add new sample</b><p>add another sample (e.g. Liver, Heart, Urine, Blood)</p></html>"); JLabel removeExtractButton = new JLabel("remove sample", removeIcon, JLabel.RIGHT); removeExtractButton.setVerticalAlignment(JLabel.TOP); UIHelper.renderComponent(removeExtractButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); removeExtractButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (extractDetails.size() > 1) { extract = extractDetails.get(extractDetails.size() - 1); extractDetails.remove(extract); extractNameContainer.remove(extract); microArrayQuestionCont.revalidate(); } } }); removeExtractButton.setToolTipText( "<html><b>remove previously added sample</b><p>remove the array design field last added</p></html>"); extractPanel.add(extractsUsedLab); extractPanel.add(extractNameContainer); JPanel extractButtonContainer = new JPanel(new GridLayout(1, 2)); extractButtonContainer.setOpaque(false); extractButtonContainer.add(addExtractButton); extractButtonContainer.add(removeExtractButton); extractPanel.add(new JLabel()); extractPanel.add(extractButtonContainer); microArrayQuestionCont.add(extractPanel); // ask for array designs used... // create array designs panel final JPanel arrayDesignPanel = new JPanel(new GridLayout(2, 2)); arrayDesignPanel.setOpaque(false); arrayDesignsUsed.clear(); JLabel arrayDesignLab = UIHelper.createLabel("array design(s) used *"); arrayDesignLab.setVerticalAlignment(JLabel.TOP); // the array designs container must adjust to an unknown number of fields. therefore, a JPanel with a BoxLayout // will be used since it is flexible! final JPanel arrayDesignsContainer = new JPanel(); arrayDesignsContainer.setLayout(new BoxLayout(arrayDesignsContainer, BoxLayout.PAGE_AXIS)); arrayDesignsContainer.setOpaque(false); newArrayDesign = new AutoFilterCombo(arrayDesigns, true); UIHelper.renderComponent(newArrayDesign, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); newArrayDesign.setPreferredSize(new Dimension(70, 30)); arrayDesignsContainer.add(newArrayDesign); arrayDesignsUsed.add(newArrayDesign); JLabel addButton = new JLabel("add design", addRecordIcon, JLabel.RIGHT); UIHelper.renderComponent(addButton, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); addButton.setVerticalAlignment(JLabel.TOP); addButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { newArrayDesign = new AutoFilterCombo(arrayDesigns, true); UIHelper.renderComponent(newArrayDesign, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); newArrayDesign.setPreferredSize(new Dimension(70, 30)); arrayDesignsUsed.add(newArrayDesign); arrayDesignsContainer.add(newArrayDesign); arrayDesignsContainer.revalidate(); microArrayQuestionCont.revalidate(); } }); addButton.setToolTipText("<html><b>add new array design</b><p>add another array design</p></html>"); JLabel removeButton = new JLabel("remove design", removeIcon, JLabel.RIGHT); removeButton.setVerticalAlignment(JLabel.TOP); UIHelper.renderComponent(removeButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); removeButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (arrayDesignsUsed.size() > 1) { newArrayDesign = arrayDesignsUsed.get(arrayDesignsUsed.size() - 1); arrayDesignsUsed.remove(newArrayDesign); arrayDesignsContainer.remove(newArrayDesign); arrayDesignPanel.revalidate(); microArrayQuestionCont.validate(); } } }); removeButton.setToolTipText( "<html><b>remove previously added array design</b><p>remove the array design field last added</p></html>"); arrayDesignPanel.add(arrayDesignLab); arrayDesignPanel.add(arrayDesignsContainer); JPanel buttonContainer = new JPanel(new GridLayout(1, 2)); buttonContainer.setOpaque(false); buttonContainer.add(addButton); buttonContainer.add(removeButton); arrayDesignPanel.add(new JLabel()); arrayDesignPanel.add(buttonContainer); microArrayQuestionCont.add(arrayDesignPanel); microArrayQuestionCont.add(Box.createVerticalStrut(5)); microArrayQuestionCont.add(Box.createHorizontalGlue()); microArrayQuestionCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 9), assay.getAssayReference(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); return microArrayQuestionCont; }
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;//from www .j a va 2 s. com 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
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 w w w . j av a2 s .c om 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; }