List of usage examples for java.awt GridBagConstraints GridBagConstraints
public GridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill, Insets insets, int ipadx, int ipady)
From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java
/** * {@inheritDoc}/* w ww . j a va 2s .co m*/ */ @Override protected void buildGUI() { setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // Create the transaction and status labels Insets insets5 = new Insets(5, 5, 5, 5); add(bold(new JLabel("Transaction ID:")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); add(transactionTxt, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0)); add(bold(new JLabel("Latest status:")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); add(statusTxt, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0)); // Create the info panel JPanel infoPanel = createInfoPanel(); add(infoPanel, new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0)); // Create the messages panel JScrollPane scrollPane = new JScrollPane(messagesPanel); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(new MatteBorder(1, 1, 1, 1, UIManager.getColor("Separator.shadow"))); messagesPanel.setBackground(UIManager.getColor("List.background")); add(scrollPane, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, WEST, BOTH, insets5, 0, 0)); }
From source file:com.lp.client.frame.component.PanelDiagramm.java
private void jbInit() throws Throwable { this.setLayout(new GridBagLayout()); jpaWorkingOn = new JPanel(new GridBagLayout()); chartPanel = new ChartPanel(null); JPanel panelButtonAction = getToolsPanel(); getInternalFrame().addItemChangedListener(this); this.add(panelButtonAction, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.add(jpaWorkingOn, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); }
From source file:com.simplexrepaginator.RepaginateFrame.java
public RepaginateFrame(FileRepaginator repaginator) { super("Simplex Repaginator version " + Repaginate.getVersion()); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.repaginator = repaginator; setJMenuBar(createMenuBar());/*w ww .j ava 2 s . co m*/ input = createInputButton(); repaginate = createRepaginateButton(); unrepaginate = createUnrepaginateButton(); output = creatOutputButton(); setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0); c.gridwidth = 2; add(input, c); c.gridy++; c.gridwidth = 1; c.fill = GridBagConstraints.VERTICAL; add(repaginate, c); c.gridx++; add(unrepaginate, c); c.gridy++; c.gridx = 0; c.gridwidth = 2; c.fill = GridBagConstraints.BOTH; add(output, c); Runnable r = new Runnable() { @Override public void run() { UpdateChecker uc = new UpdateChecker(); try { if (!uc.isUpdateAvailable()) return; final JLabel label = new JLabel("<html>Simplex Repaginator version " + uc.getLatestVersion() + " is available. " + "Choose <b>File > Check For Updates</b> to download."); EventQueue.invokeLater(new Runnable() { @Override public void run() { c.gridy++; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; add(label, c); revalidate(); } }); } catch (IOException ioe) { } } }; new Thread(r).start(); pack(); setSize(800, 400); }
From source file:de.fhg.igd.iva.explorer.main.CompareViewPanel.java
protected void updateSelection() { KnownColormap colormap = (KnownColormap) mapsCombo.getSelectedItem(); cmView.setColormap(colormap);/*from www . j a va 2 s.co m*/ statsBars.removeAll(); Map<ColormapQuality, Double> row = table.row(colormap); Insets insets = new Insets(0, 0, 0, 0); Insets insets5 = new Insets(0, 5, 0, 0); GridBagConstraints gbcName = new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, insets, 0, 0); GridBagConstraints gbcQual = new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, insets5, 0, 0); GridBagConstraints gbcRank = new GridBagConstraints(2, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, insets5, 0, 0); GridBagConstraints gbcStatL = new GridBagConstraints(3, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, insets5, 0, 0); GridBagConstraints gbcStatR = new GridBagConstraints(4, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, insets5, 0, 0); GridBagConstraints gbcStat = new GridBagConstraints(3, 0, 2, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, insets5, 0, 0); statsBars.add(new JLabel("Name"), gbcName); statsBars.add(new JLabel("Score"), gbcQual); statsBars.add(new JLabel("Rank"), gbcRank); // maybe use a best/worst arrow down marker instead? unicode: \u2193 statsBars.add(new JLabel("\u2190Worse"), gbcStatL); statsBars.add(new JLabel("Better\u2192"), gbcStatR); GridBagConstraints gbcSpace = new GridBagConstraints(0, 1, 5, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0); JSeparator spacing = new JSeparator(SwingConstants.HORIZONTAL); statsBars.add(spacing, gbcSpace); int count = table.rowKeySet().size(); int rowIdx = 2; for (ColormapQuality metric : row.keySet()) { double quality = row.get(metric); DescriptiveStatistics stats = computeStats(metric); int index = Arrays.binarySearch(stats.getSortedValues(), quality); int rank = metric.moreIsBetter() ? count - index : index + 1; gbcName = (GridBagConstraints) gbcName.clone(); gbcQual = (GridBagConstraints) gbcQual.clone(); gbcRank = (GridBagConstraints) gbcRank.clone(); gbcStat = (GridBagConstraints) gbcStat.clone(); gbcName.gridy = rowIdx; gbcQual.gridy = rowIdx; gbcRank.gridy = rowIdx; gbcStat.gridy = rowIdx; statsBars.add(new JLabel(metric.getName()), gbcName); statsBars.add(new JLabel(String.format("%.2f", quality)), gbcQual); statsBars.add(new JLabel(Integer.toString(rank)), gbcRank); statsBars.add(new JStatBar(metric, stats, quality), gbcStat); rowIdx++; } // I find it strange that both revalidate and repaint must be explicitly called here revalidate(); repaint(); }
From source file:dk.dma.epd.shore.gui.notification.StrategicRouteNotificationDetailPanel.java
/** * {@inheritDoc}//ww w.ja v a 2 s. c om */ @Override protected JPanel createInfoPanel() { // Initialize member variables here, since this method // is called by super's constructor mmsiTxt = new JLabel(" "); nameTxt = new JLabel(" "); callSignTxt = new JLabel(" "); destinationTxt = new JLabel(" "); sogTxt = new JLabel(" "); typeTxt = new JLabel(" "); lengthTxt = new JLabel(" "); widthTxt = new JLabel(" "); draughtTxt = new JLabel(" "); cogTxt = new JLabel(" "); String[] infoTitles = { "MMSI:", "Name:", "Call Sign:", "Destination:", "SOG:", "Type:", "Lenght:", "Width:", "Draught:", "COG:" }; infoLabels = new JLabel[] { mmsiTxt, nameTxt, callSignTxt, destinationTxt, sogTxt, typeTxt, lengthTxt, widthTxt, draughtTxt, cogTxt }; int[] infoCols = { 5, 5 }; JPanel infoPanel = new JPanel(new GridBagLayout()); Insets insets2 = new Insets(2, 5, 2, 5); infoPanel.setBorder(BorderFactory.createTitledBorder("Ship Info")); for (int col = 0, index = 0; col < infoCols.length; col++) { for (int row = 0; row < infoCols[col]; row++, index++) { infoPanel.add(bold(new JLabel(infoTitles[index])), new GridBagConstraints(col * 2, row, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); infoPanel.add(minSize(infoLabels[index], 40), new GridBagConstraints(col * 2 + 1, row, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets2, 0, 0)); } } return infoPanel; }
From source file:org.bench4Q.console.ui.section.R_RealSessionShowSection.java
/** * @param resources//from w w w. j av a 2 s . c om * @param processControl * @param agentsCollection * @throws ConsoleException */ public R_RealSessionShowSection(Resources resources, ProcessControl processControl, AgentsCollection agentsCollection) throws ConsoleException { m_resources = resources; m_processControl = processControl; m_agentsCollection = agentsCollection; m_agentsCollection.registerObserver(this); this.setLayout(new GridBagLayout()); this.setPreferredSize(new Dimension(683, 475)); this.setMinimumSize(new Dimension(683, 475)); testduring = -1; resultNumber = 0; picPanel = new PicPanel(); this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1)); }
From source file:org.bench4Q.console.ui.section.R_RealTransactionShowSection.java
/** * @param resources/* w w w .j ava 2 s . c o m*/ * @param processControl * @param agentsCollection * @throws ConsoleException */ public R_RealTransactionShowSection(Resources resources, ProcessControl processControl, AgentsCollection agentsCollection) throws ConsoleException { m_resources = resources; m_processControl = processControl; m_agentsCollection = agentsCollection; m_agentsCollection.registerObserver(this); this.setLayout(new GridBagLayout()); this.setPreferredSize(new Dimension(683, 475)); this.setMinimumSize(new Dimension(683, 475)); testduring = -1; resultNumber = 0; picPanel = new PicPanel(); this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1)); }
From source file:org.bench4Q.console.ui.section.LW_ConfigLoadShowSection.java
/** * @param resources// www . j a va 2s .c o m * @param processControl * @param dispatcherFactory * @param configModel * @param configLoadSection * @throws ConsoleException */ public LW_ConfigLoadShowSection(Resources resources, ProcessControl processControl, SwingDispatcherFactory dispatcherFactory, ConfigModel configModel, LW_ConfigLoadSection configLoadSection) throws ConsoleException { m_resources = resources; m_processControl = processControl; m_swingDispatcherFactory = dispatcherFactory; m_configModel = configModel; m_args = m_configModel.getArgs(); this.setLayout(new GridBagLayout()); this.setPreferredSize(new Dimension(683, 475)); this.setMinimumSize(new Dimension(683, 475)); picPanel = new PicPanel(m_args); // JPanel picPanel = new JPanel(); this.add(picPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); m_configModel.addListener(new ConfigModel.AbstractListener() { public void isArgsChanged() { resetConfig(); } }); configLoadSection.addListener(new LW_ConfigLoadSection.AbstractListener() { public void isArgsChanged() { resetConfig(); } }); }
From source file:StoppUhr.java
private void initGUI() { try {//from w ww . ja v a 2s . c o m AnchorLayout thisLayout = new AnchorLayout(); getContentPane().setLayout(thisLayout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setPreferredSize(new java.awt.Dimension(609, 394)); { jPanel3 = new JPanel(); GridBagLayout jPanel3Layout = new GridBagLayout(); jPanel3.setLayout(jPanel3Layout); getContentPane().add(jPanel3, new AnchorConstraint(668, 811, 978, 19, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jPanel3.setPreferredSize(new java.awt.Dimension(384, 94)); { jScrollPane1 = new JScrollPane(); jPanel3.add(jScrollPane1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 90)); { jTextArea = new JTextArea(); jScrollPane1.setViewportView(jTextArea); jTextArea.setText(""); } } { jTextFieldStNr = new JTextField(); jPanel3.add(jTextFieldStNr, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jTextFieldStNr.setText(""); jTextFieldStNr.setPreferredSize(new java.awt.Dimension(150, 90)); jTextFieldStNr.setHorizontalAlignment(JTextField.CENTER); jTextFieldStNr.setFont(new Font(Font.DIALOG, Font.BOLD, 40)); } jPanel3Layout.rowWeights = new double[] { 0.1 }; jPanel3Layout.rowHeights = new int[] { 7 }; jPanel3Layout.columnWeights = new double[] { 0.1, 0.1 }; jPanel3Layout.columnWidths = new int[] { 7, 7 }; } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[] { 0.1, 0.1 }; jPanel2Layout.rowHeights = new int[] { 7, 7 }; jPanel2Layout.columnWeights = new double[] { 0.1 }; jPanel2Layout.columnWidths = new int[] { 7 }; jPanel2.setLayout(jPanel2Layout); getContentPane().add(jPanel2, new AnchorConstraint(47, 821, 721, 27, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jPanel2.setPreferredSize(new java.awt.Dimension(363, 178)); { uhrzeitAusgabe = new JLabel(); jPanel2.add(uhrzeitAusgabe, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); uhrzeitAusgabe.setText("00:00:00"); uhrzeitAusgabe.setFont(new Font(Font.DIALOG, Font.BOLD, uhrFontSize)); } { stoppuhrAusgabe = new JLabel(); jPanel2.add(stoppuhrAusgabe, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); stoppuhrAusgabe.setText("00:00:00"); stoppuhrAusgabe.setFont(new Font(Font.DIALOG, Font.BOLD, uhrFontSize)); } } { jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); getContentPane().add(jPanel1, new AnchorConstraint(48, 987, 954, 820, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jPanel1Layout.rowWeights = new double[] { 0.1, 0.1, 0.1, 1.0, 0.1 }; jPanel1Layout.rowHeights = new int[] { 1, 1, 1, 1, 1 }; jPanel1Layout.columnWeights = new double[] { 0.1 }; jPanel1Layout.columnWidths = new int[] { 7 }; jPanel1.setLayout(jPanel1Layout); jPanel1.setPreferredSize(new java.awt.Dimension(100, 330)); { startButton = new JButton(); jPanel1.add(startButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); startButton.setPreferredSize(new java.awt.Dimension(90, 30)); startButton.setText("Start"); } { resetButton = new JButton(); jPanel1.add(resetButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); resetButton.setText("Reset"); resetButton.setPreferredSize(new java.awt.Dimension(90, 30)); } { jPanel4 = new JPanel(); GridBagLayout jPanel4Layout = new GridBagLayout(); jPanel1.add(jPanel4, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel4.setPreferredSize(new java.awt.Dimension(51, 81)); jPanel4Layout.rowWeights = new double[] { 0.1, 0.1, 0.1 }; jPanel4Layout.rowHeights = new int[] { 7, 7, 7 }; jPanel4Layout.columnWeights = new double[] { 0.1 }; jPanel4Layout.columnWidths = new int[] { 7 }; jPanel4.setLayout(jPanel4Layout); { plusButton = new JButton(); jPanel4.add(plusButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); plusButton.setText("+"); plusButton.setPreferredSize(new java.awt.Dimension(50, 30)); } { minusButton = new JButton(); jPanel4.add(minusButton, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); minusButton.setText("-"); minusButton.setPreferredSize(new java.awt.Dimension(50, 30)); } { jLabelFontSize = new JLabel(); jPanel4.add(jLabelFontSize, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabelFontSize.setFont(new Font(Font.DIALOG, Font.PLAIN, 10)); jLabelFontSize.setText("Font Size"); } } } this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { thisWindowClosing(evt); } }); startButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startButtonListener(evt); } }); resetButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { resetButtonListener(evt); } }); jTextFieldStNr.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { try { stNrFieldListener(evt); } catch (IOException e) { e.printStackTrace(); } } }); plusButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { plusButtonListener(evt); } }); minusButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { minusButtonListener(evt); } }); pack(); this.setSize(609, 394); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:com.lp.client.frame.component.PanelDiagramm.java
public void eventYouAreSelected(boolean bNeedNoYouAreSelectedI) throws Throwable { jpaWorkingOn.removeAll();//from w ww .j a v a 2 s .c o m diagrammDto = buildDiagrammDto(); if (diagrammDto.getJfcKapazitaetsvorschau() != null) { chartPanel = new ChartPanel(diagrammDto.getJfcKapazitaetsvorschau()); jpaWorkingOn.add(chartPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); chartPanel.addChartMouseListener(this); } // Refreshknopf reaktivieren // updateButtons(new LockStateValue(null, null, PanelBasis.LOCK_IS_NOT_LOCKED)); super.eventYouAreSelected(false); }