List of usage examples for java.awt GridBagConstraints HORIZONTAL
int HORIZONTAL
To view the source code for java.awt GridBagConstraints HORIZONTAL.
Click Source Link
From source file:com.att.aro.ui.view.videotab.VideoTab.java
public void addGraphPanel() { if (mainPanel != null) { mainPanel.add(buildGraphPanel(), new GridBagConstraints(0, graphPanelIndex, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0)); }/* w ww. j a v a 2 s . c om*/ aroView.getDiagnosticTab().getGraphPanel().setChartOptions(ChartPlotOptions.getVideoDefaultView()); }
From source file:de.codesourcery.jasm16.ide.ui.views.HexDumpView.java
protected JPanel createPanel() { textArea.setEditable(false);/*from ww w .j a v a 2 s. c o m*/ setColors(textArea); textArea.setFont(getMonospacedFont()); textArea.setEditable(false); // dump panel final JPanel dumpPanel = new JPanel(); setColors(dumpPanel); dumpPanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH); dumpPanel.add(textArea, cnstrs); // toolbar panel final JPanel toolbarPanel = new JPanel(); setColors(toolbarPanel); toolbarPanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); toolbarPanel.add(new JLabel("Goto"), cnstrs); final JTextField gotoTextfield = new JTextField(); gotoTextfield.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String val = gotoTextfield.getText(); Address adr; if (StringUtils.isBlank(val)) { gotoTextfield.setText("0000"); adr = Address.wordAddress(0); } else { try { adr = Address.wordAddress(Misc.parseHexString(val)); } catch (NumberFormatException e1) { gotoTextfield.setText("0000"); adr = Address.wordAddress(0); } } dumpStartAddress = adr; refreshDisplay(); } }); cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL); toolbarPanel.add(gotoTextfield, cnstrs); // create result panel final JPanel result = new JPanel(); setColors(result); result.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, true, GridBagConstraints.BOTH); result.add(dumpPanel, cnstrs); cnstrs = constraints(1, 0, true, true, GridBagConstraints.VERTICAL); result.add(toolbarPanel, cnstrs); textArea.addKeyListener(new PagingKeyAdapter() { @Override protected void onePageUp() { HexDumpView.this.onePageUp(); } @Override protected void onePageDown() { HexDumpView.this.onePageDown(); } @Override protected void oneLineUp() { HexDumpView.this.oneLineUp(); } @Override protected void oneLineDown() { HexDumpView.this.oneLineDown(); } }); result.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { refreshDisplay(); } }); return result; }
From source file:EditorPaneExample18.java
public EditorPaneExample18() { super("JEditorPane Example 18"); pane = new JEditorPane(); pane.setEditable(true); // Editable getContentPane().add(new JScrollPane(pane), "Center"); // Add a menu bar menuBar = new JMenuBar(); setJMenuBar(menuBar);/*from w ww. j a va 2s . c o m*/ // Populate it createMenuBar(); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1; c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridy = 5; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; editableBox = new JCheckBox("Editable JEditorPane"); panel.add(editableBox, c); editableBox.setSelected(true); editableBox.setForeground(typeLabel.getForeground()); c.gridy = 6; c.weightx = 0.0; JButton saveButton = new JButton("Save"); panel.add(saveButton, c); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { EditorKit kit = pane.getEditorKit(); try { if (kit instanceof RTFEditorKit) { kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength()); System.out.flush(); } else { if (writer == null) { writer = new OutputStreamWriter(System.out); pane.write(writer); writer.flush(); } kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength()); writer.flush(); } } catch (Exception e) { System.out.println("Write failed"); } } }); c.gridx = 1; c.gridy = 0; c.weightx = 1.0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Register a custom EditorKit for HTML ClassLoader loader = getClass().getClassLoader(); if (loader != null) { // Java 2 JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit", loader); } else { // JDK 1.1 JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit"); } // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); loadNewPage(selection); } }); // Change editability based on the checkbox editableBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pane.setEditable(editableBox.isSelected()); pane.revalidate(); pane.repaint(); } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); createMenuBar(); enableMenuBar(true); getRootPane().revalidate(); enableInput(); loadingPage = false; } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); // Listener for hypertext events pane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { // Ignore hyperlink events if the frame is busy if (loadingPage == true) { return; } if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane sp = (JEditorPane) evt.getSource(); if (evt instanceof HTMLFrameHyperlinkEvent) { HTMLDocument doc = (HTMLDocument) sp.getDocument(); doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt); } else { loadNewPage(evt.getURL()); } } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { pane.setCursor(handCursor); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { pane.setCursor(defaultCursor); } } }); }
From source file:org.eevolution.form.VCRPDetail.java
private void jbInit() { dateFrom = new VDate("DateFrom", true, false, true, DisplayType.Date, "DateFrom"); dateTo = new VDate("DateTo", true, false, true, DisplayType.Date, "DateTo"); CPanel northPanel = new CPanel(); northPanel.setLayout(new java.awt.GridBagLayout()); northPanel.add(new CLabel(Msg.translate(Env.getCtx(), "S_Resource_ID")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(resource, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(new CLabel(Msg.translate(Env.getCtx(), "DateFrom")), new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(dateFrom, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(new CLabel(Msg.translate(Env.getCtx(), "DateTo")), new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(dateTo, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); ConfirmPanel confirmPanel = new ConfirmPanel(true); confirmPanel.addActionListener(new ActionHandler()); contentPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); contentPanel.setPreferredSize(new Dimension(800, 600)); m_form.getWindow().getContentPane().add(northPanel, BorderLayout.NORTH); m_form.getWindow().getContentPane().add(contentPanel, BorderLayout.CENTER); m_form.getWindow().getContentPane().add(confirmPanel, BorderLayout.SOUTH); }
From source file:fr.eurecom.hybris.demogui.HybrisDemoGui.java
private void initializeGUI() { frame = new JFrame("Hybris Demo GUI"); frame.setIconImage(new ImageIcon(getClass().getResource("/clouds.png")).getImage()); frame.setBounds(100, 100, 650, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new GridBagLayout()); JPanel cloudParentPanel = new JPanel(new GridLayout(1, 2, 10, 10)); JPanel hybrisPanel = new JPanel(new GridBagLayout()); JPanel cloudsPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1.0;//from www. j a v a 2 s .co m gbc.weighty = 1.0; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = 3; gbc.gridheight = 1; gbc.gridx = 0; gbc.gridy = 0; hybrisPanel.add(new JLabel("<html><b>Hybris</b></html>"), gbc); gbc.gridwidth = 3; gbc.gridheight = 3; gbc.gridx = 0; gbc.gridy = 1; lstHybris = new JList<String>(lmHybris); lstHybris.setPreferredSize(new java.awt.Dimension(100, 500)); lstHybris.setMinimumSize(new java.awt.Dimension(100, 440)); hybrisPanel.add(lstHybris, gbc); gbc.anchor = GridBagConstraints.SOUTH; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridwidth = 1; gbc.gridx = 0; gbc.gridy = 4; btnPut = new JButton("Put"); hybrisPanel.add(btnPut, gbc); gbc.gridx = 1; gbc.gridy = 4; btnGet = new JButton("Get"); hybrisPanel.add(btnGet, gbc); gbc.gridx = 2; gbc.gridy = 4; btnDelete = new JButton("Delete"); hybrisPanel.add(btnDelete, gbc); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; cloudsPanel.add(new JLabel("<html><b>Amazon S3</b></html>"), gbc); gbc.gridheight = 2; gbc.gridy = 1; lstAmazon = new JList<String>(lmAmazon); lstAmazon.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstAmazon.setPreferredSize(new java.awt.Dimension(100, 100)); cloudsPanel.add(lstAmazon, gbc); gbc.gridy = 3; gbc.gridheight = 1; cloudsPanel.add(new JLabel("<html><b>Microsoft Azure</b></html>"), gbc); gbc.gridheight = 2; gbc.gridy = 4; lstAzure = new JList<String>(lmAzure); lstAzure.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstAzure.setPreferredSize(new java.awt.Dimension(100, 100)); cloudsPanel.add(lstAzure, gbc); gbc.gridy = 6; gbc.gridheight = 1; cloudsPanel.add(new JLabel("<html><b>Google Cloud Storage</b></html>"), gbc); gbc.gridheight = 2; gbc.gridy = 7; lstGoogle = new JList<String>(lmGoogle); lstGoogle.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstGoogle.setPreferredSize(new java.awt.Dimension(100, 100)); cloudsPanel.add(lstGoogle, gbc); gbc.gridy = 9; gbc.gridheight = 1; cloudsPanel.add(new JLabel("<html><b>Rackspace Cloud Files</b></html>"), gbc); gbc.gridheight = 2; gbc.gridy = 10; lstRackspace = new JList<String>(lmRackspace); lstRackspace.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstRackspace.setPreferredSize(new java.awt.Dimension(100, 100)); cloudsPanel.add(lstRackspace, gbc); cloudParentPanel.add(hybrisPanel); cloudParentPanel.add(cloudsPanel); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; frame.add(cloudParentPanel, gbc); gbc.gridx = 0; gbc.gridy = 1; JTextArea jt = new JTextArea(10, 30); JScrollPane scrollPane = new JScrollPane(jt); frame.add(scrollPane, gbc); PrintStream printStream = new PrintStream(new CustomOutputStream(jt)); System.setOut(printStream); System.setErr(printStream); frame.pack(); frame.setSize(550, 800); frame.setResizable(false); lstAmazon.addKeyListener(this); lstAzure.addKeyListener(this); lstGoogle.addKeyListener(this); lstRackspace.addKeyListener(this); lstHybris.addKeyListener(this); lstAmazon.setCellRenderer(this.new MyListRenderer("amazon")); lstGoogle.setCellRenderer(this.new MyListRenderer("google")); lstAzure.setCellRenderer(this.new MyListRenderer("azure")); lstRackspace.setCellRenderer(this.new MyListRenderer("rackspace")); btnGet.addActionListener(this); btnPut.addActionListener(this); btnDelete.addActionListener(this); }
From source file:de.fhbingen.wbs.wpOverview.tabs.APCalendarPanel.java
/** * Initialize the work package calendar panel inclusive the listeners. *///from ww w.ja va 2s . c o m private void init() { List<Workpackage> userWp = new ArrayList<Workpackage>(WpManager.getUserWp(WPOverview.getUser())); Collections.sort(userWp, new APLevelComparator()); dataset = createDataset(userWp); chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); final JPopupMenu popup = new JPopupMenu(); JMenuItem miSave = new JMenuItem(LocalizedStrings.getButton().save(LocalizedStrings.getWbs().timeLine())); miSave.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent arg0) { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new ExtensionAndFolderFilter("jpg", "jpeg")); //NON-NLS chooser.setSelectedFile(new File("chart-" //NON-NLS + System.currentTimeMillis() + ".jpg")); int returnVal = chooser.showSaveDialog(reference); if (returnVal == JFileChooser.APPROVE_OPTION) { try { File outfile = chooser.getSelectedFile(); ChartUtilities.saveChartAsJPEG(outfile, chart, chartPanel.getWidth(), chartPanel.getWidth()); Controller.showMessage( LocalizedStrings.getMessages().timeLineSaved(outfile.getCanonicalPath())); } catch (IOException e) { Controller.showError(LocalizedStrings.getErrorMessages().timeLineExportError()); } } } }); popup.add(miSave); chartPanel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { popup.show(e.getComponent(), e.getX(), e.getY()); } } }); chartPanel.setMinimumDrawHeight(50 + 15 * userWp.size()); chartPanel.setMaximumDrawHeight(50 + 15 * userWp.size()); chartPanel.setMaximumDrawWidth(9999); chartPanel.setPreferredSize( new Dimension((int) chartPanel.getPreferredSize().getWidth(), 50 + 15 * userWp.size())); chartPanel.setPopupMenu(null); this.setLayout(new BorderLayout()); this.removeAll(); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1; constraints.weighty = 1; constraints.anchor = GridBagConstraints.NORTHWEST; panel.add(chartPanel, constraints); panel.setBackground(Color.white); this.add(panel, BorderLayout.CENTER); GanttRenderer.setDefaultShadowsVisible(false); GanttRenderer.setDefaultBarPainter(new BarPainter() { @Override public void paintBar(final Graphics2D g, final BarRenderer arg1, final int row, final int col, final RectangularShape rect, final RectangleEdge arg5) { String wpName = (String) dataset.getColumnKey(col); int i = 0; int spaceCount = 0; while (wpName.charAt(i++) == ' ' && spaceCount < 17) { spaceCount++; } g.setColor(new Color(spaceCount * 15, spaceCount * 15, spaceCount * 15)); g.fill(rect); g.setColor(Color.black); g.setStroke(new BasicStroke()); g.draw(rect); } @Override public void paintBarShadow(final Graphics2D arg0, final BarRenderer arg1, final int arg2, final int arg3, final RectangularShape arg4, final RectangleEdge arg5, final boolean arg6) { } }); ((CategoryPlot) chart.getPlot()).setRenderer(new GanttRenderer() { private static final long serialVersionUID = -6078915091070733812L; public void drawItem(final Graphics2D g2, final CategoryItemRendererState state, final Rectangle2D dataArea, final CategoryPlot plot, final CategoryAxis domainAxis, final ValueAxis rangeAxis, final CategoryDataset dataset, final int row, final int column, final int pass) { super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass); } }); }
From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java
private JPanel getJPanelForDocumentExportInfo() { if (jPanelForDocumentExportInfo == null) { GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints5.gridx = -1;//w w w .j a v a 2s .c o m gridBagConstraints5.gridy = -1; gridBagConstraints5.gridwidth = 1; gridBagConstraints5.anchor = GridBagConstraints.CENTER; gridBagConstraints5.weightx = 1.0; gridBagConstraints5.weighty = 0.0; gridBagConstraints5.insets = new Insets(0, 0, 10, 5); // margin // top, left, bottom, right jPanelForDocumentExportInfo = new JPanel(); jPanelForDocumentExportInfo.setLayout(new GridBagLayout()); jPanelForDocumentExportInfo.setBorder(BorderFactory.createTitledBorder(null, "Report Export Location", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); jPanelForDocumentExportInfo.add(getJPanelDocumentExportInfo(), gridBagConstraints5); } return jPanelForDocumentExportInfo; }
From source file:endrov.typeTimeRemap.TimeRemapWindow.java
/** * Regenerate UI// w ww. ja v a2 s .co m */ private void fillDatapart() { datapart.removeAll(); datapart.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridy = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 0; datapart.add(new JLabel("Original"), c); c.gridx = 1; datapart.add(new JLabel("New"), c); for (int i = 0; i < inputVector.size(); i++) { c.gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 0; datapart.add(inputVector.get(i).frame, c); c.gridx = 1; datapart.add(inputVector.get(i).time, c); c.gridx = 2; c.fill = 0; c.weightx = 0; datapart.add(inputVector.get(i).bDelete, c); } setVisibleEvWindow(true); }
From source file:gov.loc.repository.bagger.ui.NewBagInPlaceFrame.java
private void layoutSelectDataContent(JPanel contentPanel, int row) { GridBagConstraints glbc = new GridBagConstraints(); JLabel location = new JLabel("Select Data:"); saveAsButton = new JButton(bagView.getPropertyMessage("bag.button.browse")); saveAsButton.addActionListener(new BrowseFileHandler()); saveAsButton.setEnabled(true);//from www .ja v a2 s . c o m saveAsButton.setToolTipText(bagView.getPropertyMessage("bag.button.browse.help")); String fileName = ""; if (bag != null) fileName = bag.getName(); bagNameField = new JTextField(fileName); bagNameField.setCaretPosition(fileName.length()); bagNameField.setEditable(false); bagNameField.setEnabled(false); glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); contentPanel.add(location, glbc); glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST); glbc.ipadx = 5; glbc.ipadx = 0; contentPanel.add(saveAsButton, glbc); glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); glbc.ipadx = 5; glbc.ipadx = 0; contentPanel.add(bagNameField, glbc); }
From source file:org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent.java
public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); // Champ Module c.gridx = 0;//w ww. j a v a 2 s . c om c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; final JPanel addP = ComptaSQLConfElement.createAdditionalPanel(); this.setAdditionalFieldsPanel(new FormLayouter(addP, 1)); this.add(addP, c); c.gridy++; c.gridwidth = 1; this.textTotalHT.setOpaque(false); this.textTotalTVA.setOpaque(false); this.textTotalTTC.setOpaque(false); this.selectCommande = new ElementComboBox(); // Numero JLabel labelNum = new JLabel(getLabelFor("NUMERO")); labelNum.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelNum, c); this.textNumeroUnique = new JUniqueTextField(16); c.gridx++; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique); this.add(this.textNumeroUnique, c); // Date JLabel labelDate = new JLabel(getLabelFor("DATE")); labelDate.setHorizontalAlignment(SwingConstants.RIGHT); c.fill = GridBagConstraints.HORIZONTAL; c.gridx++; c.weightx = 0; this.add(labelDate, c); JDate date = new JDate(true); c.gridx++; c.weightx = 0; c.weighty = 0; this.add(date, c); // Reference c.gridy++; c.gridx = 0; final JLabel labelNom = new JLabel(getLabelFor("NOM")); labelNom.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelNom, c); c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; DefaultGridBagConstraints.lockMinimumSize(this.textReference); this.add(this.textReference, c); // Fournisseur JLabel labelFournisseur = new JLabel(getLabelFor("ID_FOURNISSEUR")); labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 0; c.gridy++; c.weightx = 0; c.weighty = 0; this.add(labelFournisseur, c); this.fournisseur = new ElementComboBox(); c.gridx++; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(this.fournisseur, c); // Devise c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c); final ElementComboBox boxDevise = new ElementComboBox(); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(boxDevise, c); this.addView(boxDevise, "ID_DEVISE"); // Element du bon this.tableBonItem = new BonReceptionItemTable(); c.gridx = 0; c.gridy++; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; this.add(this.tableBonItem, c); this.fournisseur.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { tableBonItem.setFournisseur(fournisseur.getSelectedRow()); } }); c.anchor = GridBagConstraints.EAST; // Totaux reconfigure(this.textTotalHT); reconfigure(this.textTotalTVA); reconfigure(this.textTotalTTC); // Poids Total c.gridy++; c.gridx = 1; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; DefaultProps props = DefaultNXProps.getInstance(); Boolean b = props.getBooleanValue("ArticleShowPoids"); if (b) { JPanel panelPoids = new JPanel(new GridBagLayout()); GridBagConstraints c2 = new DefaultGridBagConstraints(); c2.fill = GridBagConstraints.NONE; panelPoids.add(new JLabel(getLabelFor("TOTAL_POIDS")), c2); // Necessaire pour ne pas avoir de saut de layout DefaultGridBagConstraints.lockMinimumSize(this.textPoidsTotal); this.textPoidsTotal.setEnabled(false); this.textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT); this.textPoidsTotal.setDisabledTextColor(Color.BLACK); c2.gridx++; c2.weightx = 1; c2.fill = GridBagConstraints.HORIZONTAL; panelPoids.add(this.textPoidsTotal, c2); this.add(panelPoids, c); } c.gridx = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; final GridBagConstraints cTotalPan = new DefaultGridBagConstraints(); JPanel panelTotalHT = new JPanel(); panelTotalHT.setLayout(new GridBagLayout()); cTotalPan.gridx = 0; cTotalPan.weightx = 0; cTotalPan.fill = GridBagConstraints.HORIZONTAL; cTotalPan.anchor = GridBagConstraints.WEST; final JLabelBold labelTotalHT = new JLabelBold(getLabelFor("TOTAL_HT")); panelTotalHT.add(labelTotalHT, cTotalPan); cTotalPan.anchor = GridBagConstraints.EAST; cTotalPan.gridx++; cTotalPan.weightx = 1; this.textTotalHT.setFont(labelTotalHT.getFont()); DefaultGridBagConstraints.lockMinimumSize(this.textTotalHT); panelTotalHT.add(this.textTotalHT, cTotalPan); this.add(panelTotalHT, c); JPanel panelTotalTVA = new JPanel(); panelTotalTVA.setLayout(new GridBagLayout()); cTotalPan.gridx = 0; cTotalPan.weightx = 0; cTotalPan.anchor = GridBagConstraints.WEST; cTotalPan.fill = GridBagConstraints.HORIZONTAL; panelTotalTVA.add(new JLabelBold(getLabelFor("TOTAL_TVA")), cTotalPan); cTotalPan.anchor = GridBagConstraints.EAST; cTotalPan.gridx++; cTotalPan.weightx = 1; DefaultGridBagConstraints.lockMinimumSize(this.textTotalTVA); panelTotalTVA.add(this.textTotalTVA, cTotalPan); c.gridy++; c.fill = GridBagConstraints.HORIZONTAL; this.add(panelTotalTVA, c); JPanel panelTotalTTC = new JPanel(); panelTotalTTC.setLayout(new GridBagLayout()); cTotalPan.gridx = 0; cTotalPan.anchor = GridBagConstraints.WEST; cTotalPan.gridwidth = GridBagConstraints.REMAINDER; cTotalPan.fill = GridBagConstraints.BOTH; cTotalPan.weightx = 1; panelTotalTTC.add(new JSeparator(), cTotalPan); cTotalPan.gridwidth = 1; cTotalPan.fill = GridBagConstraints.NONE; cTotalPan.weightx = 0; cTotalPan.gridy++; panelTotalTTC.add(new JLabelBold(getLabelFor("TOTAL_TTC")), cTotalPan); cTotalPan.anchor = GridBagConstraints.EAST; cTotalPan.gridx++; this.textTotalTTC.setFont(labelTotalHT.getFont()); DefaultGridBagConstraints.lockMinimumSize(this.textTotalTTC); panelTotalTTC.add(this.textTotalTTC, cTotalPan); c.gridy++; // probleme de tremblement vertical this.add(panelTotalTTC, c); c.anchor = GridBagConstraints.WEST; /******************************************************************************************* * * INFORMATIONS COMPLEMENTAIRES ******************************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy++; TitledSeparator sep = new TitledSeparator("Informations complmentaires"); c.insets = new Insets(10, 2, 1, 2); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); c.gridx = 0; c.gridy++; c.gridheight = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.BOTH; final ITextArea textInfos = new ITextArea(4, 4); JScrollPane scrollPane = new JScrollPane(textInfos); DefaultGridBagConstraints.lockMinimumSize(scrollPane); this.add(textInfos, c); this.addRequiredSQLObject(date, "DATE"); this.addSQLObject(textInfos, "INFOS"); this.addSQLObject(this.textReference, "NOM"); this.addSQLObject(this.selectCommande, "ID_COMMANDE"); this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO"); this.addSQLObject(this.textPoidsTotal, "TOTAL_POIDS"); this.addRequiredSQLObject(this.textTotalHT, "TOTAL_HT"); this.addRequiredSQLObject(this.textTotalTVA, "TOTAL_TVA"); this.addRequiredSQLObject(this.textTotalTTC, "TOTAL_TTC"); this.addRequiredSQLObject(this.fournisseur, "ID_FOURNISSEUR"); this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(BonReceptionSQLElement.class)); // Listeners this.tableBonItem.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { int columnIndexHT = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement( BonReceptionSQLComponent.this.tableBonItem.getPrixTotalHTElement()); int columnIndexTTC = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement( BonReceptionSQLComponent.this.tableBonItem.getPrixTotalTTCElement()); int columnIndexPoids = BonReceptionSQLComponent.this.tableBonItem.getModel() .getColumnIndexForElement( BonReceptionSQLComponent.this.tableBonItem.getPoidsTotalElement()); if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexHT || e.getColumn() == columnIndexTTC) { updateTotal(); } if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexPoids) { BonReceptionSQLComponent.this.textPoidsTotal.setText(String .valueOf(Math.round(BonReceptionSQLComponent.this.tableBonItem.getPoidsTotal() * 1000) / 1000.0)); } } }); // Lock UI DefaultGridBagConstraints.lockMinimumSize(this.fournisseur); }