List of usage examples for javax.swing JPanel setOpaque
@BeanProperty(expert = true, description = "The component's opacity") public void setOpaque(boolean isOpaque)
From source file:org.processmining.analysis.performance.fsmevaluator.FSMEvaluationMenuUI.java
protected void showConfigurationPanel() { if (configurationPanel == null) { // setup configuration panel updateFrameworkResources();//from w ww . j a va 2 s.c om configurationPanel = new JPanel(); configurationPanel.setLayout(new BorderLayout()); configurationPanel.setBackground(COLOR_OUTER_BG); // setup logs panel ArrayList<String> values = new ArrayList<String>(); Iterator<String> itr = logReaders.keySet().iterator(); while (itr.hasNext()) { values.add(itr.next()); } logsEnumeration = new GUIPropertyListEnumeration("Event Log :", null, values, null, 180); // initializing Logs RoundedPanel content = new RoundedPanel(10, 5, 5); content.setBackground(COLOR_BG); content.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); content.setLayout(new BoxLayout(content, BoxLayout.LINE_AXIS)); content.add(logsEnumeration.getPropertyPanel()); // initializing Time Sort initTimeSort(); RoundedPanel content2 = new RoundedPanel(10, 5, 5); content2.setBackground(COLOR_BG); content2.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); content2.setLayout(new BoxLayout(content2, BoxLayout.LINE_AXIS)); content2.add(timeUnitSort.getPropertyPanel()); // initializing Measure ArrayList<String> values2 = new ArrayList<String>(); values2.add(MEAN); values2.add(MEDIAN); values2.add(MIN); values2.add(HEUST1); values2.add(HEUST2); estimatorSort = new GUIPropertyListEnumeration("Estimator:", null, values2, null, 180); RoundedPanel content3 = new RoundedPanel(10, 5, 5); content3.setBackground(COLOR_BG); content3.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); content3.setLayout(new BoxLayout(content3, BoxLayout.LINE_AXIS)); content3.add(estimatorSort.getPropertyPanel()); // setup reference model / log configuration panel JPanel startPanel = new JPanel(); startPanel.setOpaque(false); startPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); startPanel.setLayout(new BoxLayout(startPanel, BoxLayout.X_AXIS)); startButton = new AutoFocusButton("start calculation"); if (RuntimeUtils.isRunningMacOsX() == true) { startButton.setOpaque(true); } startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { startCalculation(); } }); startButton.setEnabled(true); startPanel.add(Box.createHorizontalGlue()); startPanel.add(startButton); rightPanel = new JPanel(); rightPanel.setOpaque(false); rightPanel.setBorder(BorderFactory.createEmptyBorder()); rightPanel.setLayout(new BorderLayout()); // blank panel JPanel blankPanel = new JPanel(); blankPanel.setOpaque(false); blankPanel.setBorder(BorderFactory.createEmptyBorder()); blankPanel.setLayout(new BorderLayout()); JPanel leftPanel = new JPanel(); leftPanel.setOpaque(false); leftPanel.setBorder(BorderFactory.createEmptyBorder()); leftPanel.setLayout(new BorderLayout()); leftPanel.add(content, BorderLayout.CENTER); leftPanel.add(content2, BorderLayout.SOUTH); leftPanel.add(content3, BorderLayout.NORTH); // add benchmark item list to west rightPanel.add(blankPanel, BorderLayout.CENTER); rightPanel.add(startPanel, BorderLayout.SOUTH); configurationPanel.add(leftPanel, BorderLayout.WEST); configurationPanel.add(rightPanel, BorderLayout.CENTER); } // switch to configuration view setView(configurationPanel); }
From source file:org.processmining.analysis.performance.fsmevaluator.FSMEvaluationMenuUI.java
protected static JPanel packHorizontallyLeftAligned(Component[] components, int leftOffset) { JPanel packed = new JPanel(); packed.setOpaque(false); packed.setLayout(new BoxLayout(packed, BoxLayout.X_AXIS)); if (leftOffset > 0) { packed.add(Box.createHorizontalStrut(leftOffset)); }/*w ww. ja va 2 s .c om*/ int minW = 0, minH = 0; for (Component comp : components) { packed.add(comp); Dimension dim = comp.getMinimumSize(); minW += dim.getWidth(); minH = Math.max(minH, (int) dim.getHeight()); } packed.add(Box.createHorizontalGlue()); packed.setMinimumSize(new Dimension(minW, minH)); packed.setMaximumSize(new Dimension(4000, minH)); packed.setPreferredSize(new Dimension(4000, minH)); return packed; }
From source file:org.rdv.datapanel.AbstractDataPanel.java
/** * Get a component for displaying the title in top bar. This implementation * includes a button to remove a specific channel. * //from w ww . j a va2s .co m * Subclasses should overide this method if they don't want the default * implementation. * * @return A component for the top bar * @since 1.3 */ JComponent getTitleComponent() { JPanel titleBar = new JPanel(); titleBar.setOpaque(false); titleBar.setLayout(new BorderLayout()); JPopupMenu popupMenu = new ScrollablePopupMenu(); final String title; if (description != null) { title = "Edit description"; } else { title = "Add description"; } JMenuItem addDescriptionMenuItem = new JMenuItem(title); addDescriptionMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { String response = (String) JOptionPane.showInputDialog(null, "Enter a description", title, JOptionPane.QUESTION_MESSAGE, null, null, description); if (response == null) { return; } else if (response.length() == 0) { setDescription(null); } else { setDescription(response); } } }); popupMenu.add(addDescriptionMenuItem); if (description != null) { JMenuItem removeDescriptionMenuItem = new JMenuItem("Remove description"); removeDescriptionMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setDescription(null); } }); popupMenu.add(removeDescriptionMenuItem); } popupMenu.addSeparator(); final JCheckBoxMenuItem showChannelsInTitleMenuItem = new JCheckBoxMenuItem("Show channels in title", showChannelsInTitle); showChannelsInTitleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setShowChannelsInTitle(showChannelsInTitleMenuItem.isSelected()); } }); popupMenu.add(showChannelsInTitleMenuItem); if (channels.size() > 0) { popupMenu.addSeparator(); Iterator<String> i = channels.iterator(); while (i.hasNext()) { final String channelName = i.next(); JMenuItem unsubscribeChannelMenuItem = new JMenuItem("Unsubscribe from " + channelName); unsubscribeChannelMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { removeChannel(channelName); } }); popupMenu.add(unsubscribeChannelMenuItem); } } // set component popup and mouselistener to trigger it titleBar.setComponentPopupMenu(popupMenu); titleBar.addMouseListener(new MouseInputAdapter() { }); if (description != null) { titleBar.add(getDescriptionComponent(), BorderLayout.WEST); } JComponent titleComponent = getChannelComponent(); if (titleComponent != null) { titleBar.add(titleComponent, BorderLayout.CENTER); } return titleBar; }
From source file:org.rdv.datapanel.AbstractDataPanel.java
protected JComponent getChannelComponent() { if (channels.size() == 0) { return null; }/*from w w w . j a va 2s.c o m*/ JPanel channelBar = new JPanel(); channelBar.setOpaque(false); channelBar.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); Iterator<String> i = channels.iterator(); while (i.hasNext()) { String channelName = i.next(); if (showChannelsInTitle) { channelBar.add(new ChannelTitle(channelName)); } } return channelBar; }
From source file:org.revager.gui.findings_list.FindingsListFrame.java
private void createBottomOrgPanel() { JLabel locationLbl = new JLabel(translate("Location:")); locationLbl.setFont(UI.VERY_LARGE_FONT_BOLD); JLabel dateLbl = new JLabel(translate("Date:")); dateLbl.setFont(UI.VERY_LARGE_FONT_BOLD); JLabel beginLbl = new JLabel(translate("Period of time:")); beginLbl.setFont(UI.VERY_LARGE_FONT_BOLD); JLabel tillLabel = new JLabel(translate("to")); tillLabel.setFont(UI.VERY_LARGE_FONT_BOLD); clockLabel.setFont(UI.VERY_LARGE_FONT_BOLD); dateTxtFld = new ObservingTextField(); dateTxtFld.setFont(UI.VERY_LARGE_FONT); dateTxtFld.setFocusable(false);//from ww w. j a v a 2s . c o m dateTxtFld.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dateTxtFld.setPreferredSize(new Dimension(190, (int) dateTxtFld.getPreferredSize().getHeight())); dateTxtFld.setMinimumSize(dateTxtFld.getPreferredSize()); dateTxtFld.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { // instantiate the DatePicker DatePicker dp = new DatePicker(UI.getInstance().getProtocolFrame(), UI.getInstance().getProtocolFrame().getDateTxtFld()); // previously selected date Date selectedDate = dp.parseDate(UI.getInstance().getProtocolFrame().getDateTxtFld().getText()); dp.setSelectedDate(selectedDate); dp.start(UI.getInstance().getProtocolFrame().getDateTxtFld()); } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); dateTxtFld.addKeyListener(updateListener); /* * creating spinner panel */ beginMSpinner = new JSpinner(new RotateSpinnerNumberModel(00, 00, 59, 1)); beginHSpinner = new JSpinner(new RotateSpinnerNumberModel(00, 00, 23, 1)); endMSpinner = new JSpinner(new RotateSpinnerNumberModel(00, 00, 59, 1)); endHSpinner = new JSpinner(new RotateSpinnerNumberModel(00, 00, 23, 1)); beginMSpinner.setFont(UI.VERY_LARGE_FONT); beginHSpinner.setFont(UI.VERY_LARGE_FONT); endHSpinner.setFont(UI.VERY_LARGE_FONT); endMSpinner.setFont(UI.VERY_LARGE_FONT); beginMSpinner.addChangeListener(spinnerChangeListener); beginHSpinner.addChangeListener(spinnerChangeListener); endHSpinner.addChangeListener(spinnerChangeListener); endMSpinner.addChangeListener(spinnerChangeListener); locationTxtFld = new JTextField(); locationTxtFld.setFont(UI.VERY_LARGE_FONT); /* * Hide border if the application runs on Mac OS X */ boolean hideBorder = UI.getInstance().getPlatform() == UI.Platform.MAC; GUITools.formatSpinner(endHSpinner, hideBorder); GUITools.formatSpinner(endMSpinner, hideBorder); GUITools.formatSpinner(beginHSpinner, hideBorder); GUITools.formatSpinner(beginMSpinner, hideBorder); // TODO: In some cases 'currentProt.getDate()' returns null. dateF.setTimeZone(currentProt.getDate().getTimeZone()); dateTxtFld.setText(dateF.format(currentProt.getDate().getTime())); int beginHours = currentProt.getStart().get(Calendar.HOUR_OF_DAY); beginMSpinner.setValue(currentProt.getStart().get(Calendar.MINUTE)); beginHSpinner.setValue(beginHours); int endHours = currentProt.getEnd().get(Calendar.HOUR_OF_DAY); endMSpinner.setValue(currentProt.getEnd().get(Calendar.MINUTE)); endHSpinner.setValue(endHours); /* * Correct the leading zero's */ if ((Integer) beginMSpinner.getValue() == 0) { ((NumberEditor) beginMSpinner.getEditor()).getTextField().setText("00"); } if ((Integer) beginHSpinner.getValue() == 0) { ((NumberEditor) beginHSpinner.getEditor()).getTextField().setText("00"); } if ((Integer) endMSpinner.getValue() == 0) { ((NumberEditor) endMSpinner.getEditor()).getTextField().setText("00"); } if ((Integer) endHSpinner.getValue() == 0) { ((NumberEditor) endHSpinner.getEditor()).getTextField().setText("00"); } locationTxtFld.setText(currentProt.getLocation().trim()); JPanel spinnerPanel = new JPanel(gbl); spinnerPanel.setOpaque(false); JLabel labelDoubleDot1 = new JLabel(":"); labelDoubleDot1.setFont(UI.VERY_LARGE_FONT_BOLD); JLabel labelDoubleDot2 = new JLabel(":"); labelDoubleDot2.setFont(UI.VERY_LARGE_FONT_BOLD); GUITools.addComponent(spinnerPanel, gbl, beginHSpinner, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.NORTHWEST); GUITools.addComponent(spinnerPanel, gbl, labelDoubleDot1, 1, 0, 1, 1, 0, 0, 0, 5, 0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.CENTER); GUITools.addComponent(spinnerPanel, gbl, beginMSpinner, 2, 0, 1, 1, 0, 0, 0, 5, 0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.NORTHWEST); GUITools.addComponent(spinnerPanel, gbl, tillLabel, 3, 0, 1, 1, 1.0, 0, 0, 10, 0, 10, GridBagConstraints.VERTICAL, GridBagConstraints.CENTER); GUITools.addComponent(spinnerPanel, gbl, endHSpinner, 4, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.NORTHEAST); GUITools.addComponent(spinnerPanel, gbl, labelDoubleDot2, 5, 0, 1, 1, 0, 0, 0, 5, 0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.CENTER); GUITools.addComponent(spinnerPanel, gbl, endMSpinner, 6, 0, 1, 1, 0, 0, 0, 5, 0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.NORTHEAST); /* * adding created components to orgpanel */ GUITools.addComponent(bottomOrgPanel, gbl, dateLbl, 2, 0, 1, 1, 0.0, 1.0, 10, 20, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); GUITools.addComponent(bottomOrgPanel, gbl, dateTxtFld, 3, 0, 1, 1, 0.0, 1.0, 10, 5, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); GUITools.addComponent(bottomOrgPanel, gbl, locationLbl, 0, 0, 1, 1, 0.0, 1.0, 10, 20, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); GUITools.addComponent(bottomOrgPanel, gbl, locationTxtFld, 1, 0, 1, 1, 1.0, 1.0, 10, 5, 0, 10, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); GUITools.addComponent(bottomOrgPanel, gbl, beginLbl, 5, 0, 1, 1, 0.0, 1.0, 10, 30, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); GUITools.addComponent(bottomOrgPanel, gbl, spinnerPanel, 6, 0, 1, 1, 0.0, 1.0, 10, 5, 0, 25, GridBagConstraints.VERTICAL, GridBagConstraints.WEST); updateAttButtons(); }
From source file:org.richie.codeGen.ui.GenAndPreviewUI.java
/** * ??// w w w .ja va2 s. c o m * * @param fileName * @param fileContent */ private void addPreviewTablePanel(String fileName, String fileContent) { final JScrollPane content = new JScrollPane(); JTextArea viewTextArea = new JTextArea(); viewTextArea.setText(fileContent); content.setViewportView(viewTextArea); JPanel tab = new JPanel(); tab.setOpaque(false); JLabel tabLabel = new JLabel(fileName); ImageIcon closeXIcon = new ImageIcon(ClassLoader.getSystemResource("resources/images/close.gif")); JButton tabCloseButton = new JButton(closeXIcon); tabCloseButton.setToolTipText("close"); tabCloseButton.setBorder(null); tabCloseButton.setContentAreaFilled(false); tabCloseButton.setPreferredSize(new Dimension(closeXIcon.getIconWidth(), closeXIcon.getIconHeight())); tabCloseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int closeTabNumber = mainPanel.indexOfComponent(content); mainPanel.removeTabAt(closeTabNumber); } }); tab.add(tabLabel, BorderLayout.WEST); tab.add(tabCloseButton, BorderLayout.EAST); mainPanel.addTab(null, content); mainPanel.setTabComponentAt(mainPanel.getTabCount() - 1, tab); mainPanel.setSelectedComponent(content); }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private AbstractWizardPage getCompletionPage() { final ProgressWheel pw = new ProgressWheel(); final JPanel p = new JPanel(); p.setOpaque(false); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); final CompletionWizardPage page = new CompletionWizardPage(PAGENAME_COMPLETE) { @Override//from w w w. j a v a2 s .c om public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.NEXT); if (modify) { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.FINISH); } else { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); new SwingWorker() { @Override protected Object doInBackground() throws Exception { try { createNewProject(); } catch (Exception e) { DialogUtils.displayException("Error", "Error trying to create project", e); LOG.error(e); e.printStackTrace(); } return null; } @Override protected void done() { pw.setComplete(); p.setVisible(true); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.FINISH); revalidate(); repaint(); } }.execute(); } } }; if (modify) { page.addText("You have completed the project modification process."); } else { page.addText("Creating project..."); page.addComponent(pw); p.add(new JLabel("Complete.")); p.add(Box.createHorizontalGlue()); page.addComponent(p); p.setVisible(false); /*p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(pw, Box.createHorizontalGlue()); p.add(pw, BorderLayout.CENTER); p.add(pw, Box.createHorizontalGlue()); page.addComponent(p);*/ } return page; }
From source file:org.ut.biolab.medsavant.client.view.app.builtin.settings.AddRemoveDatabaseDialog.java
/** This method is called from within the constructor to * initialize the form./*from w w w . j a v a 2s. c o m*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { okButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); javax.swing.JPanel detailsPanel = new javax.swing.JPanel(); javax.swing.JLabel jLabel3 = new javax.swing.JLabel(); hostField = new javax.swing.JTextField(); javax.swing.JLabel jLabel4 = new javax.swing.JLabel(); portField = new javax.swing.JTextField(); javax.swing.JLabel jLabel5 = new javax.swing.JLabel(); databaseField = new javax.swing.JTextField(); javax.swing.JLabel jLabel6 = new javax.swing.JLabel(); passwordField = new javax.swing.JPasswordField(); javax.swing.JLabel jLabel7 = new javax.swing.JLabel(); userField = new javax.swing.JTextField(); setTitle("Create Database"); setBackground(new java.awt.Color(217, 222, 229)); okButton.setText("Create"); okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okButtonActionPerformed(evt); } }); cancelButton.setText("Cancel"); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); detailsPanel.setBackground(getBackground()); detailsPanel.setOpaque(false); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel3.setText("SERVER ADDRESS"); hostField.setFont(new java.awt.Font("Lucida Grande", 0, 15)); // NOI18N hostField.setHorizontalAlignment(javax.swing.JTextField.CENTER); jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel4.setText("SERVER PORT"); portField.setFont(new java.awt.Font("Lucida Grande", 0, 15)); // NOI18N portField.setHorizontalAlignment(javax.swing.JTextField.CENTER); jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel5.setText("DATABASE NAME"); databaseField.setFont(new java.awt.Font("Lucida Grande", 0, 15)); // NOI18N databaseField.setHorizontalAlignment(javax.swing.JTextField.CENTER); jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel6.setText("ADMIN USERNAME"); passwordField.setFont(new java.awt.Font("Lucida Grande", 0, 15)); // NOI18N passwordField.setHorizontalAlignment(javax.swing.JTextField.CENTER); jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel7.setText("ADMIN PASSWORD"); userField.setFont(new java.awt.Font("Lucida Grande", 0, 15)); // NOI18N userField.setHorizontalAlignment(javax.swing.JTextField.CENTER); org.jdesktop.layout.GroupLayout detailsPanelLayout = new org.jdesktop.layout.GroupLayout(detailsPanel); detailsPanel.setLayout(detailsPanelLayout); detailsPanelLayout.setHorizontalGroup(detailsPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(detailsPanelLayout.createSequentialGroup().addContainerGap().add(detailsPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, hostField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) .add(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, portField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) .add(jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) .add(databaseField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) .add(jLabel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) .add(jLabel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) .add(passwordField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, userField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)) .addContainerGap())); detailsPanelLayout .setVerticalGroup(detailsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(detailsPanelLayout.createSequentialGroup().addContainerGap().add(jLabel3) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(hostField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel4) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(portField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel5) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(databaseField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel6) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(userField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel7) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(passwordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup().addContainerGap(285, Short.MAX_VALUE).add(okButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(cancelButton) .addContainerGap()) .add(detailsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.linkSize(new java.awt.Component[] { cancelButton, okButton }, org.jdesktop.layout.GroupLayout.HORIZONTAL); layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(detailsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(18, 18, 18).add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(cancelButton).add(okButton)) .addContainerGap())); getRootPane().setDefaultButton(okButton); pack(); }
From source file:pcgui.SetupParametersPanel.java
/** * Shows a window with execution progress and logs the percent completion *//*w w w.ja v a 2s . c o m*/ private void showProgressBar() { pbar = new JProgressBar(); pbar.setMinimum(MY_MINIMUM); pbar.setMaximum(MY_MAXIMUM); pbar.setValue(0); pbar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); progressFrame = new JFrame("Running test instances"); JPanel rootPanel = new JPanel(new BorderLayout()); rootPanel.setOpaque(true); progressFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); progressFrame.setContentPane(rootPanel); JPanel panel = new JPanel(); panel.add(pbar); rootPanel.add(panel, BorderLayout.PAGE_START); rootPanel.add(new JScrollPane(taskOutput), BorderLayout.CENTER); rootPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); progressFrame.pack(); // make the frame half the height and width Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int height = screenSize.height; int width = screenSize.width; progressFrame.setSize(width / 2, height / 2); // here's the part where i center the jframe on screen progressFrame.setLocationRelativeTo(null); progressFrame.setVisible(true); }
From source file:Provider.GoogleMapsStatic.TestUI.MySample.java
/** * @author Nazmul//from ww w . j av a 2 s .c o m */ private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY // //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license ttfSizeW = new JTextField("512"); ttfLat = new JTextField("45.5"); btnGetMap = new JButton("Get Map"); btnQuit = new JButton("Quit"); ttfSizeH = new JTextField("512"); ttfLon = new JTextField("-73.55"); ttfZoom = new JTextField("14"); ttaStatus = new JTextArea(); checkboxRecvStatus = new JCheckBox(); checkboxSendStatus = new JCheckBox(); ttfProgressMsg = new JTextField(); progressBar = new JProgressBar(); imgLbl = new JLabel(); /*** * @author Dhgiang, jpmolinamatute * Created a slider, zoom in/out buttons, conbo box (drop down listbox) for city selection, * a panel to group the zoom buttons and the slider bar */ slider = new JSlider(0, 19, 14); controlPanel = new JPanel(new GridBagLayout()); // controlPanel was created by jpmolinamatute cities = new JComboBox<Object>(new String[] { "Montreal", "Toronto", // the place setting where the combo box is now used to be a text field "Vancouver", "New York City", "Caracas", "Hong Kong" }); // for license key, but it was removed to accommodate space for combo box // @author Dhgiang JPanel panel1 = new JPanel(); JPanel contentPanel = new JPanel(); JPanel btnPanel = new JPanel(); JPanel dialogPane = new JPanel(); JLabel label1 = new JLabel("Select City"); // this used to be the label for license key, it was changed to label as 'select city' JLabel label2 = new JLabel("Size Width"); JLabel label3 = new JLabel("Size Height"); JLabel label4 = new JLabel("Latitude"); JLabel label5 = new JLabel("Longitude"); JLabel label6 = new JLabel("Zoom"); JButton btnZoomIn = new JButton("-"); JButton btnZoomOut = new JButton("+"); /*** * @author jpmolinamatute * Created 8 cardinal points: N,NE,NW; S,SE,SW; E, W; */ JButton btnSE = new JButton("SE"); JButton btnS = new JButton("S"); JButton btnSW = new JButton("SW"); JButton btnE = new JButton("E"); JButton btnW = new JButton("W"); JButton btnNE = new JButton("NE"); JButton btnN = new JButton("N"); JButton btnNW = new JButton("NW"); /*** * @author JPMolinaMatute * Creaetd a spaceControl GridBagConstraints object to manage * the cardinal points, and add KeyListener so users can use the * 8 cardinal keys on the num pad; initialize dimensions * */ GridBagConstraints spaceControl = new GridBagConstraints(); spaceControl.insets = new Insets(5, 5, 5, 5); controlPanel.addKeyListener(this); controlPanel.setSize(new Dimension(512, 512)); // ---- My Combo Boxes for different city coordinates ----// // ======== this ======== setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setTitle("Google Static Maps"); setIconImage(null); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); // ======== dialogPane ======== { dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); dialogPane.setOpaque(false); dialogPane.setLayout(new BorderLayout()); // ======== contentPanel ======== { contentPanel.setOpaque(false); contentPanel.setLayout(new TableLayout( new double[][] { { TableLayoutConstants.FILL }, { TableLayoutConstants.PREFERRED, TableLayoutConstants.FILL, TableLayoutConstants.PREFERRED } })); ((TableLayout) contentPanel.getLayout()).setHGap(5); ((TableLayout) contentPanel.getLayout()).setVGap(5); // ======== panel1 ======== { panel1.setOpaque(false); panel1.setBorder(new CompoundBorder( new TitledBorder("Configure the inputs to Google Static Maps"), Borders.DLU2_BORDER)); panel1.setLayout(new TableLayout( new double[][] { { 0.17, 0.17, 0.17, 0.17, 0.05, TableLayoutConstants.FILL }, { TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED, TableLayoutConstants.PREFERRED } })); ((TableLayout) panel1.getLayout()).setHGap(5); ((TableLayout) panel1.getLayout()).setVGap(5); label1.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label1, new TableLayoutConstraints(0, 2, 0, 2, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- label2 ---- label2.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label2, new TableLayoutConstraints(0, 0, 0, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- ttfSizeW ---- panel1.add(ttfSizeW, new TableLayoutConstraints(1, 0, 1, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- label4 ---- label4.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label4, new TableLayoutConstraints(2, 0, 2, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- ttfLat ---- panel1.add(ttfLat, new TableLayoutConstraints(3, 0, 3, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- btnGetMap ---- btnGetMap.setHorizontalAlignment(SwingConstants.LEFT); btnGetMap.setMnemonic('G'); btnGetMap.setActionCommand("getMap"); btnGetMap.addActionListener(this); panel1.add(btnGetMap, new TableLayoutConstraints(5, 0, 5, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- label3 ---- label3.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label3, new TableLayoutConstraints(0, 1, 0, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- ttfSizeH ---- panel1.add(ttfSizeH, new TableLayoutConstraints(1, 1, 1, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- label5 ---- label5.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label5, new TableLayoutConstraints(2, 1, 2, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- ttfLon ---- panel1.add(ttfLon, new TableLayoutConstraints(3, 1, 3, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- btnQuit ---- btnQuit.setMnemonic('Q'); btnQuit.setHorizontalAlignment(SwingConstants.LEFT); btnQuit.setHorizontalTextPosition(SwingConstants.RIGHT); btnQuit.setActionCommand("quit"); btnQuit.addActionListener(this); panel1.add(btnQuit, new TableLayoutConstraints(5, 1, 5, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); /*** * @author Dhgiang * Added an anonymous inner class for ItemLister and event handling for the combo box * Used the switch case condition handling to set coordinates based on the city selected * Juan helped modified this method by adding the startTaskAction() at the end so * users don't have to click on Get Map button. */ cities.setSelectedIndex(0); // initialize the city selection item to 0 (or the first item) cities.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Integer z = cities.getSelectedIndex(); switch (z) { case 0: ttfLat.setText("45.5"); ttfLon.setText("-73.55"); break; case 1: ttfLat.setText("43.65"); ttfLon.setText("-79.38"); break; case 2: ttfLat.setText("49.2505"); ttfLon.setText("-123.1119"); break; case 3: ttfLat.setText("40.7142"); ttfLon.setText("-74.0064"); break; case 4: ttfLat.setText("10.4901"); ttfLon.setText("-66.9151"); break; case 5: ttfLat.setText("22.257"); ttfLon.setText("114.2"); break; default: break; } startTaskAction(); } }); /*** * @author Dhgiang * Added the combo box to the panel */ panel1.add(cities, new TableLayoutConstraints(1, 2, 1, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL)); // ---- label6 ---- label6.setHorizontalAlignment(SwingConstants.RIGHT); panel1.add(label6, new TableLayoutConstraints(2, 2, 2, 2, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); // ---- ttfZoom ---- panel1.add(ttfZoom, new TableLayoutConstraints(3, 2, 3, 2, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); } { btnPanel.setOpaque(false); btnPanel.setLayout(new GridLayout(0, 3)); /**** * @author Dhgiang * Initializing the zoom IN / OUT buttons with proper parameters and * adding them to the btnPanel of Panel1 (panel within a panel) */ // ---- btnZoomIn ---- btnZoomIn.setHorizontalAlignment(SwingConstants.LEFT); btnZoomIn.setHorizontalTextPosition(SwingConstants.RIGHT); btnZoomIn.setActionCommand("Zoomin"); btnZoomIn.addActionListener(this); btnPanel.add(btnZoomIn, new TableLayoutConstraints(5, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL)); // ---- btnZoomOut ---- btnZoomOut.setHorizontalAlignment(SwingConstants.RIGHT); btnZoomOut.setHorizontalTextPosition(SwingConstants.RIGHT); btnZoomOut.setActionCommand("Zoomout"); btnZoomOut.addActionListener(this); btnPanel.add(btnZoomOut, new TableLayoutConstraints(5, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL)); /*** * @author Dhgiang * Having created a new JSlider slider object, maximum & minimum values * are initialized along with incremental values * */ // ---- slider ----- slider.setMaximum(19); slider.setMinimum(0); slider.setPaintTicks(true); slider.setMajorTickSpacing(19); slider.setMinorTickSpacing(1); slider.setPaintTrack(false); slider.createStandardLabels(4, 0); /*** * @author Dhgiang * Added a ChangeListener to the slider so that * 1) the slider moves left if (-) button is clicked, slider moves right if (+) is clicked * 2) and zoom values will increase or decrease if slider bar is shifted left or right accordingly * 3) after the user releases the click button, the map will display automatically with the values * set by the slider bar, without having the user to click on get map button */ slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { Integer a = slider.getValue(); if (a >= 0 && a <= 19) { ttfZoom.setText(a.toString()); startTaskAction(); } } }); slider.setBorder(null); /*** * @author Dhgiang * Added the slider bar to the button panel */ btnPanel.add(slider, new TableLayoutConstraints(5, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL)); } /*** * @author Dhgiang * Adding the button panel to panel1 */ panel1.add(btnPanel, new TableLayoutConstraints(5, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL)); contentPanel.add(panel1, new TableLayoutConstraints(0, 0, 0, 0, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); /*** * @author jpmolinamatute * Initializing coordinates for the cardinal points * Adding the cardinal points button to the control panel */ // ---- Cardinals points ----- btnNW.setActionCommand("Northwest"); btnNW.addActionListener(this); spaceControl.gridx = 0; spaceControl.gridy = 0; controlPanel.add(btnNW, spaceControl); btnN.setActionCommand("North"); btnN.addActionListener(this); spaceControl.gridx = 3; spaceControl.gridy = 0; controlPanel.add(btnN, spaceControl); btnNE.setActionCommand("Northeast"); btnNE.addActionListener(this); spaceControl.gridx = 6; spaceControl.gridy = 0; controlPanel.add(btnNE, spaceControl); btnW.setActionCommand("West"); btnW.addActionListener(this); spaceControl.gridx = 0; spaceControl.gridy = 3; controlPanel.add(btnW, spaceControl); spaceControl.gridx = 3; spaceControl.gridy = 3; controlPanel.add(imgLbl, spaceControl); btnE.setActionCommand("East"); btnE.addActionListener(this); spaceControl.gridx = 6; spaceControl.gridy = 3; controlPanel.add(btnE, spaceControl); btnSW.setActionCommand("Southwest"); btnSW.addActionListener(this); spaceControl.gridx = 0; spaceControl.gridy = 6; controlPanel.add(btnSW, spaceControl); btnS.setActionCommand("South"); btnS.addActionListener(this); spaceControl.gridx = 3; spaceControl.gridy = 6; controlPanel.add(btnS, spaceControl); btnSE.setActionCommand("Southeast"); btnSE.addActionListener(this); spaceControl.gridx = 6; spaceControl.gridy = 6; controlPanel.add(btnSE, spaceControl); contentPanel.add(controlPanel, new TableLayoutConstraints(0, 1, 0, 1, TableLayoutConstants.FULL, TableLayoutConstants.FULL)); } dialogPane.add(contentPanel, BorderLayout.CENTER); } contentPane.add(dialogPane, BorderLayout.CENTER); setSize(700, 800); setLocationRelativeTo(null); }