List of usage examples for java.awt GridBagConstraints BOTH
int BOTH
To view the source code for java.awt GridBagConstraints BOTH.
Click Source Link
From source file:com.wet.wired.jsr.player.JPlayer.java
public void showWindow() { setTitle("TestingOwl Player"); setIconImage(owl.getWelcomeIcon().getImage()); getContentPane().removeAll();//from w w w. j ava 2s . com JPanel panel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); panel.setLayout(gbl); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { closePlayer(); System.exit(0); } }); open = new JButton("Open Recording"); open.setActionCommand("open"); open.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0; gbc.weighty = 1; panel.add(open, gbc); reset = new JButton("Reset"); reset.setActionCommand("reset"); reset.setEnabled(false); reset.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 1; gbc.gridy = 0; gbc.weightx = 0; gbc.weighty = 1; panel.add(reset, gbc); play = new JButton("Play"); play.setActionCommand("play"); play.setEnabled(false); play.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 2; gbc.gridy = 0; gbc.weightx = 0; gbc.weighty = 1; panel.add(play, gbc); fastForward = new JButton("Fast Forward"); fastForward.setActionCommand("fastForward"); fastForward.setEnabled(false); fastForward.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 3; gbc.gridy = 0; gbc.weightx = 0; gbc.weighty = 1; panel.add(fastForward, gbc); pause = new JButton("Pause"); pause.setActionCommand("pause"); pause.setEnabled(false); pause.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 4; gbc.gridy = 0; gbc.weightx = 0; gbc.weighty = 1; panel.add(pause, gbc); close = new JButton("Close File"); close.setActionCommand("close"); close.setEnabled(false); close.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 5; gbc.gridy = 0; gbc.weightx = 0; gbc.weighty = 1; panel.add(close, gbc); // slider gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 6; gbc.gridy = 0; gbc.weightx = 1; gbc.weighty = 1; panel.add(createSliderLayout(), gbc); soundLevel.setSize(30, (int) close.getSize().getHeight()); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 7; gbc.gridy = 0; gbc.weightx = 0; gbc.weighty = 1; panel.add(soundLevel, gbc); recorder = new JButton("to Recorder"); recorder.setActionCommand("recorder"); recorder.setEnabled(true); recorder.addActionListener(this); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 8; gbc.gridy = 0; gbc.weightx = 0; gbc.weighty = 1; panel.add(recorder, gbc); panel.doLayout(); this.getContentPane().add(panel, BorderLayout.NORTH); panel = new JPanel(); panel.setLayout(new GridLayout(1, 2)); frameLabel = new JLabel("Frame: 0 Time: 0"); frameLabel.setForeground(Color.black); text = new JLabel("No recording selected"); text.setForeground(Color.black); panel.add(text); panel.add(frameLabel); this.getContentPane().add(panel, BorderLayout.SOUTH); this.setSize(700, this.getHeight()); this.pack(); this.setVisible(true); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.StartupDialog.java
/** * Initialises all GUI elements./*from www . j a v a 2 s . c o m*/ */ private void initGui() { this.setResizable(false); this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); cancelButton = new JButton("Don't log in"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); storeCredentialsButton = new JButton("Store Credentials"); storeCredentialsButton.setActionCommand("StoreCredentials"); storeCredentialsButton.addActionListener(this); okButton = new JButton("Log in"); okButton.setActionCommand("LogIn"); okButton.addActionListener(this); // Set default ENTER and ESCAPE buttons. this.getRootPane().setDefaultButton(okButton); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = -1742280851624947873L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); JPanel buttonsPanel = new JPanel(new GridBagLayout()); buttonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); buttonsPanel.add(storeCredentialsButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); buttonsPanel.add(okButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); loginPassphrasePanel = new LoginPassphrasePanel(hyperlinkListener); loginLocalFolderPanel = new LoginLocalFolderPanel(ownerFrame, hyperlinkListener); loginCredentialsPanel = new LoginCredentialsPanel(false, hyperlinkListener); // Tabbed Pane. tabbedPane = new JTabbedPane(); tabbedPane.addChangeListener(this); tabbedPane.add(loginPassphrasePanel, "S3 Online"); tabbedPane.add(loginLocalFolderPanel, "Local Folder"); tabbedPane.add(loginCredentialsPanel, "Direct Login"); int row = 0; this.getContentPane().setLayout(new GridBagLayout()); this.getContentPane().add(tabbedPane, new GridBagConstraints(0, row++, 2, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); this.getContentPane().add(buttonsPanel, new GridBagConstraints(0, row++, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); this.pack(); this.setSize(500, 400); this.setLocationRelativeTo(this.getOwner()); }
From source file:com.polivoto.vistas.Charts.java
public void getBotonesPreguntas(JPanel botones) { GridBagConstraints gridBagConstraints; boolean first = false; botones.removeAll();//from w w w.ja va 2 s.c o m JPanel panelRelleno = new JPanel(new BorderLayout(20, 20)); panelRelleno.setBackground(Color.white); JPanel panelContainer = new JPanel(new GridLayout(0, 1, 30, 30)); panelContainer.setBackground(Color.white); botones.setPreferredSize(new Dimension(250, 0)); botones.setLayout(new GridBagLayout()); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); botones.add(panelContainer, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.9; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); botones.add(panelRelleno, gridBagConstraints); JLabel labelPreguntas = new JLabel("PREGUNTAS"); labelPreguntas.setFont(new Font("Roboto", 1, 24)); labelPreguntas.setHorizontalAlignment(0); labelPreguntas.setForeground(new Color(137, 36, 31)); panelContainer.add(labelPreguntas); for (Pregunta pregunta : votacion.getPreguntas()) { Boton boton = new Boton("<html><div align=center>" + pregunta.getTitulo() + "</html>") { @Override public void botonClicked(Boton e) { crearGrafica(pregunta); botonActual = e; } }; boton.setPreferredSize(new Dimension(200, 0)); panelContainer.add(boton); if (!first) { botonActual = boton; first = true; } } botones.repaint(); botones.revalidate(); }
From source file:com.digitalgeneralists.assurance.ui.components.ScanPathMappingPanel.java
protected void initializeComponent() { if (!this.initialized) { if (this.mappingDefinition == null) { this.mode = AssuranceDialogMode.ADD; this.dialogTitle = "Add New Path Mapping"; this.mappingDefinition = new ScanMappingDefinition(); } else {//from w w w . j a v a 2 s. co m this.mode = AssuranceDialogMode.EDIT; this.dialogTitle = "Edit Path Mapping"; } GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); final JPanel scanPathsPanel = new JPanel(); scanPathsPanel.setLayout(new GridBagLayout()); Border pathsPanelBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); pathsPanelBorder = BorderFactory.createTitledBorder(pathsPanelBorder, "Paths", TitledBorder.CENTER, TitledBorder.TOP); GridBagConstraints scanPathsPanelConstraints = new GridBagConstraints(); scanPathsPanelConstraints.anchor = GridBagConstraints.NORTH; scanPathsPanelConstraints.fill = GridBagConstraints.HORIZONTAL; scanPathsPanelConstraints.gridx = 0; scanPathsPanelConstraints.gridy = 0; scanPathsPanelConstraints.weightx = 1.0; scanPathsPanelConstraints.weighty = 1.0; scanPathsPanelConstraints.gridheight = 1; scanPathsPanelConstraints.gridwidth = 2; scanPathsPanelConstraints.insets = new Insets(5, 5, 5, 5); scanPathsPanel.setBorder(pathsPanelBorder); this.add(scanPathsPanel, scanPathsPanelConstraints); GridBagConstraints sourcePathFieldConstraints = new GridBagConstraints(); sourcePathFieldConstraints.anchor = GridBagConstraints.NORTH; sourcePathFieldConstraints.fill = GridBagConstraints.HORIZONTAL; sourcePathFieldConstraints.gridx = 0; sourcePathFieldConstraints.gridy = 0; sourcePathFieldConstraints.weightx = 1.0; sourcePathFieldConstraints.weighty = 1.0; sourcePathFieldConstraints.gridheight = 1; sourcePathFieldConstraints.gridwidth = 1; sourcePathFieldConstraints.insets = new Insets(0, 5, 5, 5); GridBagConstraints targetPathFieldConstraints = new GridBagConstraints(); targetPathFieldConstraints.anchor = GridBagConstraints.NORTH; targetPathFieldConstraints.fill = GridBagConstraints.HORIZONTAL; targetPathFieldConstraints.gridx = 0; targetPathFieldConstraints.gridy = 1; targetPathFieldConstraints.weightx = 1.0; targetPathFieldConstraints.weighty = 1.0; targetPathFieldConstraints.gridheight = 1; targetPathFieldConstraints.gridwidth = 1; targetPathFieldConstraints.insets = new Insets(5, 5, 5, 5); scanPathsPanel.add(this.sourcePathPickerField, sourcePathFieldConstraints); scanPathsPanel.add(this.targetPathPickerField, targetPathFieldConstraints); if (mappingDefinition != null) { File source = mappingDefinition.getSource(); if (source != null) { this.sourcePathPickerField.setValue(source.getPath()); } else { this.sourcePathPickerField.setValue(""); } File target = mappingDefinition.getTarget(); if (target != null) { this.targetPathPickerField.setValue(target.getPath()); } else { this.targetPathPickerField.setValue(""); } } Border existingExclusionsPanelBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); existingExclusionsPanelBorder = BorderFactory.createTitledBorder(existingExclusionsPanelBorder, "Exclusions", TitledBorder.CENTER, TitledBorder.TOP); GridBagConstraints existingExclusionsPanelConstraints = new GridBagConstraints(); existingExclusionsPanelConstraints.anchor = GridBagConstraints.WEST; existingExclusionsPanelConstraints.fill = GridBagConstraints.BOTH; existingExclusionsPanelConstraints.gridx = 0; existingExclusionsPanelConstraints.gridy = 1; existingExclusionsPanelConstraints.weightx = 1.0; existingExclusionsPanelConstraints.weighty = 0.9; existingExclusionsPanelConstraints.gridheight = 1; existingExclusionsPanelConstraints.gridwidth = 2; existingExclusionsPanelConstraints.insets = new Insets(0, 5, 0, 5); JPanel existingExclusionsPanel = new JPanel(); GridBagLayout panelGridbag = new GridBagLayout(); existingExclusionsPanel.setLayout(panelGridbag); existingExclusionsPanel.setBorder(existingExclusionsPanelBorder); this.add(existingExclusionsPanel, existingExclusionsPanelConstraints); GridBagConstraints existingExclusionsListConstraints = new GridBagConstraints(); existingExclusionsListConstraints.anchor = GridBagConstraints.WEST; existingExclusionsListConstraints.fill = GridBagConstraints.BOTH; existingExclusionsListConstraints.gridx = 0; existingExclusionsListConstraints.gridy = 0; existingExclusionsListConstraints.weightx = 1.0; existingExclusionsListConstraints.weighty = 0.9; existingExclusionsListConstraints.gridheight = 1; existingExclusionsListConstraints.gridwidth = 2; existingExclusionsListConstraints.insets = new Insets(5, 5, 5, 5); this.mappingDefinition = (ScanMappingDefinition) ModelUtils.initializeEntity(this.mappingDefinition, ScanMappingDefinition.EXCLUSIONS_PROPERTY); this.exclusionsPanel = new ListInputPanel<FileReference>(this.mappingDefinition, this); existingExclusionsPanel.add(this.exclusionsPanel, existingExclusionsListConstraints); this.initialized = true; } }
From source file:org.openconcerto.erp.core.finance.accounting.element.AnalytiqueSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.anchor = GridBagConstraints.NORTHWEST; c.gridwidth = 4;//from w w w . j a va 2s . c o m c.gridheight = 8; vecteurTabAxe = new Vector(); repartitionsAxe = new Vector(); repartitionElemsAxe = new Vector(); postesAxe = new Vector(); tabAxes = new JTabbedPane(); /*********************************************************************************** * * CREATION DES ONGLETS **********************************************************************************/ // on recupere les axes existant // SELECT ID, NOM FROM AXE SQLBase base = getTable().getBase(); SQLSelect sel = new SQLSelect(base); sel.addSelect(getTable().getKey()); sel.addSelect(getTable().getField("NOM")); sel.addRawOrder("AXE_ANALYTIQUE.NOM"); String req = sel.asString(); Object ob = getTable().getBase().getDataSource().execute(req, new ArrayListHandler()); List myList = (List) ob; if (myList.size() != 0) { // on cre les onglets et on stocke les axes for (int i = 0; i < myList.size(); i++) { // ID, nom Object[] objTmp = (Object[]) myList.get(i); axes.add(new Axe(Integer.parseInt(objTmp[0].toString()), objTmp[1].toString())); // on recupere les repartitions et les lements associs l'axe RepartitionAxeAnalytiquePanel repAxeComp = new RepartitionAxeAnalytiquePanel( ((Axe) axes.get(i)).getId()); repartitionsAxe.add(repAxeComp.getRepartitions()); repartitionElemsAxe.add(repAxeComp.getRepartitionElems()); postesAxe.add(repAxeComp.getPostes()); tabAxes.addTab(((Axe) axes.get(i)).getNom(), repAxeComp); vecteurTabAxe.add(i, new String(String.valueOf(i))); } System.out.println("Size ----> " + axes.size()); } else { ajouterAxe("Nouvel Axe"); } c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; this.add(tabAxes, c); tabAxes.addMouseListener(new MouseAdapter() { public void mousePressed(final MouseEvent e) { final int index = tabAxes.indexAtLocation(e.getX(), e.getY()); validAxeText(); if (e.getClickCount() == 2) { actionModifierAxe(e, index); } if (e.getButton() == MouseEvent.BUTTON3) { actionDroitOnglet(index, e); } } }); tabAxes.addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { validAxeText(); } public void ancestorRemoved(AncestorEvent event) { validAxeText(); } public void ancestorMoved(AncestorEvent event) { validAxeText(); } }); /*********************************************************************************** * * AJOUT D'UN AXE **********************************************************************************/ JButton boutonAddAxe = new JButton("Ajouter un axe"); boutonAddAxe.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (ajoutAxeFrame == null) { ajoutAxeFrame = new AjouterAxeAnalytiqueFrame(a); } ajoutAxeFrame.pack(); ajoutAxeFrame.setVisible(true); } }); c.gridx += 4; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(boutonAddAxe, c); /*********************************************************************************** * * SUPPRESSION D'UN AXE **********************************************************************************/ JButton boutonDelAxe = new JButton("Supprimer un axe"); boutonDelAxe.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { supprimerAxe(Integer.parseInt(vecteurTabAxe.get(tabAxes.getSelectedIndex()).toString())); } }); c.gridy++; this.add(boutonDelAxe, c); JButton boutonSet = new JButton("SetVal"); boutonSet.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setVal(); } }); c.gridy++; this.add(boutonSet, c); JButton boutonCheck = new JButton("Check"); boutonCheck.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { checkID(); } }); c.gridy++; this.add(boutonCheck, c); } }; }
From source file:de.codesourcery.jasm16.ide.ui.views.CPUView.java
protected JPanel createPanel() { textArea.setFont(getMonospacedFont()); textArea.setEditable(false);//from ww w.j a va 2 s. c o m setColors(textArea); final JPanel panel = new JPanel(); setColors(panel); panel.setLayout(new GridBagLayout()); final GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH); panel.add(textArea, cnstrs); return panel; }
From source file:de.codesourcery.jasm16.ide.ui.views.ProjectConfigurationView.java
@Override protected JPanel getPanel() { final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); // project name int y = 0;// w w w. j a v a 2 s. c o m GridBagConstraints cnstrs = constraints(0, y, false, false, GridBagConstraints.NONE); result.add(new JLabel("Project name"), cnstrs); cnstrs = constraints(1, y++, true, false, GridBagConstraints.NONE); result.add(projectName, cnstrs); // build options panel final JPanel buildOptionsPanel = new JPanel(); buildOptionsPanel.setLayout(new GridBagLayout()); buildOptionsPanel.setBorder(BorderFactory.createTitledBorder("Build options")); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Compilation root"), cnstrs); cnstrs = constraints(1, 0, false, false, GridBagConstraints.NONE); compilationRootName.setEditable(false); compilationRootName.setColumns(25); buildOptionsPanel.add(compilationRootName, cnstrs); cnstrs = constraints(2, 0, true, false, GridBagConstraints.NONE); buildOptionsPanel.add(compilationRootButton, cnstrs); compilationRootButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser chooser; File baseDir = null; if (project != null) { baseDir = project.getConfiguration().getBaseDirectory(); } if (StringUtils.isNotBlank(compilationRootName.getText())) { File tmp = new File(compilationRootName.getText()).getParentFile(); if (tmp.exists() && tmp.isDirectory()) { baseDir = tmp; } } if (baseDir != null) { chooser = new JFileChooser(baseDir); } else { chooser = new JFileChooser(); } final int result = chooser.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile().isFile()) { compilationRootName.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); // generate self-relocating code ? cnstrs = constraints(0, 1, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Generate self-relocating code?"), cnstrs); cnstrs = constraints(1, 1, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; buildOptionsPanel.add(generateSelfRelocatingCode, cnstrs); // inline short literals ? cnstrs = constraints(0, 2, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Inline short literals?"), cnstrs); cnstrs = constraints(1, 2, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; buildOptionsPanel.add(inlineShortLiterals, cnstrs); // add build options panel to parent cnstrs = constraints(0, y++, true, false, GridBagConstraints.BOTH); cnstrs.gridwidth = 2; result.add(buildOptionsPanel, cnstrs); // buttons final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); buttonPanel.add(saveButton, cnstrs); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (hasValidInput()) { onSave(); } } }); cnstrs = constraints(1, 0, true, true, GridBagConstraints.NONE); buttonPanel.add(cancelButton, cnstrs); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onCancel(); } }); // button panel cnstrs = constraints(0, y++, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; result.add(buttonPanel, cnstrs); return result; }
From source file:com.intel.stl.ui.monitor.view.PSNodesDetailsPanel.java
/** * Description:// www .j a v a2 s . c o m * * @param name */ protected void initComponent() { setLayout(new BorderLayout(0, 0)); setOpaque(false); setBorder(BorderFactory.createTitledBorder((Border) null)); JPanel titlePanel = new JPanel(new BorderLayout(5, 1)); titlePanel.setOpaque(false); numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); numberLabel.setHorizontalAlignment(JLabel.RIGHT); titlePanel.add(numberLabel, BorderLayout.CENTER); nameLabel = ComponentFactory.getH3Label("", Font.PLAIN); nameLabel.setHorizontalAlignment(JLabel.LEFT); nameLabel.setVerticalAlignment(JLabel.BOTTOM); titlePanel.add(nameLabel, BorderLayout.EAST); add(titlePanel, BorderLayout.NORTH); JPanel mainPanel = new JPanel(); mainPanel.setOpaque(false); mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); GridBagLayout gridBag = new GridBagLayout(); mainPanel.setLayout(gridBag); GridBagConstraints gc = new GridBagConstraints(); gc.weighty = 0; gc.insets = new Insets(8, 2, 2, 2); gc.weightx = 1; gc.gridwidth = 1; gc.gridheight = 2; // gc.gridheight = 3; // Should change to 3 if we add Route typeChartPanel = new ChartPanel(null); typeChartPanel.setPreferredSize(new Dimension(80, 60)); mainPanel.add(typeChartPanel, gc); gc.fill = GridBagConstraints.BOTH; gc.insets = new Insets(12, 2, 2, 2); gc.weightx = 0; gc.gridheight = 1; swNumberLabel = createNumberLabel(); mainPanel.add(swNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; swNameLabel = createNameLabel(STLConstants.K0048_SWITCHES.getValue()); mainPanel.add(swNameLabel, gc); gc.insets = new Insets(2, 2, 6, 2); gc.gridwidth = 1; fiNumberLabel = createNumberLabel(); mainPanel.add(fiNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; fiNameLabel = createNameLabel(STLConstants.K0052_HOSTS.getValue()); mainPanel.add(fiNameLabel, gc); // gc.gridwidth = 1; // rtNumberLabel = ComponentFactory.getH4Label( // STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); // rtNumberLabel.setHorizontalAlignment(JLabel.CENTER); // mainPanel.add(rtNumberLabel, gc); // // gc.gridwidth = GridBagConstraints.REMAINDER; // rtNameLabel = ComponentFactory.getH5Label( // STLConstants.K0050_ROUTERS.getValue(), Font.PLAIN); // rtNameLabel.setVerticalAlignment(JLabel.BOTTOM); // mainPanel.add(rtNameLabel, gc); add(mainPanel, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(new GridBagLayout()); bottomPanel.setOpaque(false); bottomPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.INTEL_BORDER_GRAY)); gc = new GridBagConstraints(); gc.insets = new Insets(0, 5, 1, 5); gc.fill = GridBagConstraints.BOTH; gc.weightx = 1; gc.gridheight = 2; otherPortsLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); otherPortsLabel.setForeground(UIConstants.INTEL_GRAY); otherPortsLabel.setHorizontalAlignment(JLabel.RIGHT); bottomPanel.add(otherPortsLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; gc.gridheight = 1; gc.weightx = 0; gc.weighty = 1; JLabel label = ComponentFactory.getH4Label(STLConstants.K1026_PORT_RESOURCE.getValue(), Font.PLAIN); label.setHorizontalAlignment(JLabel.LEFT); label.setVerticalAlignment(JLabel.BOTTOM); bottomPanel.add(label, gc); gc.weighty = 0; label = ComponentFactory.getH4Label(STLConstants.K2077_NOT_IN_FABRIC.getValue(), Font.PLAIN); label.setHorizontalAlignment(JLabel.LEFT); label.setVerticalAlignment(JLabel.BOTTOM); bottomPanel.add(label, gc); add(bottomPanel, BorderLayout.SOUTH); }
From source file:com.xmage.launcher.XMageLauncher.java
private XMageLauncher() { locale = Locale.getDefault(); //locale = new Locale("it", "IT"); messages = ResourceBundle.getBundle("MessagesBundle", locale); localize();/*from w w w . java2 s . c o m*/ serverConsole = new XMageConsole("XMage Server console"); clientConsole = new XMageConsole("XMage Client console"); frame = new JFrame(messages.getString("frameTitle") + " " + Config.getVersion()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(800, 500)); frame.setResizable(false); createToolbar(); ImageIcon icon = new ImageIcon(XMageLauncher.class.getResource("/icon-mage-flashed.png")); frame.setIconImage(icon.getImage()); Random r = new Random(); int imageNum = 1 + r.nextInt(17); ImageIcon background = new ImageIcon(new ImageIcon( XMageLauncher.class.getResource("/backgrounds/" + Integer.toString(imageNum) + ".jpg")).getImage() .getScaledInstance(800, 480, Image.SCALE_SMOOTH)); mainPanel = new JLabel(background) { @Override public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); Dimension lmPrefSize = getLayout().preferredLayoutSize(this); size.width = Math.max(size.width, lmPrefSize.width); size.height = Math.max(size.height, lmPrefSize.height); return size; } }; mainPanel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { grabPoint = e.getPoint(); mainPanel.getComponentAt(grabPoint); } }); mainPanel.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { // get location of Window int thisX = frame.getLocation().x; int thisY = frame.getLocation().y; // Determine how much the mouse moved since the initial click int xMoved = (thisX + e.getX()) - (thisX + grabPoint.x); int yMoved = (thisY + e.getY()) - (thisY + grabPoint.y); // Move window to this position int X = thisX + xMoved; int Y = thisY + yMoved; frame.setLocation(X, Y); } }); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(10, 10, 10, 10); Font font16 = new Font("Arial", Font.BOLD, 16); Font font12 = new Font("Arial", Font.PLAIN, 12); Font font12b = new Font("Arial", Font.BOLD, 12); mainPanel.add(Box.createRigidArea(new Dimension(250, 50))); ImageIcon logo = new ImageIcon(new ImageIcon(XMageLauncher.class.getResource("/label-xmage.png")).getImage() .getScaledInstance(150, 75, Image.SCALE_SMOOTH)); xmageLogo = new JLabel(logo); constraints.gridx = 3; constraints.gridy = 0; constraints.gridheight = 1; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.anchor = GridBagConstraints.EAST; mainPanel.add(xmageLogo, constraints); textArea = new JTextArea(5, 40); textArea.setEditable(false); textArea.setForeground(Color.WHITE); textArea.setBackground(Color.BLACK); DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); scrollPane = new JScrollPane(textArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); constraints.gridx = 2; constraints.gridy = 1; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.fill = GridBagConstraints.BOTH; mainPanel.add(scrollPane, constraints); labelProgress = new JLabel(messages.getString("progress")); labelProgress.setFont(font12); labelProgress.setForeground(Color.WHITE); constraints.gridy = 2; constraints.weightx = 0.0; constraints.weighty = 0.0; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.WEST; mainPanel.add(labelProgress, constraints); progressBar = new JProgressBar(0, 100); constraints.gridx = 3; constraints.weightx = 1.0; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(progressBar, constraints); JPanel pnlButtons = new JPanel(); pnlButtons.setLayout(new GridBagLayout()); pnlButtons.setOpaque(false); constraints.gridx = 0; constraints.gridy = 3; constraints.gridheight = GridBagConstraints.REMAINDER; constraints.fill = GridBagConstraints.BOTH; mainPanel.add(pnlButtons, constraints); btnLaunchClient = new JButton(messages.getString("launchClient")); btnLaunchClient.setToolTipText(messages.getString("launchClient.tooltip")); btnLaunchClient.setFont(font16); btnLaunchClient.setForeground(Color.GRAY); btnLaunchClient.setEnabled(false); btnLaunchClient.setPreferredSize(new Dimension(180, 60)); btnLaunchClient.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleClient(); } }); constraints.gridx = GridBagConstraints.RELATIVE; constraints.gridy = 0; constraints.gridwidth = 1; constraints.fill = GridBagConstraints.BOTH; pnlButtons.add(btnLaunchClient, constraints); btnLaunchClientServer = new JButton(messages.getString("launchClientServer")); btnLaunchClientServer.setToolTipText(messages.getString("launchClientServer.tooltip")); btnLaunchClientServer.setFont(font12b); btnLaunchClientServer.setEnabled(false); btnLaunchClientServer.setForeground(Color.GRAY); btnLaunchClientServer.setPreferredSize(new Dimension(80, 40)); btnLaunchClientServer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleServer(); handleClient(); } }); constraints.fill = GridBagConstraints.HORIZONTAL; pnlButtons.add(btnLaunchClientServer, constraints); btnLaunchServer = new JButton(messages.getString("launchServer")); btnLaunchServer.setToolTipText(messages.getString("launchServer.tooltip")); btnLaunchServer.setFont(font12b); btnLaunchServer.setEnabled(false); btnLaunchServer.setForeground(Color.GRAY); btnLaunchServer.setPreferredSize(new Dimension(80, 40)); btnLaunchServer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleServer(); } }); pnlButtons.add(btnLaunchServer, constraints); btnUpdate = new JButton(messages.getString("update.xmage")); btnUpdate.setToolTipText(messages.getString("update.xmage.tooltip")); btnUpdate.setFont(font12b); btnUpdate.setForeground(Color.BLACK); btnUpdate.setPreferredSize(new Dimension(80, 40)); btnUpdate.setEnabled(true); btnUpdate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleUpdate(); } }); pnlButtons.add(btnUpdate, constraints); btnCheck = new JButton(messages.getString("check.xmage")); btnCheck.setToolTipText(messages.getString("check.xmage.tooltip")); btnCheck.setFont(font12b); btnCheck.setForeground(Color.BLACK); btnCheck.setPreferredSize(new Dimension(80, 40)); btnCheck.setEnabled(true); btnCheck.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleCheckUpdates(); } }); pnlButtons.add(btnCheck, constraints); frame.add(mainPanel); frame.pack(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2); }
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.ADAP3DecompositionV2SetupDialog.java
@Override public void actionPerformed(ActionEvent e) { super.actionPerformed(e); final Object source = e.getSource(); if (source.equals(chkPreview)) { if (chkPreview.isSelected()) { // Set the height of the chkPreview to 200 cells, so it will span // the whole vertical length of the dialog (buttons are at row // no 100). Also, we set the weight to 10, so the chkPreview // component will consume most of the extra available space. mainPanel.add(pnlPlots, 3, 0, 1, 200, 10, 10, GridBagConstraints.BOTH); pnlUIElements.add(pnlComboBoxes, BorderLayout.CENTER); // cboPeakLists.setSelectedIndex(0); } else {//from ww w . ja va 2 s. c om mainPanel.remove(pnlPlots); pnlUIElements.remove(pnlComboBoxes); } updateMinimumSize(); pack(); setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow()); retTimeCluster(); } else if (source.equals(cboClusters)) { Cursor cursor = this.getCursor(); this.setCursor(new Cursor(Cursor.WAIT_CURSOR)); shapeCluster(); this.setCursor(cursor); } }