List of usage examples for java.awt GridBagConstraints GridBagConstraints
public GridBagConstraints()
From source file:com.sec.ose.osi.ui.frm.main.report.JPanBillOfMaterials.java
private JPanel getJPanelOptions() { if (jPanelOptions == null) { GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.gridx = 1;//from www . j a v a 2 s. c o m gridBagConstraints3.fill = GridBagConstraints.BOTH; gridBagConstraints3.insets = new Insets(0, 0, 10, 0); gridBagConstraints3.gridy = 1; jLabelSelectedComponent = new JLabel(); jLabelSelectedComponent.setText("Display files for the selected components"); jLabelSelectedComponent.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { eventHandler.handleEvent(EventHandler.RADIO_SELECTED_COMPONENT); } }); GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.gridx = 0; gridBagConstraints2.insets = new Insets(0, 10, 10, 0); gridBagConstraints2.gridy = 1; GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.gridx = 1; gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints1.insets = new Insets(10, 0, 10, 0); gridBagConstraints1.gridwidth = 1; gridBagConstraints1.gridy = 0; jLabelAllFiles = new JLabel(); jLabelAllFiles.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { eventHandler.handleEvent(EventHandler.RADIO_ALL_FILES); } }); jLabelAllFiles.setText("Display all files for all components"); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.insets = new Insets(0, 10, 0, 0); gridBagConstraints.gridy = 0; jPanelOptions = new JPanel(); jPanelOptions.setLayout(new GridBagLayout()); jPanelOptions.add(getJRadioAllFilesForAll(), gridBagConstraints); jPanelOptions.add(jLabelAllFiles, gridBagConstraints1); jPanelOptions.add(getJRadioAllFilesForSelectedComponent(), gridBagConstraints2); jPanelOptions.add(jLabelSelectedComponent, gridBagConstraints3); } return jPanelOptions; }
From source file:de.codesourcery.flocking.ui.NumberInputField.java
/** * Create instance./*from w ww.ja v a2s. c o m*/ * * <p>Creates a resizable panel that holds a label, a textfield and a slider * for entering/adjusting a numeric value.</p> * * @param label the label to display * @param model the model that is used to read/write the value to be edited. If the model returns <code>null</code> values, * these will be treated as "0" (or "0.0" respectively). * @param minValue valid minimum value (inclusive) the user may enter * @param maxValue vali maximum value (inclusive) the user may enter * @param onlyIntValues whether the user may enter only integers or integers <b>and</b> floating-point numbers. */ public NumberInputField(String label, IModel<T> model, double minValue, double maxValue, final boolean onlyIntValues) { if (model == null) { throw new IllegalArgumentException("model must not be NULL."); } this.model = model; this.minValue = minValue; this.maxValue = maxValue; this.onlyIntValues = onlyIntValues; textField = new JTextField("0"); textField.setColumns(5); textField.setHorizontalAlignment(JTextField.RIGHT); slider = new JSlider(0, SLIDER_RESOLUTION); textField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (selfTriggeredEvent) { return; } final String s = textField.getText(); if (!StringUtils.isBlank(s)) { Number number = null; try { if (onlyIntValues) { number = Long.parseLong(s.trim()); } else { number = Double.parseDouble(s.trim()); } } catch (Exception ex) { textField.setText(numberToString(NumberInputField.this.model.getObject())); return; } updateModelValue(number); } } }); textField.setText(numberToString(model.getObject())); slider.getModel().setValue(calcSliderValue(model.getObject())); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (selfTriggeredEvent) { return; } final double percentage = slider.getModel().getValue() / (double) SLIDER_RESOLUTION; // 0...1 final double range = Math.abs(NumberInputField.this.maxValue - NumberInputField.this.minValue); final double newValue = NumberInputField.this.minValue + range * percentage; updateModelValue(newValue); } }); slider.setMinimumSize(new Dimension(100, 20)); slider.setPreferredSize(new Dimension(100, 20)); // do layout setLayout(new GridBagLayout()); GridBagConstraints cnstrs = new GridBagConstraints(); cnstrs.fill = GridBagConstraints.NONE; cnstrs.weightx = 0; cnstrs.weighty = 0; cnstrs.gridx = 0; cnstrs.gridy = 0; final JLabel l = new JLabel(label); l.setMinimumSize(new Dimension(1500, 20)); l.setPreferredSize(new Dimension(150, 20)); l.setVerticalAlignment(SwingConstants.TOP); add(l, cnstrs); cnstrs = new GridBagConstraints(); cnstrs.fill = GridBagConstraints.NONE; cnstrs.weightx = 0; cnstrs.weighty = 0; cnstrs.gridx = 1; cnstrs.gridy = 0; cnstrs.insets = new Insets(0, 0, 0, 10); add(textField, cnstrs); cnstrs = new GridBagConstraints(); cnstrs.fill = GridBagConstraints.HORIZONTAL; cnstrs.weightx = 1.0; cnstrs.weighty = 1.0; cnstrs.gridx = 2; cnstrs.gridy = 0; add(slider, cnstrs); }
From source file:com.xmage.launcher.XMageLauncher.java
private XMageLauncher() { locale = Locale.getDefault(); //locale = new Locale("it", "IT"); messages = ResourceBundle.getBundle("MessagesBundle", locale); localize();//w w w . j a v a2s . 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:edu.harvard.mcz.imagecapture.RunnableJobReportDialog.java
/** * This method initializes jPanel1 /*from www . j a v a2 s . c om*/ * * @return javax.swing.JPanel */ private JPanel getJPanel1() { if (jPanel1 == null) { jPanel1 = new JPanel(); jPanel1.setLayout(new GridBagLayout()); GridBagConstraints gbc_jButtonSave = new GridBagConstraints(); gbc_jButtonSave.insets = new Insets(0, 0, 0, 5); gbc_jButtonSave.gridx = 0; gbc_jButtonSave.gridy = 0; jPanel1.add(getJButtonSave(), gbc_jButtonSave); GridBagConstraints gbc_jButton = new GridBagConstraints(); gbc_jButton.gridx = 1; gbc_jButton.gridy = 0; jPanel1.add(getJButton(), gbc_jButton); } return jPanel1; }
From source file:de.fhbingen.wbs.wpOverview.tabs.APCalendarPanel.java
/** * Initialize the work package calendar panel inclusive the listeners. *///from ww w . j ava 2 s.co 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;/* ww w. j ava 2s . c om*/ 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:com.sec.ose.osi.ui.frm.login.JPanLogin.java
/** * This method initializes jPanelUserInfo * /*from www . jav a 2 s. com*/ * @return javax.swing.JPanel */ private JPanel getJPanelUserInfo() { if (jPanelUserInfo == null) { jPanelUserInfo = new JPanel(); jPanelUserInfo.setLayout(new GridBagLayout()); // User ID JLabel jLabelUser = new JLabel("User ID:"); jLabelUser.setHorizontalAlignment(SwingConstants.RIGHT); jLabelUser.setText("User ID :"); jLabelUser.setEnabled(true); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridy = 0; gridBagConstraints.gridx = 0; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new Insets(0, 10, 0, 0); jPanelUserInfo.add(jLabelUser, gridBagConstraints); GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.fill = GridBagConstraints.BOTH; gridBagConstraints1.gridy = 0; gridBagConstraints1.gridx = 1; gridBagConstraints1.weightx = 1.0; gridBagConstraints1.insets = new Insets(5, 5, 5, 5); jPanelUserInfo.add(getJTextFieldUser(), gridBagConstraints1); // Password JLabel jLabelPwd = new JLabel(); jLabelPwd.setText("Password :"); jLabelPwd.setHorizontalAlignment(SwingConstants.RIGHT); GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.gridy = 1; gridBagConstraints2.gridx = 0; gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints2.insets = new Insets(0, 10, 0, 0); jPanelUserInfo.add(jLabelPwd, gridBagConstraints2); GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.fill = GridBagConstraints.BOTH; gridBagConstraints3.gridy = 1; gridBagConstraints3.gridx = 1; gridBagConstraints3.weightx = 1.0; gridBagConstraints3.insets = new Insets(5, 5, 5, 5); jPanelUserInfo.add(getJPasswordField(), gridBagConstraints3); // Protex Server IP JLabel jLabelServer = new JLabel(); jLabelServer.setText("Protex Server IP :"); jLabelServer.setHorizontalAlignment(SwingConstants.RIGHT); jLabelServer.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED); GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); gridBagConstraints11.gridy = 2; gridBagConstraints11.gridx = 0; gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints11.insets = new Insets(0, 10, 5, 0); jPanelUserInfo.add(jLabelServer, gridBagConstraints11); GridBagConstraints gridBagConstraints21 = new GridBagConstraints(); gridBagConstraints21.gridy = 2; gridBagConstraints21.gridx = 1; gridBagConstraints21.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints21.insets = new Insets(5, 5, 10, 5); jPanelUserInfo.add(getJTextFieldServerIP(), gridBagConstraints21); } return jPanelUserInfo; }
From source file:endrov.typeTimeRemap.TimeRemapWindow.java
/** * Regenerate UI/*from ww w . jav a2 s .c om*/ */ 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:com.frostwire.gui.bittorrent.PartialFilesDialog.java
private void setupOkButton() { GridBagConstraints c;/*from w w w . ja va 2 s .c o m*/ _buttonOK = new JButton(I18n.tr("Download Selected Files Only")); _buttonOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { buttonOK_actionPerformed(e); } }); c = new GridBagConstraints(); c.insets = new Insets(4, 100, 8, 4); c.fill = GridBagConstraints.NONE; c.gridwidth = GridBagConstraints.RELATIVE; c.anchor = GridBagConstraints.EAST; c.ipadx = 20; c.weightx = 1.0; c.gridy = 4; panel.add(_buttonOK, c); }
From source file:au.org.ala.delta.intkey.ui.DefineButtonDialog.java
public DefineButtonDialog(Frame owner, boolean modal) { super(owner, modal); setPreferredSize(new Dimension(500, 430)); ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(DefineButtonDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(DefineButtonDialog.class, this); setTitle(title);//from w w w . j a v a2s. com _okButtonPressed = false; _pnlButtons = new JPanel(); getContentPane().add(_pnlButtons, BorderLayout.SOUTH); _btnOk = new JButton(); _btnOk.setAction(actionMap.get("DefineButtonDialog_OK")); _pnlButtons.add(_btnOk); _btnCancel = new JButton(); _btnCancel.setAction(actionMap.get("DefineButtonDialog_Cancel")); _pnlButtons.add(_btnCancel); _btnHelp = new JButton(); _btnHelp.setAction(actionMap.get("DefineButtonDialog_Help")); _btnHelp.setEnabled(false); _pnlButtons.add(_btnHelp); _pnlMain = new JPanel(); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(5, 0)); _pnlButtonProperties = new JPanel(); _pnlButtonProperties.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder( new EtchedBorder(EtchedBorder.LOWERED, null, null), new EmptyBorder(5, 5, 5, 5)))); _pnlMain.add(_pnlButtonProperties, BorderLayout.NORTH); GridBagLayout gbl__pnlButtonProperties = new GridBagLayout(); gbl__pnlButtonProperties.columnWidths = new int[] { 475, 0 }; gbl__pnlButtonProperties.rowHeights = new int[] { 14, 23, 14, 20, 14, 20, 14, 0, 23, 23, 23, 23, 0 }; gbl__pnlButtonProperties.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl__pnlButtonProperties.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; _pnlButtonProperties.setLayout(gbl__pnlButtonProperties); _lblEnterNameOf = new JLabel(enterFileNameCaption); _lblEnterNameOf.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc__lblEnterNameOf = new GridBagConstraints(); gbc__lblEnterNameOf.anchor = GridBagConstraints.WEST; gbc__lblEnterNameOf.insets = new Insets(0, 0, 5, 0); gbc__lblEnterNameOf.gridx = 0; gbc__lblEnterNameOf.gridy = 0; _pnlButtonProperties.add(_lblEnterNameOf, gbc__lblEnterNameOf); _pnlFile = new JPanel(); GridBagConstraints gbc__pnlFile = new GridBagConstraints(); gbc__pnlFile.fill = GridBagConstraints.HORIZONTAL; gbc__pnlFile.insets = new Insets(0, 0, 5, 0); gbc__pnlFile.gridx = 0; gbc__pnlFile.gridy = 1; _pnlButtonProperties.add(_pnlFile, gbc__pnlFile); _pnlFile.setLayout(new BorderLayout(0, 0)); _txtFldFileName = new JTextField(); _pnlFile.add(_txtFldFileName, BorderLayout.CENTER); _txtFldFileName.setColumns(10); _btnBrowse = new JButton(); _btnBrowse.setAction(actionMap.get("DefineButtonDialog_Browse")); _pnlFile.add(_btnBrowse, BorderLayout.EAST); _lblEnterTheCommands = new JLabel(enterCommandsCaption); _lblEnterTheCommands.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc__lblEnterTheCommands = new GridBagConstraints(); gbc__lblEnterTheCommands.anchor = GridBagConstraints.WEST; gbc__lblEnterTheCommands.insets = new Insets(0, 0, 5, 0); gbc__lblEnterTheCommands.gridx = 0; gbc__lblEnterTheCommands.gridy = 2; _pnlButtonProperties.add(_lblEnterTheCommands, gbc__lblEnterTheCommands); _txtFldCommands = new JTextField(); GridBagConstraints gbc__txtFldCommands = new GridBagConstraints(); gbc__txtFldCommands.fill = GridBagConstraints.HORIZONTAL; gbc__txtFldCommands.insets = new Insets(0, 0, 5, 0); gbc__txtFldCommands.gridx = 0; gbc__txtFldCommands.gridy = 3; _pnlButtonProperties.add(_txtFldCommands, gbc__txtFldCommands); _txtFldCommands.setColumns(10); _lblEnterBriefHelp = new JLabel(enterBriefHelpCaption); _lblEnterBriefHelp.setAlignmentY(Component.TOP_ALIGNMENT); GridBagConstraints gbc__lblEnterBriefHelp = new GridBagConstraints(); gbc__lblEnterBriefHelp.anchor = GridBagConstraints.NORTHWEST; gbc__lblEnterBriefHelp.insets = new Insets(0, 0, 5, 0); gbc__lblEnterBriefHelp.gridx = 0; gbc__lblEnterBriefHelp.gridy = 4; _pnlButtonProperties.add(_lblEnterBriefHelp, gbc__lblEnterBriefHelp); _txtFldBriefHelp = new JTextField(); GridBagConstraints gbc__txtFldBriefHelp = new GridBagConstraints(); gbc__txtFldBriefHelp.fill = GridBagConstraints.HORIZONTAL; gbc__txtFldBriefHelp.insets = new Insets(0, 0, 5, 0); gbc__txtFldBriefHelp.gridx = 0; gbc__txtFldBriefHelp.gridy = 5; _pnlButtonProperties.add(_txtFldBriefHelp, gbc__txtFldBriefHelp); _txtFldBriefHelp.setColumns(10); _lblEnterMoreDetailed = new JLabel(enterDetailedHelpCaption); GridBagConstraints gbc__lblEnterMoreDetailed = new GridBagConstraints(); gbc__lblEnterMoreDetailed.anchor = GridBagConstraints.WEST; gbc__lblEnterMoreDetailed.insets = new Insets(0, 0, 5, 0); gbc__lblEnterMoreDetailed.gridx = 0; gbc__lblEnterMoreDetailed.gridy = 6; _pnlButtonProperties.add(_lblEnterMoreDetailed, gbc__lblEnterMoreDetailed); _txtFldDetailedHelp = new JTextField(); GridBagConstraints gbc__txtFldDetailedHelp = new GridBagConstraints(); gbc__txtFldDetailedHelp.insets = new Insets(0, 0, 5, 0); gbc__txtFldDetailedHelp.fill = GridBagConstraints.HORIZONTAL; gbc__txtFldDetailedHelp.gridx = 0; gbc__txtFldDetailedHelp.gridy = 7; _pnlButtonProperties.add(_txtFldDetailedHelp, gbc__txtFldDetailedHelp); _txtFldDetailedHelp.setColumns(10); _chckbxEnableOnlyIfUsedCharacters = new JCheckBox(enableOnlyIfUsedCaption); GridBagConstraints gbc__chckbxEnableOnlyIf = new GridBagConstraints(); gbc__chckbxEnableOnlyIf.anchor = GridBagConstraints.WEST; gbc__chckbxEnableOnlyIf.insets = new Insets(0, 0, 5, 0); gbc__chckbxEnableOnlyIf.gridx = 0; gbc__chckbxEnableOnlyIf.gridy = 8; _pnlButtonProperties.add(_chckbxEnableOnlyIfUsedCharacters, gbc__chckbxEnableOnlyIf); _rdbtnEnableInAll = new JRadioButton(enableInAllModesCaption); GridBagConstraints gbc__rdbtnEnableInAll = new GridBagConstraints(); gbc__rdbtnEnableInAll.anchor = GridBagConstraints.WEST; gbc__rdbtnEnableInAll.insets = new Insets(0, 0, 5, 0); gbc__rdbtnEnableInAll.gridx = 0; gbc__rdbtnEnableInAll.gridy = 9; _pnlButtonProperties.add(_rdbtnEnableInAll, gbc__rdbtnEnableInAll); _rdbtnEnableInNormal = new JRadioButton(enableInNormalModeCaption); GridBagConstraints gbc__rdbtnEnableInNormal = new GridBagConstraints(); gbc__rdbtnEnableInNormal.anchor = GridBagConstraints.WEST; gbc__rdbtnEnableInNormal.insets = new Insets(0, 0, 5, 0); gbc__rdbtnEnableInNormal.gridx = 0; gbc__rdbtnEnableInNormal.gridy = 10; _pnlButtonProperties.add(_rdbtnEnableInNormal, gbc__rdbtnEnableInNormal); _rdbtnEnableInAdvanced = new JRadioButton(enableInAdvancedModeCaption); GridBagConstraints gbc__rdbtnEnableInAdvanced = new GridBagConstraints(); gbc__rdbtnEnableInAdvanced.anchor = GridBagConstraints.WEST; gbc__rdbtnEnableInAdvanced.gridx = 0; gbc__rdbtnEnableInAdvanced.gridy = 11; _pnlButtonProperties.add(_rdbtnEnableInAdvanced, gbc__rdbtnEnableInAdvanced); _pnlSpaceRemoveAll = new JPanel(); _pnlSpaceRemoveAll.setBorder(new EmptyBorder(0, 10, 0, 0)); _pnlMain.add(_pnlSpaceRemoveAll, BorderLayout.SOUTH); _pnlSpaceRemoveAll.setLayout(new BoxLayout(_pnlSpaceRemoveAll, BoxLayout.Y_AXIS)); _chckbxInsertASpace = new JCheckBox(insertSpaceCaption); _chckbxInsertASpace.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { _insertSpace = !_insertSpace; if (_insertSpace) { _removeAllButtons = false; _chckbxRemoveAllButtons.setSelected(false); } updateButtonPropertyControls(); } }); _pnlSpaceRemoveAll.add(_chckbxInsertASpace); _chckbxRemoveAllButtons = new JCheckBox(removeAllCaption); _chckbxRemoveAllButtons.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { _removeAllButtons = !_removeAllButtons; if (_removeAllButtons) { _insertSpace = false; _chckbxInsertASpace.setSelected(false); } updateButtonPropertyControls(); } }); _pnlSpaceRemoveAll.add(_chckbxRemoveAllButtons); _pnlButtonProperties.setEnabled(false); ButtonGroup btnGroup = new ButtonGroup(); btnGroup.add(_rdbtnEnableInAll); btnGroup.add(_rdbtnEnableInNormal); btnGroup.add(_rdbtnEnableInAdvanced); _rdbtnEnableInAll.setSelected(true); }