List of usage examples for javax.swing JCheckBox JCheckBox
public JCheckBox(Action a)
From source file:logdruid.ui.chart.GraphPanel.java
public void loadGroupCheckbox(final JPanel panel_2) { panel_1.removeAll();/* ww w. j a v a 2 s .co m*/ //Iterator mineResultSetIterator = mineResultSet.mineResults.entrySet().iterator(); Map<Source, Map<String, MineResult>> treeMap = new TreeMap<Source, Map<String, MineResult>>( mineResultSet.mineResults); Iterator mineResultSetIterator = treeMap.entrySet().iterator(); logger.debug("mineResultSet size: " + mineResultSet.mineResults.size()); while (mineResultSetIterator.hasNext()) { int groupCount = 0; int totalGroupCount = 0; Map.Entry pairs = (Map.Entry) mineResultSetIterator.next(); Map mrArrayList = (Map<String, MineResult>) pairs.getValue(); ArrayList<String> mineResultGroup = new ArrayList<String>(); Set<String> mrss = mrArrayList.keySet(); mineResultGroup.addAll(mrss); Collections.sort(mineResultGroup, new AlphanumComparator()); Iterator mrArrayListIterator = mineResultGroup.iterator(); while (mrArrayListIterator.hasNext()) { String key = (String) mrArrayListIterator.next(); final MineResult mr = (MineResult) mrArrayList.get(key); Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap(); Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap(); if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) { if (mr.getStartDate() != null && mr.getEndDate() != null) { if ((mr.getStartDate().before((Date) endDateJSPinner.getValue())) && (mr.getEndDate().after((Date) startDateJSpinner.getValue()))) { groupCount++; } } } } Iterator mrArrayListIterator2 = mineResultGroup.iterator(); while (mrArrayListIterator2.hasNext()) { String key = (String) mrArrayListIterator2.next(); final MineResult mr = (MineResult) mrArrayList.get(key); Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap(); Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap(); if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) { if (mr.getStartDate() != null && mr.getEndDate() != null) { if ((mr.getStartDate().before((Date) maximumDate)) && (mr.getEndDate().after((Date) minimumDate))) { totalGroupCount++; } } } } boolean selected = true; if (groupCheckBox.containsKey(((Source) pairs.getKey()).getSourceName())) { selected = groupCheckBox.get(((Source) pairs.getKey()).getSourceName()); } else { groupCheckBox.put(((Source) pairs.getKey()).getSourceName(), selected); } JCheckBox chckbxGroup = new JCheckBox( ((Source) pairs.getKey()).getSourceName() + "(" + groupCount + "/" + totalGroupCount + ")"); chckbxGroup.setFont(new Font("Dialog", Font.BOLD, 11)); chckbxGroup.setSelected(selected); panel_1.add(chckbxGroup); chckbxGroup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JCheckBox chkBox = ((JCheckBox) e.getSource()); groupCheckBox.put( (String) chkBox.getText().substring(0, ((String) chkBox.getText()).indexOf("(")), !groupCheckBox.get((String) chkBox.getText().substring(0, ((String) chkBox.getText()).indexOf("(")))); loadGroupCheckbox(panel_2); load(panel_2); //logger.info("checkBox:"+ chkBox.getText()+","+chkBox.isSelected()+","+groupCheckBox); //logger.info("checkBox2:"+((String)chkBox.getText())+", "+((String)chkBox.getText()).indexOf("(")+", "+groupCheckBox.get((String)chkBox.getText().substring(0, ((String)chkBox.getText()).indexOf("(")))); } }); } }
From source file:com.floreantpos.ui.model.PizzaItemForm.java
private void initComponents() { setLayout(new BorderLayout()); JLabel lblButtonColor = new JLabel(Messages.getString("MenuItemForm.19")); //$NON-NLS-1$ tabbedPane = new javax.swing.JTabbedPane(); JPanel tabGeneral = new javax.swing.JPanel(); JLabel lblName = new JLabel(); lblName.setHorizontalAlignment(SwingConstants.TRAILING); tfName = new com.floreantpos.swing.FixedLengthTextField(20); tfDescription = new JTextArea(new FixedLengthDocument(120)); JLabel lTax = new javax.swing.JLabel(); lTax.setHorizontalAlignment(SwingConstants.TRAILING); cbTax = new javax.swing.JComboBox(); JButton btnNewTax = new javax.swing.JButton(); JPanel tabShift = new javax.swing.JPanel(); JPanel tabPrice = new javax.swing.JPanel(); JPanel tabButtonStyle = new javax.swing.JPanel(); JButton btnDeleteShift = new javax.swing.JButton(); JButton btnAddShift = new javax.swing.JButton(); JButton btnNewPrice = new javax.swing.JButton(); JButton btnUpdatePrice = new javax.swing.JButton(); JButton btnDeletePrice = new javax.swing.JButton(); JButton btnDeleteAll = new javax.swing.JButton(); JButton btnDefaultValue = new javax.swing.JButton(); JButton btnAutoGenerate = new javax.swing.JButton(); JScrollPane jScrollPane2 = new javax.swing.JScrollPane(); JScrollPane priceTabScrollPane = new javax.swing.JScrollPane(); shiftTable = new JTable(); priceTable = new JTable(); priceTable.setRowHeight(PosUIManager.getSize(priceTable.getRowHeight())); priceTable.setCellSelectionEnabled(true); priceTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); priceTable.setSurrendersFocusOnKeystroke(true); cbPrinterGroup = new JComboBox<PrinterGroup>(new DefaultComboBoxModel<PrinterGroup>( PrinterGroupDAO.getInstance().findAll().toArray(new PrinterGroup[0]))); cbPrinterGroup.setPreferredSize(new Dimension(226, 0)); tfDefaultSellPortion = new IntegerTextField(10); tfTranslatedName = new FixedLengthTextField(20); tfTranslatedName.setLength(120);// w w w . jav a 2s . c om lblKitchenPrinter = new JLabel(Messages.getString("MenuItemForm.27")); //$NON-NLS-1$ lblName.setText(Messages.getString("LABEL_NAME")); //$NON-NLS-1$ tfName.setLength(120); JLabel lblTranslatedName = new JLabel(Messages.getString("MenuItemForm.lblTranslatedName.text")); //$NON-NLS-1$ tfSortOrder = new IntegerTextField(20); tfSortOrder.setText(""); //$NON-NLS-1$ cbTax.setPreferredSize(new Dimension(198, 0)); btnButtonColor = new JButton(); //$NON-NLS-1$ btnButtonColor.setPreferredSize(new Dimension(228, 40)); JLabel lblTextColor = new JLabel(Messages.getString("MenuItemForm.lblTextColor.text")); //$NON-NLS-1$ btnTextColor = new JButton(Messages.getString("MenuItemForm.SAMPLE_TEXT")); //$NON-NLS-1$ cbShowTextWithImage = new JCheckBox(Messages.getString("MenuItemForm.40")); //$NON-NLS-1$ cbShowTextWithImage.setActionCommand(Messages.getString("MenuItemForm.41")); //$NON-NLS-1$ lTax.setText(Messages.getString("LABEL_TAX")); //$NON-NLS-1$ btnNewTax.setText("..."); lTax.setText(Messages.getString("LABEL_TAX")); //$NON-NLS-1$ btnNewTax.setText("..."); //$NON-NLS-1$ btnNewTax.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNewTaxdoCreateNewTax(evt); } }); tabbedPane.addTab(com.floreantpos.POSConstants.GENERAL, tabGeneral); tabbedPane.setPreferredSize(new Dimension(750, 470)); tabbedPane.addTab(com.floreantpos.POSConstants.MODIFIER_GROUPS, getModifierGroupTab()); btnAddShift.addActionListener(this); btnDeleteShift.addActionListener(this); tabGeneral.setLayout(new MigLayout("insets 20", "[][]20px[][]", "[][][][][][][][][][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ tabGeneral.add(lblName, "cell 0 1 ,right"); //$NON-NLS-1$ tabGeneral.add(tfName, "cell 1 1,grow"); //$NON-NLS-1$ tabGeneral.add(lblTranslatedName, "cell 0 2,right"); //$NON-NLS-1$ tabGeneral.add(tfTranslatedName, "cell 1 2,grow"); JLabel lgroup = new javax.swing.JLabel(); lgroup.setHorizontalAlignment(SwingConstants.TRAILING); lgroup.setText(Messages.getString("LABEL_GROUP")); //$NON-NLS-1$ tabGeneral.add(lgroup, "cell 0 3,alignx right"); //$NON-NLS-1$ JLabel lblBarcode = new JLabel(Messages.getString("MenuItemForm.lblBarcode.text")); //$NON-NLS-1$ tabGeneral.add(lblBarcode, "cell 0 4,alignx right"); //$NON-NLS-1$ tfBarcode = new FixedLengthTextField(20); tabGeneral.add(tfBarcode, "cell 1 4,grow"); //$NON-NLS-1$ JLabel lblStockCount = new JLabel(Messages.getString("MenuItemForm.17")); //$NON-NLS-1$ tabGeneral.add(lblStockCount, "cell 0 5,alignx right"); //$NON-NLS-1$ tfStockCount = new DoubleTextField(1); tabGeneral.add(tfStockCount, "cell 1 5,grow"); //$NON-NLS-1$ chkVisible = new javax.swing.JCheckBox(); tabGeneral.add(new JLabel("Default sell portion (%)"), "cell 0 6"); tabGeneral.add(tfDefaultSellPortion, "cell 1 6,grow"); chkVisible.setText(com.floreantpos.POSConstants.VISIBLE); chkVisible.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); chkVisible.setMargin(new java.awt.Insets(0, 0, 0, 0)); tabGeneral.add(chkVisible, "cell 1 7"); tabGeneral.add(lblKitchenPrinter, "cell 2 1,right"); //$NON-NLS-1$ tabGeneral.add(cbPrinterGroup, "cell 3 1,grow"); //$NON-NLS-1$ tabGeneral.add(lTax, "cell 2 2,right"); //$NON-NLS-1$ tabGeneral.add(cbTax, "cell 3 2"); //$NON-NLS-1$ tabGeneral.add(btnNewTax, "cell 3 2,grow"); //$NON-NLS-1$ cbGroup = new javax.swing.JComboBox(); cbGroup.setPreferredSize(new Dimension(198, 0)); tabGeneral.add(cbGroup, "flowx,cell 1 3"); //$NON-NLS-1$ JButton btnNewGroup = new javax.swing.JButton(); btnNewGroup.setText("..."); //$NON-NLS-1$ btnNewGroup.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { doCreateNewGroup(evt); } }); tabGeneral.add(btnNewGroup, "cell 1 3"); //$NON-NLS-1$ tabGeneral.add(new JLabel(Messages.getString("MenuItemForm.25")), "cell 2 3,right"); //$NON-NLS-1$ //$NON-NLS-2$ orderList = new CheckBoxList(); List<OrderType> orderTypes = Application.getInstance().getOrderTypes(); orderList.setModel(orderTypes); JScrollPane orderCheckBoxList = new JScrollPane(orderList); orderCheckBoxList.setPreferredSize(new Dimension(228, 100)); tabGeneral.add(orderCheckBoxList, "cell 3 3 3 3"); //$NON-NLS-1$ cbDisableStockCount = new JCheckBox(Messages.getString("MenuItemForm.18")); //$NON-NLS-1$ tabGeneral.add(cbDisableStockCount, "cell 1 8"); //$NON-NLS-1$ tabGeneral.add(new JLabel(Messages.getString("MenuItemForm.29")), "cell 2 6,alignx right"); //$NON-NLS-1$ //$NON-NLS-2$ JScrollPane scrlDescription = new JScrollPane(tfDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrlDescription.setPreferredSize(new Dimension(228, 70)); tfDescription.setLineWrap(true); tabGeneral.add(scrlDescription, "cell 3 6 3 3"); //$NON-NLS-1$ add(tabbedPane); //TODO: addRecepieExtension(); btnDeleteShift.setText(com.floreantpos.POSConstants.DELETE_SHIFT); btnAddShift.setText(com.floreantpos.POSConstants.ADD_SHIFT); shiftTable .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ jScrollPane2.setViewportView(shiftTable); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(tabShift); tabShift.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup().addContainerGap(76, Short.MAX_VALUE) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 670, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup().add(btnAddShift).add(5, 5, 5) .add(btnDeleteShift))) .addContainerGap())); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup() .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 345, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(btnAddShift).add(btnDeleteShift)) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); tabbedPane.addTab(com.floreantpos.POSConstants.SHIFTS, tabShift); btnNewPrice.setText(Messages.getString("MenuItemForm.9")); //$NON-NLS-1$ btnNewPrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addNewPrice(); } }); btnUpdatePrice.setText(Messages.getString("MenuItemForm.13")); //$NON-NLS-1$ btnUpdatePrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updatePrice(); } }); btnDeletePrice.setText(Messages.getString("MenuItemForm.14")); //$NON-NLS-1$ btnDeletePrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deletePrice(); } }); btnAutoGenerate.setText("Auto Generate"); //$NON-NLS-1$ btnAutoGenerate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { autoGeneratePizzaItemSizeAndPrice(); } }); btnDeleteAll.setText(Messages.getString("MenuItemForm.15")); //$NON-NLS-1$ btnDeleteAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteAll(); } }); btnDefaultValue.setText(Messages.getString("MenuItemForm.7")); //$NON-NLS-1$ priceTabScrollPane.setViewportView(priceTable); tabPrice.setLayout(new BorderLayout()); tabPrice.add(priceTabScrollPane, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.add(btnNewPrice); buttonPanel.add(btnUpdatePrice); buttonPanel.add(btnDeletePrice); buttonPanel.add(btnAutoGenerate); tabPrice.add(buttonPanel, BorderLayout.SOUTH); tabGeneral.add(tabPrice, "cell 0 10,grow,span"); tabbedPane.addChangeListener(this); tabButtonStyle.setLayout(new MigLayout("insets 10", "[][]100[][][][]", "[][][center][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ JLabel lblImage = new JLabel(Messages.getString("MenuItemForm.28")); //$NON-NLS-1$ lblImage.setHorizontalAlignment(SwingConstants.TRAILING); tabButtonStyle.add(lblImage, "cell 0 0,right"); //$NON-NLS-1$ lblImagePreview = new JLabel(""); //$NON-NLS-1$ lblImagePreview.setHorizontalAlignment(JLabel.CENTER); lblImagePreview.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); lblImagePreview.setPreferredSize(new Dimension(100, 100)); tabButtonStyle.add(lblImagePreview, "cell 1 0"); //$NON-NLS-1$ JButton btnSelectImage = new JButton("..."); //$NON-NLS-1$ btnClearImage = new JButton(Messages.getString("MenuItemForm.34")); //$NON-NLS-1$ tabButtonStyle.add(btnClearImage, "cell 1 0"); //$NON-NLS-1$ tabButtonStyle.add(btnSelectImage, "cell 1 0"); //$NON-NLS-1$ tabButtonStyle.add(lblButtonColor, "cell 0 2,right"); //$NON-NLS-1$ tabButtonStyle.add(btnButtonColor, "cell 1 2,grow"); //$NON-NLS-1$ tabButtonStyle.add(lblTextColor, "cell 0 3,right"); //$NON-NLS-1$ tabButtonStyle.add(btnTextColor, "cell 1 3"); //$NON-NLS-1$ tabButtonStyle.add(cbShowTextWithImage, "cell 1 4"); //$NON-NLS-1$ btnTextColor.setPreferredSize(new Dimension(228, 50)); btnSelectImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSelectImageFile(); } }); btnClearImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doClearImage(); } }); btnButtonColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(POSUtil.getBackOfficeWindow(), Messages.getString("MenuItemForm.42"), btnButtonColor.getBackground()); //$NON-NLS-1$ btnButtonColor.setBackground(color); btnTextColor.setBackground(color); } }); btnTextColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(POSUtil.getBackOfficeWindow(), Messages.getString("MenuItemForm.43"), btnTextColor.getForeground()); //$NON-NLS-1$ btnTextColor.setForeground(color); } }); tabbedPane.addTab(Messages.getString("MenuItemForm.26"), tabButtonStyle); //$NON-NLS-1$ }
From source file:com.mirth.connect.client.ui.NotificationDialog.java
private void initComponents() { setLayout(new MigLayout("insets 12", "[]", "[fill][]")); notificationPanel = new JPanel(); notificationPanel.setLayout(new MigLayout("insets 0 0 0 0, fill", "[200!][]", "[25!]0[]")); notificationPanel.setBackground(UIConstants.BACKGROUND_COLOR); archiveAll = new JLabel("Archive All"); archiveAll.setForeground(java.awt.Color.blue); archiveAll.setText("<html><u>Archive All</u></html>"); archiveAll.setToolTipText("Archive all notifications below."); archiveAll.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); newNotificationsLabel = new JLabel(); newNotificationsLabel.setFont(newNotificationsLabel.getFont().deriveFont(Font.BOLD)); headerListPanel = new JPanel(); headerListPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR); headerListPanel.setLayout(new MigLayout("insets 2, fill")); headerListPanel.setBorder(BorderFactory.createLineBorder(borderColor)); list = new JList(); list.setCellRenderer(new NotificationListCellRenderer()); list.addListSelectionListener(new ListSelectionListener() { @Override/*ww w.j a va 2 s . c om*/ public void valueChanged(ListSelectionEvent event) { if (!event.getValueIsAdjusting()) { currentNotification = (Notification) list.getSelectedValue(); if (currentNotification != null) { notificationNameTextField.setText(currentNotification.getName()); contentTextPane.setText(currentNotification.getContent()); archiveSelected(); } } } }); listScrollPane = new JScrollPane(); listScrollPane.setBackground(UIConstants.BACKGROUND_COLOR); listScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor)); listScrollPane.setViewportView(list); listScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); archiveLabel = new JLabel(); archiveLabel.setForeground(java.awt.Color.blue); archiveLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); notificationNameTextField = new JTextField(); notificationNameTextField.setFont(notificationNameTextField.getFont().deriveFont(Font.BOLD)); notificationNameTextField.setEditable(false); notificationNameTextField.setFocusable(false); notificationNameTextField.setBorder(BorderFactory.createEmptyBorder()); notificationNameTextField.setBackground(UIConstants.HIGHLIGHTER_COLOR); DefaultCaret nameCaret = (DefaultCaret) notificationNameTextField.getCaret(); nameCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); headerContentPanel = new JPanel(); headerContentPanel.setLayout(new MigLayout("insets 2, fill")); headerContentPanel.setBorder(BorderFactory.createLineBorder(borderColor)); headerContentPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR); contentTextPane = new JTextPane(); contentTextPane.setContentType("text/html"); contentTextPane.setEditable(false); contentTextPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { if (evt.getEventType() == EventType.ACTIVATED && Desktop.isDesktopSupported()) { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(evt.getURL().toURI()); } else { BareBonesBrowserLaunch.openURL(evt.getURL().toString()); } } catch (Exception e) { e.printStackTrace(); } } } }); DefaultCaret contentCaret = (DefaultCaret) contentTextPane.getCaret(); contentCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); contentScrollPane = new JScrollPane(); contentScrollPane.setViewportView(contentTextPane); contentScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor)); archiveLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { int index = list.getSelectedIndex(); if (currentNotification.isArchived()) { notificationModel.setArchived(false, index); unarchivedCount++; } else { notificationModel.setArchived(true, index); unarchivedCount--; } archiveSelected(); updateUnarchivedCountLabel(); } }); archiveAll.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { for (int i = 0; i < notificationModel.getSize(); i++) { notificationModel.setArchived(true, i); } unarchivedCount = 0; archiveSelected(); updateUnarchivedCountLabel(); } }); notificationCheckBox = new JCheckBox("Show new notifications on login"); notificationCheckBox.setBackground(UIConstants.BACKGROUND_COLOR); if (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications)) { checkForNotificationsSetting = true; if (showNotificationPopup == null || BooleanUtils.toBoolean(showNotificationPopup)) { notificationCheckBox.setSelected(true); } else { notificationCheckBox.setSelected(false); } } else { notificationCheckBox.setSelected(false); } notificationCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (notificationCheckBox.isSelected() && !checkForNotificationsSetting) { alertSettingsChange(); } } }); closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSave(); } }); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { doSave(); } }); }
From source file:com.projity.pm.graphic.chart.ChartLegend.java
void initControls() { chartInfo.setAxisPanel(new AxisPanel(chartInfo)); filterComboBox = new TransformComboBox(null, MenuActionConstants.ACTION_CHOOSE_FILTER, TransformComboBoxModel.FILTER); filterComboBox.setView(ViewConfiguration.getView(MenuActionConstants.ACTION_CHARTS)); filterComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (chartInfo.isRestoring()) return; TransformComboBox combo = (TransformComboBox) e.getSource(); CommonTransformFactory factory = (CommonTransformFactory) combo.getSelectedItem(); ((TransformComboBoxModel) combo.getModel()).changeTransform(factory); }/* ww w. j a v a2 s . co m*/ }); initTree(); Object[] fields = getFields(false); workTraces = getListInstance(false); tracesList = workTraces; // start off work tracesScrollPane = new JScrollPane(workTraces); workTraces.setVisibleRowCount(Environment.getStandAlone() ? HasTimeDistributedData.tracesCount : HasTimeDistributedData.serverTracesCount); // final ViewTransformer transformer=ViewConfiguration.getView(MenuActionConstants.ACTION_CHARTS).getTransform(); // final ResourceInTeamFilter hiddenFilter=(ResourceInTeamFilter)transformer.getHiddenFilter(); // teamResources= new JCheckBox(Messages.getString("Text.ShowTeamResourcesOnly")); // teamResources.addItemListener(new ItemListener() { // public void itemStateChanged(ItemEvent e) { // hiddenFilter.setFilterTeam(e.getStateChange() == ItemEvent.SELECTED); // transformer.update(); // } // }); // teamResources.setSelected(hiddenFilter.isFilterTeam()); if (simple) { chartInfo.setTraces(fields); tree.getSelectionModel().setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION); // allow only 1 for histogram selectedOnTop = new JCheckBox(Messages.getString("Text.ShowSelectedOnTop")); //$NON-NLS-1$ selectedOnTop.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { chartInfo.setSelectedOnTop(e.getStateChange() == ItemEvent.SELECTED); Object[] traces = getFields(false); chartInfo.setTraces(traces); workTraces = getListInstance(false); tracesScrollPane.getViewport().add(workTraces); workTraces.setVisibleRowCount(Environment.getStandAlone() ? HasTimeDistributedData.tracesCount : HasTimeDistributedData.serverTracesCount); } }); selectedOnTop.setSelected(chartInfo.isSelectedOnTop()); // start off as histogram return; } costTraces = getListInstance(true); cumulative = new JCheckBox(Messages.getString("Text.Cumulative")); //$NON-NLS-1$ cumulative.setSelected(chartInfo.isCumulative()); // start off as histogram cumulative.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { chartInfo.setCumulative(e.getStateChange() == ItemEvent.SELECTED); } }); histogram = new JCheckBox(Messages.getString("Text.Histogram")); //$NON-NLS-1$ histogram.setSelected(chartInfo.isHistogram()); // start off as histogram histogram.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean histogramSelected = e.getStateChange() == ItemEvent.SELECTED; chartInfo.setHistogram(histogramSelected); if (histogramSelected) { workTraces.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); // allow only 1 for histogram costTraces.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); // allow only 1 for histogram } else { workTraces.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // allow many costTraces.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // allow only 1 for histogram } } }); work = new JRadioButton(Messages.getString("Text.work")); //$NON-NLS-1$ work.setSelected(chartInfo.isWork()); cost = new JRadioButton(Messages.getString("Text.cost")); //$NON-NLS-1$ ItemListener costWork = new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean isCost = e.getSource() == cost; chartInfo.setWork(!isCost); tracesList = isCost ? costTraces : workTraces; tracesScrollPane.getViewport().add(tracesList); if (!chartInfo.isRestoring()) chartInfo.setTraces(tracesList.getSelectedValues()); } }; cost.addItemListener(costWork); work.addItemListener(costWork); ButtonGroup group = new ButtonGroup(); group.add(cost); group.add(work); // by default, always select first item chartInfo.setTraces(new Object[] { fields[0] }); }
From source file:net.sf.taverna.t2.activities.rshell.views.RshellConfigurationPanel.java
private Component createSettingsPanel() { JPanel settingsPanel = new JPanel(new GridBagLayout()); GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.weightx = 0.0;/*from w w w .ja v a2 s . c om*/ labelConstraints.gridx = 0; labelConstraints.gridy = 0; labelConstraints.fill = GridBagConstraints.NONE; labelConstraints.anchor = GridBagConstraints.LINE_START; GridBagConstraints fieldConstraints = new GridBagConstraints(); fieldConstraints.weightx = 1.0; fieldConstraints.gridx = 1; fieldConstraints.gridy = 0; fieldConstraints.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints buttonConstraints = new GridBagConstraints(); buttonConstraints.weightx = 1.0; buttonConstraints.gridx = 1; buttonConstraints.gridy = 2; buttonConstraints.fill = GridBagConstraints.NONE; buttonConstraints.anchor = GridBagConstraints.WEST; Dimension dimension = new Dimension(0, 0); hostnameField = new JTextField(); JLabel hostnameLabel = new JLabel("Hostname"); hostnameField.setSize(dimension); hostnameLabel.setSize(dimension); hostnameLabel.setLabelFor(hostnameField); JsonNode connectionSettings = getJson().path("connection"); hostnameField.setText(connectionSettings.path("hostname").asText()); portField = new JTextField(); JLabel portLabel = new JLabel("Port"); portField.setSize(dimension); portLabel.setSize(dimension); portLabel.setLabelFor(portField); portField.setText( Integer.toString(connectionSettings.path("port").asInt(RshellTemplateService.DEFAULT_PORT))); // "Set username and password" button ActionListener usernamePasswordListener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (credManagerUI == null) { credManagerUI = new CredentialManagerUI(credentialManager); } credManagerUI.newPasswordForService( URI.create("rserve://" + hostnameField.getText() + ":" + portField.getText())); // this is used as a key for the service in Credential Manager } }; JButton setHttpUsernamePasswordButton = new JButton("Set username and password"); setHttpUsernamePasswordButton.setSize(dimension); setHttpUsernamePasswordButton.addActionListener(usernamePasswordListener); keepSessionAliveCheckBox = new JCheckBox("Keep Session Alive"); keepSessionAliveCheckBox.setSelected(connectionSettings.path("keepSessionAlive") .asBoolean(RshellTemplateService.DEFAULT_KEEP_SESSION_ALIVE)); settingsPanel.add(hostnameLabel, labelConstraints); labelConstraints.gridy++; settingsPanel.add(hostnameField, fieldConstraints); fieldConstraints.gridy++; settingsPanel.add(portLabel, labelConstraints); labelConstraints.gridy++; settingsPanel.add(portField, fieldConstraints); fieldConstraints.gridy++; settingsPanel.add(setHttpUsernamePasswordButton, buttonConstraints); buttonConstraints.gridy++; fieldConstraints.gridy++; settingsPanel.add(keepSessionAliveCheckBox, fieldConstraints); fieldConstraints.gridy++; return settingsPanel; }
From source file:com.dragoniade.deviantart.ui.PreferencesDialog.java
public PreferencesDialog(final DownloaderGUI owner, Properties config) { super(owner, "Preferences", true); HttpClientParams params = new HttpClientParams(); params.setVersion(HttpVersion.HTTP_1_1); params.setSoTimeout(30000);//w ww .j a v a2s. c o m client = new HttpClient(params); setProxy(ProxyCfg.parseConfig(config)); sample = new Deviation(); sample.setId(15972367L); sample.setTitle("Fella Promo"); sample.setArtist("devart"); sample.setImageDownloadUrl(DOWNLOAD_URL); sample.setImageFilename(Deviation.extractFilename(DOWNLOAD_URL)); sample.setCollection(new Collection(1L, "MyCollect")); setLayout(new BorderLayout()); panes = new JTabbedPane(JTabbedPane.TOP); JPanel genPanel = new JPanel(); BoxLayout genLayout = new BoxLayout(genPanel, BoxLayout.Y_AXIS); genPanel.setLayout(genLayout); panes.add("General", genPanel); JLabel userLabel = new JLabel("Username"); userLabel.setToolTipText("The username the account you want to download the favorites from."); userField = new JTextField(config.getProperty(Constants.USERNAME)); userLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); userLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); userField.setAlignmentX(JLabel.LEFT_ALIGNMENT); userField.setMaximumSize(new Dimension(Integer.MAX_VALUE, userField.getFont().getSize() * 2)); genPanel.add(userLabel); genPanel.add(userField); JPanel radioPanel = new JPanel(); BoxLayout radioLayout = new BoxLayout(radioPanel, BoxLayout.X_AXIS); radioPanel.setAlignmentX(JLabel.LEFT_ALIGNMENT); radioPanel.setBorder(new EmptyBorder(0, 5, 0, 5)); radioPanel.setLayout(radioLayout); JLabel searchLabel = new JLabel("Search for"); searchLabel .setToolTipText("Select what you want to download from that user: it favorites or it galleries."); searchLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); searchLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); selectedSearch = SEARCH.lookup(config.getProperty(Constants.SEARCH, SEARCH.getDefault().getId())); buttonGroup = new ButtonGroup(); for (final SEARCH search : SEARCH.values()) { JRadioButton radio = new JRadioButton(search.getLabel()); radio.setAlignmentX(JLabel.LEFT_ALIGNMENT); radio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectedSearch = search; } }); buttonGroup.add(radio); radioPanel.add(radio); if (search.equals(selectedSearch)) { radio.setSelected(true); } } genPanel.add(radioPanel); final JTextField sampleField = new JTextField(""); sampleField.setEditable(false); JLabel locationLabel = new JLabel("Download location"); locationLabel.setToolTipText("The folder pattern where you want the file to be downloaded in."); JLabel legendsLabel = new JLabel( "<html><body>Field names: %user%, %artist%, %title%, %id%, %filename%, %collection%, %ext%<br></br>Example:</body></html>"); legendsLabel.setToolTipText("An example of where a file will be downloaded to."); locationString = new StringBuilder(); locationField = new JTextField(config.getProperty(Constants.LOCATION)); locationField.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub } public void keyReleased(KeyEvent e) { File dest = LocationHelper.getFile(locationField.getText(), userField.getText(), sample, sample.getImageFilename()); locationString.setLength(0); locationString.append(dest.getAbsolutePath()); sampleField.setText(locationString.toString()); if (useSameForMatureBox.isSelected()) { locationMatureString.setLength(0); locationMatureString.append(sampleField.getText()); locationMatureField.setText(locationField.getText()); } } public void keyTyped(KeyEvent e) { } }); locationField.addMouseListener(new MouseListener() { public void mouseReleased(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseExited(MouseEvent e) { sampleField.setText(locationString.toString()); } public void mouseEntered(MouseEvent e) { sampleField.setText(locationString.toString()); } public void mouseClicked(MouseEvent e) { } }); JLabel locationMatureLabel = new JLabel("Mature download location"); locationMatureLabel.setToolTipText( "The folder pattern where you want the file marked as 'Mature' to be downloaded in."); locationMatureString = new StringBuilder(); locationMatureField = new JTextField(config.getProperty(Constants.MATURE)); locationMatureField.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub } public void keyReleased(KeyEvent e) { File dest = LocationHelper.getFile(locationMatureField.getText(), userField.getText(), sample, sample.getImageFilename()); locationMatureString.setLength(0); locationMatureString.append(dest.getAbsolutePath()); sampleField.setText(locationMatureString.toString()); } public void keyTyped(KeyEvent e) { } }); locationMatureField.addMouseListener(new MouseListener() { public void mouseReleased(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseExited(MouseEvent e) { sampleField.setText(locationString.toString()); } public void mouseEntered(MouseEvent e) { sampleField.setText(locationMatureString.toString()); } public void mouseClicked(MouseEvent e) { } }); useSameForMatureBox = new JCheckBox("Use same location for mature deviation?"); useSameForMatureBox.setSelected(locationLabel.getText().equals(locationMatureField.getText())); useSameForMatureBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (useSameForMatureBox.isSelected()) { locationMatureField.setEditable(false); locationMatureField.setText(locationField.getText()); locationMatureString.setLength(0); locationMatureString.append(locationString); } else { locationMatureField.setEditable(true); } } }); File dest = LocationHelper.getFile(locationField.getText(), userField.getText(), sample, sample.getImageFilename()); sampleField.setText(dest.getAbsolutePath()); locationString.append(sampleField.getText()); dest = LocationHelper.getFile(locationMatureField.getText(), userField.getText(), sample, sample.getImageFilename()); locationMatureString.append(dest.getAbsolutePath()); locationLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); locationLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); locationField.setAlignmentX(JLabel.LEFT_ALIGNMENT); locationField.setMaximumSize(new Dimension(Integer.MAX_VALUE, locationField.getFont().getSize() * 2)); locationMatureLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); locationMatureLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); locationMatureField.setAlignmentX(JLabel.LEFT_ALIGNMENT); locationMatureField .setMaximumSize(new Dimension(Integer.MAX_VALUE, locationMatureField.getFont().getSize() * 2)); useSameForMatureBox.setAlignmentX(JLabel.LEFT_ALIGNMENT); legendsLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); legendsLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); legendsLabel.setMaximumSize(new Dimension(Integer.MAX_VALUE, legendsLabel.getFont().getSize() * 2)); sampleField.setAlignmentX(JLabel.LEFT_ALIGNMENT); sampleField.setMaximumSize(new Dimension(Integer.MAX_VALUE, sampleField.getFont().getSize() * 2)); genPanel.add(locationLabel); genPanel.add(locationField); genPanel.add(locationMatureLabel); genPanel.add(locationMatureField); genPanel.add(useSameForMatureBox); genPanel.add(legendsLabel); genPanel.add(sampleField); genPanel.add(Box.createVerticalBox()); final KeyListener prxChangeListener = new KeyListener() { public void keyTyped(KeyEvent e) { proxyChangeState = true; } public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { } }; JPanel prxPanel = new JPanel(); BoxLayout prxLayout = new BoxLayout(prxPanel, BoxLayout.Y_AXIS); prxPanel.setLayout(prxLayout); panes.add("Proxy", prxPanel); JLabel prxHostLabel = new JLabel("Proxy Host"); prxHostLabel.setToolTipText("The hostname of the proxy server"); prxHostField = new JTextField(config.getProperty(Constants.PROXY_HOST)); prxHostLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); prxHostLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); prxHostField.setAlignmentX(JLabel.LEFT_ALIGNMENT); prxHostField.setMaximumSize(new Dimension(Integer.MAX_VALUE, prxHostField.getFont().getSize() * 2)); JLabel prxPortLabel = new JLabel("Proxy Port"); prxPortLabel.setToolTipText("The port of the proxy server (Default 80)."); prxPortSpinner = new JSpinner(); prxPortSpinner.setModel(new SpinnerNumberModel( Integer.parseInt(config.getProperty(Constants.PROXY_PORT, "80")), 1, 65535, 1)); prxPortLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); prxPortLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); prxPortSpinner.setAlignmentX(JLabel.LEFT_ALIGNMENT); prxPortSpinner.setMaximumSize(new Dimension(Integer.MAX_VALUE, prxPortSpinner.getFont().getSize() * 2)); JLabel prxUserLabel = new JLabel("Proxy username"); prxUserLabel.setToolTipText("The username used for authentication, if applicable."); prxUserField = new JTextField(config.getProperty(Constants.PROXY_USERNAME)); prxUserLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); prxUserLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); prxUserField.setAlignmentX(JLabel.LEFT_ALIGNMENT); prxUserField.setMaximumSize(new Dimension(Integer.MAX_VALUE, prxUserField.getFont().getSize() * 2)); JLabel prxPassLabel = new JLabel("Proxy username"); prxPassLabel.setToolTipText("The username used for authentication, if applicable."); prxPassField = new JPasswordField(config.getProperty(Constants.PROXY_PASSWORD)); prxPassLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); prxPassLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); prxPassField.setAlignmentX(JLabel.LEFT_ALIGNMENT); prxPassField.setMaximumSize(new Dimension(Integer.MAX_VALUE, prxPassField.getFont().getSize() * 2)); prxUseBox = new JCheckBox("Use a proxy?"); prxUseBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { prxChangeListener.keyTyped(null); if (prxUseBox.isSelected()) { prxHostField.setEditable(true); prxPortSpinner.setEnabled(true); prxUserField.setEditable(true); prxPassField.setEditable(true); } else { prxHostField.setEditable(false); prxPortSpinner.setEnabled(false); prxUserField.setEditable(false); prxPassField.setEditable(false); } } }); prxUseBox.setSelected(!Boolean.parseBoolean(config.getProperty(Constants.PROXY_USE))); prxUseBox.doClick(); proxyChangeState = false; prxHostField.addKeyListener(prxChangeListener); prxUserField.addKeyListener(prxChangeListener); prxPassField.addKeyListener(prxChangeListener); prxPortSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { proxyChangeState = true; } }); prxPanel.add(prxUseBox); prxPanel.add(prxHostLabel); prxPanel.add(prxHostField); prxPanel.add(prxPortLabel); prxPanel.add(prxPortSpinner); prxPanel.add(prxUserLabel); prxPanel.add(prxUserField); prxPanel.add(prxPassLabel); prxPanel.add(prxPassField); prxPanel.add(Box.createVerticalBox()); final JPanel advPanel = new JPanel(); BoxLayout advLayout = new BoxLayout(advPanel, BoxLayout.Y_AXIS); advPanel.setLayout(advLayout); panes.add("Advanced", advPanel); panes.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JTabbedPane pane = (JTabbedPane) e.getSource(); if (proxyChangeState && pane.getSelectedComponent() == advPanel) { Properties properties = new Properties(); properties.setProperty(Constants.PROXY_USERNAME, prxUserField.getText().trim()); properties.setProperty(Constants.PROXY_PASSWORD, new String(prxPassField.getPassword()).trim()); properties.setProperty(Constants.PROXY_HOST, prxHostField.getText().trim()); properties.setProperty(Constants.PROXY_PORT, prxPortSpinner.getValue().toString()); properties.setProperty(Constants.PROXY_USE, Boolean.toString(prxUseBox.isSelected())); ProxyCfg prx = ProxyCfg.parseConfig(properties); setProxy(prx); revalidateSearcher(null); } } }); JLabel domainLabel = new JLabel("Deviant Art domain name"); domainLabel.setToolTipText("The deviantART main domain, should it ever change."); domainField = new JTextField(config.getProperty(Constants.DOMAIN)); domainLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); domainLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); domainField.setAlignmentX(JLabel.LEFT_ALIGNMENT); domainField.setMaximumSize(new Dimension(Integer.MAX_VALUE, domainField.getFont().getSize() * 2)); advPanel.add(domainLabel); advPanel.add(domainField); JLabel throttleLabel = new JLabel("Throttle search delay"); throttleLabel.setToolTipText( "Slow down search query by inserting a pause between them. This help prevent abuse when doing a massive download."); throttleSpinner = new JSpinner(); throttleSpinner.setModel( new SpinnerNumberModel(Integer.parseInt(config.getProperty(Constants.THROTTLE, "0")), 5, 60, 1)); throttleLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); throttleLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); throttleSpinner.setAlignmentX(JLabel.LEFT_ALIGNMENT); throttleSpinner.setMaximumSize(new Dimension(Integer.MAX_VALUE, throttleSpinner.getFont().getSize() * 2)); advPanel.add(throttleLabel); advPanel.add(throttleSpinner); JLabel searcherLabel = new JLabel("Searcher"); searcherLabel.setToolTipText("Select a searcher that will look for your favorites."); searcherBox = new JComboBox(); searcherBox.setRenderer(new TogglingRenderer()); final AtomicInteger index = new AtomicInteger(0); searcherBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox combo = (JComboBox) e.getSource(); Object selectedItem = combo.getSelectedItem(); if (selectedItem instanceof SearchItem) { SearchItem item = (SearchItem) selectedItem; if (item.isValid) { index.set(combo.getSelectedIndex()); } else { combo.setSelectedIndex(index.get()); } } } }); try { for (Class<Search> clazz : SearcherClassCache.getInstance().getClasses()) { Search searcher = clazz.newInstance(); String name = searcher.getName(); SearchItem item = new SearchItem(name, clazz.getName(), true); searcherBox.addItem(item); } String selectedClazz = config.getProperty(Constants.SEARCHER, com.dragoniade.deviantart.deviation.SearchRss.class.getName()); revalidateSearcher(selectedClazz); } catch (Exception e1) { throw new RuntimeException(e1); } searcherLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); searcherLabel.setBorder(new EmptyBorder(0, 5, 0, 5)); searcherBox.setAlignmentX(JLabel.LEFT_ALIGNMENT); searcherBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, searcherBox.getFont().getSize() * 2)); advPanel.add(searcherLabel); advPanel.add(searcherBox); advPanel.add(Box.createVerticalBox()); add(panes, BorderLayout.CENTER); JButton saveBut = new JButton("Save"); userField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { JTextField field = (JTextField) input; if (field.getText().trim().length() == 0) { JOptionPane.showMessageDialog(input, "The user musn't be empty.", "Warning", JOptionPane.WARNING_MESSAGE); return false; } return true; } }); locationField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { JTextField field = (JTextField) input; String content = field.getText().trim(); if (content.length() == 0) { JOptionPane.showMessageDialog(input, "The location musn't be empty.", "Warning", JOptionPane.WARNING_MESSAGE); return false; } if (!content.contains("%filename%") && !content.contains("%id%")) { JOptionPane.showMessageDialog(input, "The location must contains at least a %filename% or an %id% field.", "Warning", JOptionPane.WARNING_MESSAGE); return false; } return true; } }); locationMatureField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { JTextField field = (JTextField) input; String content = field.getText().trim(); if (content.length() == 0) { JOptionPane.showMessageDialog(input, "The Mature location musn't be empty.", "Warning", JOptionPane.WARNING_MESSAGE); return false; } if (!content.contains("%filename%") && !content.contains("%id%")) { JOptionPane.showMessageDialog(input, "The Mature location must contains at least a %username% or an %id% field.", "Warning", JOptionPane.WARNING_MESSAGE); return false; } return true; } }); domainField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { JTextField field = (JTextField) input; String domain = field.getText().trim(); if (domain.length() == 0) { JOptionPane.showMessageDialog(input, "You must specify the deviantART main domain.", "Warning", JOptionPane.WARNING_MESSAGE); return false; } if (domain.toLowerCase().startsWith("http://")) { JOptionPane.showMessageDialog(input, "You must specify the deviantART main domain, not the full URL (aka www.deviantart.com).", "Warning", JOptionPane.WARNING_MESSAGE); return false; } return true; } }); locationField.setVerifyInputWhenFocusTarget(true); final JDialog parent = this; saveBut.addActionListener(new ActionListener() { String errorMsg = "The location is invalid or cannot be written to."; public void actionPerformed(ActionEvent e) { String username = userField.getText().trim(); String location = locationField.getText().trim(); String locationMature = locationMatureField.getText().trim(); String domain = domainField.getText().trim(); String throttle = throttleSpinner.getValue().toString(); String searcher = searcherBox.getSelectedItem().toString(); String prxUse = Boolean.toString(prxUseBox.isSelected()); String prxHost = prxHostField.getText().trim(); String prxPort = prxPortSpinner.getValue().toString(); String prxUsername = prxUserField.getText().trim(); String prxPassword = new String(prxPassField.getPassword()).trim(); if (!testPath(location, username)) { JOptionPane.showMessageDialog(parent, errorMsg, "Error", JOptionPane.ERROR_MESSAGE); } if (!testPath(locationMature, username)) { JOptionPane.showMessageDialog(parent, errorMsg, "Error", JOptionPane.ERROR_MESSAGE); } Properties p = new Properties(); p.setProperty(Constants.USERNAME, username); p.setProperty(Constants.LOCATION, location); p.setProperty(Constants.MATURE, locationMature); p.setProperty(Constants.DOMAIN, domain); p.setProperty(Constants.THROTTLE, throttle); p.setProperty(Constants.SEARCHER, searcher); p.setProperty(Constants.SEARCH, selectedSearch.getId()); p.setProperty(Constants.PROXY_USE, prxUse); p.setProperty(Constants.PROXY_HOST, prxHost); p.setProperty(Constants.PROXY_PORT, prxPort); p.setProperty(Constants.PROXY_USERNAME, prxUsername); p.setProperty(Constants.PROXY_PASSWORD, prxPassword); owner.savePreferences(p); parent.dispose(); } }); JButton cancelBut = new JButton("Cancel"); cancelBut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { parent.dispose(); } }); JPanel buttonPanel = new JPanel(); BoxLayout butLayout = new BoxLayout(buttonPanel, BoxLayout.X_AXIS); buttonPanel.setLayout(butLayout); buttonPanel.add(saveBut); buttonPanel.add(cancelBut); add(buttonPanel, BorderLayout.SOUTH); pack(); setResizable(false); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation((d.width - getWidth()) / 2, (d.height - getHeight()) / 2); setVisible(true); }
From source file:task5.deneme.java
JPanel createControlPanel() { JPanel panel = new JPanel(); panel.add(new JCheckBox(new deneme.VisibleAction(0))); panel.add(new JCheckBox(new deneme.VisibleAction(1))); panel.add(new JCheckBox(new deneme.VisibleAction(2))); return panel; }
From source file:com.floreantpos.main.SetUpWindow.java
private JPanel createTerminalConfigPanel() { JPanel contentPanel = new JPanel(new MigLayout("fill,hidemode 3", "[150px][fill, grow]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ contentPanel.setBorder(new TitledBorder(Messages.getString("SetUpWindow.20"))); //$NON-NLS-1$ tfTerminalNumber = new IntegerTextField(); tfTerminalNumber.setColumns(10);/*from w ww .j a v a2s. c o m*/ contentPanel.add(new JLabel(Messages.getString("SetUpWindow.21"))); //$NON-NLS-1$ contentPanel.add(tfTerminalNumber, "aligny top,wrap"); //$NON-NLS-1$ tfSecretKeyLength = new IntegerTextField(3); contentPanel.add(new JLabel("Default password length")); //$NON-NLS-1$ contentPanel.add(tfSecretKeyLength, "wrap"); //$NON-NLS-1$ chkAutoLogoff = new JCheckBox(Messages.getString("SetUpWindow.22")); //$NON-NLS-1$ tfLogoffTime.setEnabled(false); chkAutoLogoff.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (chkAutoLogoff.isSelected()) { tfLogoffTime.setEnabled(true); } else { tfLogoffTime.setEnabled(false); } } }); contentPanel.add(chkAutoLogoff, "newline"); //$NON-NLS-1$ contentPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.16")), "split 2"); //$NON-NLS-1$ //$NON-NLS-2$ contentPanel.add(tfLogoffTime, "alignx left,grow,wrap"); //$NON-NLS-1$ contentPanel.add(new JLabel("Screen scaling")); //$NON-NLS-1$ tfScaleFactor = new DoubleTextField(5); contentPanel.add(tfScaleFactor); return contentPanel; }
From source file:org.esa.beam.visat.toolviews.stat.DensityPlotPanel.java
private JPanel createOptionsPanel() { toggleColorCheckBox = new JCheckBox("Invert plot colors"); toggleColorCheckBox.addActionListener(new ActionListener() { @Override//ww w . ja v a2 s.c om public void actionPerformed(ActionEvent e) { toggleColor(); } }); toggleColorCheckBox.setEnabled(false); final JPanel optionsPanel = GridBagUtils.createPanel(); final GridBagConstraints gbc = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=0,weightx=1,gridx=0"); GridBagUtils.addToPanel(optionsPanel, axisRangeControls[X_VAR].getPanel(), gbc, "gridy=0"); GridBagUtils.addToPanel(optionsPanel, xBandList, gbc, "gridy=1,insets.left=4,insets.right=2"); GridBagUtils.addToPanel(optionsPanel, axisRangeControls[Y_VAR].getPanel(), gbc, "gridy=2,insets.left=0,insets.right=0"); GridBagUtils.addToPanel(optionsPanel, yBandList, gbc, "gridy=3,insets.left=4,insets.right=2"); GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=4"); GridBagUtils.addToPanel(optionsPanel, new JSeparator(), gbc, "gridy=5,insets.left=4,insets.right=2"); GridBagUtils.addToPanel(optionsPanel, toggleColorCheckBox, gbc, "gridy=6,insets.left=0,insets.right=0"); return optionsPanel; }
From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java
@Override public void createUI() { super.createUI(); CellConstraints cc = new CellConstraints(); orderUpBtn = createIconBtn("ReorderUp", "TCGD_MOVE_UP", new ActionListener() { public void actionPerformed(ActionEvent ae) { int inx = fieldsTbl.getSelectedRow(); UIFieldFormatterField item = (UIFieldFormatterField) fields.get(inx); fields.remove(inx);/*from w w w .j av a 2s .c o m*/ fields.insertElementAt(item, inx - 1); fieldsTbl.getSelectionModel().setSelectionInterval(inx - 1, inx - 1); selectedFormat.resetLength(); updateEnabledState(); updateUIEnabled(); } }); orderDwnBtn = createIconBtn("ReorderDown", "TCGD_MOVE_DOWN", new ActionListener() { public void actionPerformed(ActionEvent ae) { int inx = fieldsTbl.getSelectedRow(); UIFieldFormatterField item = (UIFieldFormatterField) fields.get(inx); fields.remove(inx); fields.insertElementAt(item, inx + 1); fieldsTbl.getSelectionModel().setSelectionInterval(inx + 1, inx + 1); selectedFormat.resetLength(); updateEnabledState(); updateUIEnabled(); } }); // get formatters for field List<UIFieldFormatterIFace> fmtrs = new Vector<UIFieldFormatterIFace>(uiFieldFormatterMgrCache .getFormatterList(fieldInfo.getTableInfo().getClassObj(), fieldInfo.getName())); Collections.sort(fmtrs, new Comparator<UIFieldFormatterIFace>() { public int compare(UIFieldFormatterIFace o1, UIFieldFormatterIFace o2) { return o1.toPattern().compareTo(o2.toPattern()); } }); // table and field titles PanelBuilder tblInfoPB = new PanelBuilder( new FormLayout("r:p,2px,f:p:g", "p,2px,p,2px,p,10px")/*, new FormDebugPanel()*/); String typeStr = fieldInfo.getType(); typeStr = typeStr.indexOf('.') > -1 ? StringUtils.substringAfterLast(fieldInfo.getType(), ".") : typeStr; JLabel tableTitleLbl = createI18NFormLabel("FFE_TABLE"); JLabel tableTitleValueLbl = createLabel(fieldInfo.getTableInfo().getTitle()); tableTitleValueLbl.setBackground(Color.WHITE); tableTitleValueLbl.setOpaque(true); JLabel fieldTitleLbl = createI18NFormLabel("FFE_FIELD"); JLabel fieldTitleValueLbl = createLabel(fieldInfo.getTitle()); fieldTitleValueLbl.setBackground(Color.WHITE); fieldTitleValueLbl.setOpaque(true); JLabel fieldLengthLbl = createI18NFormLabel("FFE_LENGTH"); JLabel fieldLengthValueLbl = createLabel(Integer.toString(fieldInfo.getLength())); fieldLengthValueLbl.setBackground(Color.WHITE); fieldLengthValueLbl.setOpaque(true); int y = 1; tblInfoPB.add(tableTitleLbl, cc.xy(1, y)); tblInfoPB.add(tableTitleValueLbl, cc.xy(3, y)); y += 2; tblInfoPB.add(fieldTitleLbl, cc.xy(1, y)); tblInfoPB.add(fieldTitleValueLbl, cc.xy(3, y)); y += 2; tblInfoPB.add(fieldLengthLbl, cc.xy(1, y)); tblInfoPB.add(fieldLengthValueLbl, cc.xy(3, y)); y += 2; // sample panel sampleLabel = createLabel("", SwingConstants.LEFT); JPanel samplePanel = new JPanel(); samplePanel.setBorder(BorderFactory.createTitledBorder(getResourceString("FFE_SAMPLE"))); //$NON-NLS-1$ samplePanel.add(sampleLabel); // name text field nameTF = createTextField(20); // title text field titleTF = createTextField(20); byYearCB = createCheckBox(getResourceString("FFE_BY_YEAR_CHECKBOX")); //$NON-NLS-1$ hookByYearCheckBoxListener(); fieldsPanel = new EditDeleteAddPanel(getSaveAL(), getDelAL(), getAddAL()); fieldsTbl = new JTable(fieldsModel = new FieldsTableModel()); fieldTypeCbx = new JComboBox(FieldType.values()); // I18N fieldTxt = createTextField(20); fieldsPanel.getAddBtn().setEnabled(true); fieldsPanel.getEditBtn().setIcon(IconManager.getIcon("Green Arrow Up", IconManager.IconSize.Std16)); UIHelper.makeTableHeadersCentered(fieldsTbl, true); fieldTxt.setDocument(new FieldDocument()); fieldsTbl.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); int width = fieldTypeCbx.getPreferredSize().width; y = 1; PanelBuilder subPB = new PanelBuilder(new FormLayout("r:p,2px,p", "p,4px, p,4px, p,4px, p,4px")); subPB.add(createI18NFormLabel("FFE_NAME"), cc.xy(1, y)); subPB.add(nameTF, cc.xy(3, y)); y += 2; subPB.add(createI18NFormLabel("FFE_TITLE"), cc.xy(1, y)); subPB.add(titleTF, cc.xy(3, y)); y += 2; subPB.add(byYearCB, cc.xy(3, y)); y += 2; // CardLayout for Editor Panels SpinnerModel retModel = new SpinnerNumberModel(1, //initial value 1, //min fieldInfo.getLength(), //max 1); //step sizeSpinner = new JSpinner(retModel); isIncChk = new JCheckBox("Is Incrementer"); // I18N String colDefs = "f:p:g,p,2px," + width + "px,2px,p"; closeBtn = createClose(0); PanelBuilder numPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p,2px,p")); numPB.add(createI18NFormLabel("FFE_LENGTH"), cc.xy(2, 1)); numPB.add(sizeSpinner, cc.xy(4, 1)); //numPB.add(closeBtn, cc.xy(6, 1)); numPB.add(isIncChk, cc.xy(4, 3)); sepCbx = new JComboBox(new String[] { "-", ".", "/", "(space)", "_" }); closeBtn = createClose(1); PanelBuilder sepPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p")); sepPB.add(createI18NFormLabel("FFE_SEP"), cc.xy(2, 1)); sepPB.add(sepCbx, cc.xy(4, 1)); //sepPB.add(closeBtn, cc.xy(6, 1)); closeBtn = createClose(2); PanelBuilder txtPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p")); txtPB.add(createI18NFormLabel("FFE_TEXT"), cc.xy(2, 1)); txtPB.add(fieldTxt, cc.xy(4, 1)); cardPanel = new JPanel(cardLayout); cardPanel.add("size", numPB.getPanel()); cardPanel.add("text", txtPB.getPanel()); cardPanel.add("sep", sepPB.getPanel()); cardPanel.add("none", new JLabel(" ")); y = 1; PanelBuilder leftPB = new PanelBuilder(new FormLayout("f:p:g", "t:p,10px,p,f:p:g")); leftPB.add(tblInfoPB.getPanel(), cc.xy(1, y)); y += 2; leftPB.add(subPB.getPanel(), cc.xy(1, y)); y += 2; PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "f:p:g, p, 2px, p, f:p:g")); upDownPanel.add(orderUpBtn, cc.xy(1, 2)); upDownPanel.add(orderDwnBtn, cc.xy(1, 4)); totLenLbl = createLabel("XXXXX"); y = 1; PanelBuilder rightPB = new PanelBuilder(new FormLayout("p:g,2px,p,2px,p", "200px,2px,p,2px,p,2px,p")); rightPB.add(createScrollPane(fieldsTbl), cc.xywh(1, y, 3, 1)); rightPB.add(upDownPanel.getPanel(), cc.xywh(5, y, 1, 1)); y += 2; rightPB.add(totLenLbl, cc.xy(1, y)); rightPB.add(fieldsPanel, cc.xywh(3, y, 1, 1)); y += 2; rightPB.add(fieldTypeLbl = createI18NFormLabel("FFE_TYPE"), cc.xy(1, y)); rightPB.add(fieldTypeCbx, cc.xy(3, y)); rightPB.add(closeBtn, cc.xy(5, y)); y += 2; rightPB.add(cardPanel, cc.xyw(1, y, 3)); y += 2; y = 1; PanelBuilder pb = new PanelBuilder(new FormLayout("p:g,10px,p,10px,p:g,10px,p", "f:p:g,10px,p")); Color bg = getBackground(); pb.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xywh(3, 1, 1, 1)); pb.add(leftPB.getPanel(), cc.xy(1, y)); pb.add(rightPB.getPanel(), cc.xy(5, y)); //pb.add(keyPanel, cc.xy(7, y)); y += 2; pb.add(samplePanel, cc.xyw(1, y, 7)); y += 2; setByYearSelected(selectedFormat); nameTF.setEditable(isNew); nameTF.setText(selectedFormat.getName()); titleTF.setText(selectedFormat.getTitle()); updateSample(); hookTextChangeListener(nameTF, "FFE_NO_NAME", 32); hookTextChangeListener(titleTF, "FFE_NO_TITLE", 32); pb.setDefaultDialogBorder(); contentPanel = pb.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); updateUIEnabled(); pack(); enabledEditorUI(false); hookFieldsTblSelectionListener(); fieldTypeCbx.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { typeChanged(); } }); sepCbx.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { fieldHasChanged = true; updateEnabledState(); hasChanged = true; updateUIEnabled(); } }); fieldTxt.getDocument().addDocumentListener(new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { fieldHasChanged = true; updateEnabledState(); hasChanged = true; updateUIEnabled(); } }); sizeSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { fieldHasChanged = true; updateEnabledState(); hasChanged = true; updateUIEnabled(); } }); isIncChk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fieldHasChanged = true; if (!isIncChk.isSelected()) { byYearCB.setSelected(false); } updateEntry(); updateUIEnabled(); updateEnabledState(); fieldsTbl.repaint(); } }); fieldTypeCbx.setSelectedIndex(-1); fieldHasChanged = false; updateEnabledState(); }