List of usage examples for javax.swing JCheckBox JCheckBox
public JCheckBox(Action a)
From source file:com.floreantpos.ui.forms.CustomerForm.java
private void createCustomerForm() { setOpaque(true);/*from w w w . ja v a 2s . c o m*/ setLayout(new MigLayout("", "[][][grow][][grow]", "[][][][][][][][][][][][][][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ picturePanel = new JPanel(new MigLayout()); lblPicture = new JLabel(""); //$NON-NLS-1$ lblPicture.setIconTextGap(0); lblPicture.setHorizontalAlignment(SwingConstants.CENTER); picturePanel.setBorder(new TitledBorder(null, Messages.getString("CustomerForm.10"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); picturePanel.add(lblPicture, "wrap,center"); //$NON-NLS-1$ btnSelectImage = new PosSmallButton(); btnSelectImage.setText(Messages.getString("CustomerForm.44")); //$NON-NLS-1$ picturePanel.add(btnSelectImage, "split 2"); //$NON-NLS-1$ btnClearImage = new PosSmallButton(); btnClearImage.setText(Messages.getString("CustomerForm.45")); //$NON-NLS-1$ picturePanel.add(btnClearImage); add(picturePanel, "cell 0 0 0 8"); //$NON-NLS-1$ JLabel lblSalutation = new JLabel(Messages.getString("CustomerForm.0")); //$NON-NLS-1$ add(lblSalutation, "cell 1 0,right"); //$NON-NLS-1$ cbSalutation = new JComboBox(); cbSalutation.addItem(Messages.getString("CustomerForm.2")); //$NON-NLS-1$ cbSalutation.addItem(Messages.getString("CustomerForm.4")); //$NON-NLS-1$ cbSalutation.addItem(Messages.getString("CustomerForm.5")); //$NON-NLS-1$ cbSalutation.addItem(Messages.getString("CustomerForm.6")); //$NON-NLS-1$ cbSalutation.setPreferredSize(new Dimension(100, 0)); add(cbSalutation, "cell 2 0,grow"); //$NON-NLS-1$ JLabel lblFirstName = new JLabel(Messages.getString("CustomerForm.3")); //$NON-NLS-1$ add(lblFirstName, "cell 1 1,right "); //$NON-NLS-1$ tfFirstName = new FixedLengthTextField(30); add(tfFirstName, "cell 2 1,grow"); //$NON-NLS-1$ //tfFirstName.setFocusTraversalPolicy(policy) JLabel lblLastName = new JLabel(Messages.getString("CustomerForm.11")); //$NON-NLS-1$ add(lblLastName, "cell 1 2,right"); //$NON-NLS-1$ tfLastName = new FixedLengthTextField(); add(tfLastName, "cell 2 2,grow"); //$NON-NLS-1$ lblDob = new JLabel("DoB (MM-DD-YYYY)"); //$NON-NLS-1$ add(lblDob, "cell 1 3,right"); //$NON-NLS-1$ tfDoB = new FixedLengthTextField(); add(tfDoB, "cell 2 3,grow"); //$NON-NLS-1$ JLabel lblAddress = new JLabel(Messages.getString("CustomerForm.18")); //$NON-NLS-1$ add(lblAddress, "cell 1 4,right"); //$NON-NLS-1$ tfAddress = new JTextField(); add(tfAddress, "cell 2 4,grow"); //$NON-NLS-1$ JLabel lblZip = new JLabel(Messages.getString("CustomerForm.21")); //$NON-NLS-1$ add(lblZip, "cell 1 5,right"); //$NON-NLS-1$ tfZip = new FixedLengthTextField(); add(tfZip, "cell 2 5,grow"); //$NON-NLS-1$ lblSocialSecurityNumber = new JLabel(Messages.getString("CustomerForm.22")); //$NON-NLS-1$ add(lblSocialSecurityNumber, "cell 3 0,right"); //$NON-NLS-1$ tfSocialSecurityNumber = new FixedLengthTextField(); add(tfSocialSecurityNumber, "cell 4 0,grow"); //$NON-NLS-1$ JLabel lblCitytown = new JLabel(Messages.getString("CustomerForm.24")); //$NON-NLS-1$ add(lblCitytown, "cell 3 1,right"); //$NON-NLS-1$ // tfCity = new FixedLengthTextField(); add(tfCity, "cell 4 1,grow"); //$NON-NLS-1$ JLabel lblCountry = new JLabel(Messages.getString("CustomerForm.27")); //$NON-NLS-1$ add(lblCountry, "cell 3 2,right"); //$NON-NLS-1$ tfCountry = new FixedLengthTextField(); tfCountry.setText(Messages.getString("CustomerForm.29")); //$NON-NLS-1$ add(tfCountry, "cell 4 2,grow"); //$NON-NLS-1$ lblMobile = new JLabel(Messages.getString("CustomerForm.32")); //$NON-NLS-1$ add(lblMobile, "cell 3 3 ,right"); //$NON-NLS-1$ tfMobile = new IntegerTextField(10); add(tfMobile, "cell 4 3,grow"); //$NON-NLS-1$ lblHomePhone = new JLabel("Home Phone");//$NON-NLS-1$ add(lblHomePhone, "cell 3 4,right"); //$NON-NLS-1$ tfHomePhone = new FixedLengthTextField(); add(tfHomePhone, "cell 4 4,grow"); //$NON-NLS-1$ lblWorkPhone = new JLabel(Messages.getString("CustomerForm.39")); //$NON-NLS-1$ add(lblWorkPhone, "cell 3 5,right"); //$NON-NLS-1$ tfWorkPhone = new FixedLengthTextField(); add(tfWorkPhone, "cell 4 5,grow"); //$NON-NLS-1$ JLabel lblEmail = new JLabel(Messages.getString("CustomerForm.15")); //$NON-NLS-1$ add(lblEmail, "cell 3 6 ,right"); //$NON-NLS-1$ tfEmail = new FixedLengthTextField(); add(tfEmail, "cell 4 6,grow"); //$NON-NLS-1$ lblLoyaltyPoint = new JLabel(Messages.getString("CustomerForm.34")); //$NON-NLS-1$ add(lblLoyaltyPoint, "cell 3 7,right"); //$NON-NLS-1$ tfLoyaltyPoint = new IntegerTextField(); add(tfLoyaltyPoint, "cell 4 7,grow"); //$NON-NLS-1$ cbVip = new JCheckBox(Messages.getString("CustomerForm.41")); //$NON-NLS-1$ cbVip.setFocusable(false); add(cbVip, "cell 4 8,wrap"); //$NON-NLS-1$ JLabel lblLoyaltyNo = new JLabel(Messages.getString("CustomerForm.31")); //$NON-NLS-1$ add(lblLoyaltyNo, "cell 1 6,right"); //$NON-NLS-1$ tfLoyaltyNo = new FixedLengthTextField(); tfLoyaltyNo.setLength(8); add(tfLoyaltyNo, "cell 2 6,grow"); //$NON-NLS-1$ JLabel lblCreditLimit = new JLabel(Messages.getString("CustomerForm.37")); //$NON-NLS-1$ add(lblCreditLimit, "cell 1 7,right"); //$NON-NLS-1$ tfCreditLimit = new DoubleTextField(); tfCreditLimit.setText("500.00"); //$NON-NLS-1$ add(tfCreditLimit, "cell 2 7,grow"); //$NON-NLS-1$ qwertyKeyPad = new QwertyKeyPad(); if (isKeypad) { add(qwertyKeyPad, "cell 0 10 5 5,grow"); //$NON-NLS-1$ } btnSelectImage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { BufferedImage tmpImage; tmpImage = PosGuiUtil.selectImageFile(); if (tmpImage != null) { image = tmpImage; } if (image == null) { return; } ImageIcon imageIcon = new ImageIcon(image); lblPicture.setIcon(imageIcon); } catch (Exception e1) { PosLog.error(getClass(), e1); } } }); btnClearImage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setDefaultCustomerPicture(); } }); setDefaultCustomerPicture(); enableCustomerFields(false); callOrderController(); }
From source file:is.iclt.jcorpald.CorpaldView.java
public void createAndShowGUI() { CorpaldSettings settings = CorpaldSettings.getInstance(); //Create and set up the window. JFrame frame = new JFrame(settings.getProperty("corpus.acronym") + " " + settings.getProperty("corpus.version") + " - " + settings.getProperty("corpus.longname")); frame.setIconImage((new ImageIcon("icons/corpald.png")).getImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setBounds(50, 50, 700, 450); frame.setPreferredSize(new Dimension(750, 720)); // Create the panel that has the query and the result JPanel panMainArea = new JPanel(new BorderLayout()); JPanel panQuery = new JPanel(new BorderLayout()); txtQuery = new JHighlightPane(); txtQuery.addKeyListener(this); txtQuery.setFont(new Font("Monospaced", Font.BOLD, 16)); this.updateHighlighting(); txtQuery.setPreferredSize(new Dimension(700, 150)); panQuery.add(labQuery, BorderLayout.NORTH); panQuery.add(new JScrollPane(txtQuery, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS), BorderLayout.CENTER); panQuery.setBorder(new EmptyBorder(0, 10, 10, 10)); String welcomeMessage = ""; try {// w ww. jav a2 s . c o m welcomeMessage = FileUtils.readFileToString(new File(settings.getProperty("corpus.welcome")), "utf-8"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } JPanel panResult = new JPanel(new BorderLayout()); txtResult = new JTextArea(welcomeMessage); txtResult.setEditable(false); txtResult.setFont(new Font("Monospaced", Font.BOLD, 14)); JScrollPane scrResult = new JScrollPane(txtResult, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrResult.setPreferredSize(new Dimension(700, 400)); panResult.add(new JLabel("Result:"), BorderLayout.NORTH); panResult.add(scrResult, BorderLayout.CENTER); panResult.setBorder(new EmptyBorder(0, 10, 0, 10)); panMainArea.add(panQuery, BorderLayout.NORTH); panMainArea.add(panResult, BorderLayout.CENTER); // Create panel at top with buttons JPanel panToolbar = new JPanel(new FlowLayout(FlowLayout.CENTER)); // New, Open, Save // New ImageIcon icoNewQuery = new ImageIcon("icons/page_white.png"); butNewQuery = new JButton(icoNewQuery); butNewQuery.addActionListener(this); butNewQuery.setPreferredSize(new Dimension(26, 26)); butNewQuery.setToolTipText("Create a new empty query"); panToolbar.add(butNewQuery); // Open ImageIcon icoOpenQuery = new ImageIcon("icons/folder.png"); butOpenQuery = new JButton(icoOpenQuery); butOpenQuery.addActionListener(this); butOpenQuery.setPreferredSize(new Dimension(26, 26)); butOpenQuery.setToolTipText("Open a query file"); panToolbar.add(butOpenQuery); // Save ImageIcon icoSaveQuery = new ImageIcon("icons/page_save.png"); butSaveQuery = new JButton(icoSaveQuery); butSaveQuery.addActionListener(this); butSaveQuery.setPreferredSize(new Dimension(26, 26)); butSaveQuery.setToolTipText("Save current query"); panToolbar.add(butSaveQuery); // Save as ImageIcon icoSaveQueryAs = new ImageIcon("icons/page_save_as.png"); butSaveQueryAs = new JButton(icoSaveQueryAs); butSaveQueryAs.addActionListener(this); butSaveQueryAs.setPreferredSize(new Dimension(26, 26)); butSaveQueryAs.setToolTipText("Save current query under a new file name"); panToolbar.add(butSaveQueryAs); // Open definitions file ImageIcon icoOpenDef = new ImageIcon("icons/folder_table.png"); butOpenDef = new JButton(icoOpenDef); butOpenDef.addActionListener(this); butOpenDef.setPreferredSize(new Dimension(26, 26)); butOpenDef.setToolTipText("Select a new definitions file"); panToolbar.add(butOpenDef); // Run Query button ImageIcon icoRunQuery = new ImageIcon("icons/control_play_blue.png"); butRunQuery = new JButton("Run Query", icoRunQuery); butRunQuery.setPreferredSize(new Dimension(130, 26)); butRunQuery.addActionListener(this); butRunQuery.setToolTipText("Run the current query using CorpusSearch"); panToolbar.add(butRunQuery); // TextField for root node label JLabel labRootNode = new JLabel("Root:"); panToolbar.add(labRootNode); txtRootNode = new JTextField("", 12); txtRootNode.setPreferredSize(new Dimension(50, 26)); txtRootNode.addKeyListener(this); txtRootNode.setMargin(new Insets(3, 3, 3, 3)); txtRootNode.setToolTipText("<html>Search within instances of a particular type of node,<br/>" + "such as IP-*, IP-SUB, NP-*, etc. $ROOT matches<br/>" + "the root node of every tree in the corpus.</html>"); panToolbar.add(txtRootNode); chkNodesOnly = new JCheckBox("Nodes only"); chkNodesOnly.addItemListener(this); chkNodesOnly.setToolTipText("<html>If checked, CorpusSearch prints out only the nodes that<br/>" + "contain the structure described in \"Query\". If not checked,<br/>" + "CorpusSearch prints out the entire sentence that contains the<br/>" + "structure described in \"Query\".</html>"); panToolbar.add(chkNodesOnly); chkRemoveNodes = new JCheckBox("Remove nodes"); chkRemoveNodes.addItemListener(this); chkRemoveNodes.setToolTipText("<html>Remove subtrees whose root is of the same syntactic category<br/>" + "as the node boundary embedded within a instance of that node<br/>" + "boundary. \"Remove nodes\" thus removes recursive structure.</html>"); panToolbar.add(chkRemoveNodes); // Create panel at top with buttons JPanel panBottombar = new JPanel(new FlowLayout(FlowLayout.CENTER)); // panBottombar.setBorder(new EmptyBorder(0, 0, 10, 5)); ImageIcon icoOpenFolder = new ImageIcon("icons/folder.png"); butOpenFolder = new JButton("Show result in folder", icoOpenFolder); butOpenFolder.setEnabled(false); butOpenFolder.addActionListener(this); panBottombar.add(butOpenFolder); ImageIcon icoTextEditor = new ImageIcon("icons/page_white_go.png"); butTextEditor = new JButton("Open result in text editor", icoTextEditor); butTextEditor.setEnabled(false); butTextEditor.addActionListener(this); panBottombar.add(butTextEditor); ImageIcon icoCopyResults = new ImageIcon("icons/page_copy.png"); butCopyResults = new JButton("Copy result to clipboard", icoCopyResults); butCopyResults.setEnabled(false); butCopyResults.addActionListener(this); panBottombar.add(butCopyResults); // Add stuff to top level content pane frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(panToolbar, BorderLayout.NORTH); frame.getContentPane().add(panMainArea, BorderLayout.CENTER); frame.getContentPane().add(panBottombar, BorderLayout.SOUTH); this.configureFileFilters(); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:com.sshtools.common.ui.SshToolsConnectionHostTab.java
/** * Creates a new SshToolsConnectionHostTab object. *///from w w w. j a va 2s . c o m public SshToolsConnectionHostTab() { super(); // Create the main connection details panel JPanel mainConnectionDetailsPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(0, 2, 2, 2); gbc.weightx = 1.0; // Host name UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Hostname"), gbc, GridBagConstraints.REMAINDER); gbc.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextHostname, gbc, GridBagConstraints.REMAINDER); gbc.fill = GridBagConstraints.NONE; // Port UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Port"), gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextPort, gbc, GridBagConstraints.REMAINDER); // Username UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weighty = 1.0; UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextUsername, gbc, GridBagConstraints.REMAINDER); gbc.fill = GridBagConstraints.NONE; // IconWrapperPanel iconMainConnectionDetailsPanel = new IconWrapperPanel( new ResourceIcon(SshToolsConnectionHostTab.class, CONNECT_ICON), mainConnectionDetailsPanel); // Authentication methods panel JPanel authMethodsPanel = new JPanel(new GridBagLayout()); authMethodsPanel.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0)); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 2; GridBagConstraints gbc2 = new GridBagConstraints(); gbc2.fill = GridBagConstraints.HORIZONTAL; gbc2.anchor = GridBagConstraints.NORTHWEST; gbc2.insets = new Insets(2, 2, 2, 2); gbc2.weightx = 1.0; gbc2.weighty = 0.0; gbc2.gridx = 0; gbc2.gridy = 1; gbc2.gridwidth = 2; GridBagConstraints gbc3 = new GridBagConstraints(); gbc3.fill = GridBagConstraints.HORIZONTAL; gbc3.anchor = GridBagConstraints.NORTHWEST; gbc3.insets = new Insets(2, 2, 2, 2); gbc3.weightx = 1.0; gbc3.weighty = 0.0; gbc3.gridx = 0; gbc3.gridy = 2; gbc3.gridwidth = 2; GridBagConstraints gbc4 = new GridBagConstraints(); gbc4.fill = GridBagConstraints.HORIZONTAL; gbc4.anchor = GridBagConstraints.NORTHWEST; gbc4.insets = new Insets(26, 2, 2, 2); gbc4.weightx = 0.0; gbc4.weighty = 0.0; gbc4.gridx = 0; gbc4.gridy = 3; gbc4.gridwidth = 1; GridBagConstraints gbc5 = new GridBagConstraints(); gbc5.fill = GridBagConstraints.NONE; gbc5.anchor = GridBagConstraints.WEST; gbc5.insets = new Insets(26, 2, 2, 2); gbc5.weightx = 1.0; gbc5.weighty = 0.0; gbc5.gridx = 1; gbc5.gridy = 3; gbc5.gridwidth = 1; GridBagConstraints gbc6 = new GridBagConstraints(); gbc6.fill = GridBagConstraints.HORIZONTAL; gbc6.anchor = GridBagConstraints.NORTHWEST; gbc6.insets = new Insets(12, 2, 2, 2); gbc6.weightx = 0.0; gbc6.weighty = 0.0; gbc6.gridx = 0; gbc6.gridy = 4; gbc6.gridwidth = 1; GridBagConstraints gbc7 = new GridBagConstraints(); gbc7.fill = GridBagConstraints.NONE; gbc7.anchor = GridBagConstraints.WEST; gbc7.insets = new Insets(12, 2, 2, 2); gbc7.weightx = 1.0; gbc7.weighty = 0.0; gbc7.gridx = 1; gbc7.gridy = 4; gbc7.gridwidth = 1; GridBagConstraints gbc8 = new GridBagConstraints(); gbc8.fill = GridBagConstraints.HORIZONTAL; gbc8.anchor = GridBagConstraints.NORTHWEST; gbc8.insets = new Insets(12, 2, 2, 2); gbc8.weightx = 0.0; gbc8.weighty = 0.0; gbc8.gridx = 0; gbc8.gridy = 5; gbc8.gridwidth = 1; GridBagConstraints gbc9 = new GridBagConstraints(); gbc9.fill = GridBagConstraints.NONE; gbc9.anchor = GridBagConstraints.WEST; gbc9.insets = new Insets(12, 2, 2, 2); gbc9.weightx = 1.0; gbc9.weighty = 0.0; gbc9.gridx = 1; gbc9.gridy = 5; gbc9.gridwidth = 1; GridBagConstraints gbc10 = new GridBagConstraints(); gbc10.fill = GridBagConstraints.HORIZONTAL; gbc10.anchor = GridBagConstraints.NORTHWEST; gbc10.insets = new Insets(26, 2, 2, 2); gbc10.weightx = 1.0; gbc10.weighty = 0.0; gbc10.gridx = 0; gbc10.gridy = 6; gbc10.gridwidth = 2; // Authentication methods authMethodsPanel.add(new JLabel("Authentication Methods"), gbc); jListAuths.setVisibleRowCount(5); authMethodsPanel.add(new JScrollPane(jListAuths), gbc2); allowAgentForwarding = new JCheckBox("Allow agent forwarding"); authMethodsPanel.add(allowAgentForwarding, gbc3); String options[] = { "Full", "Limited", "None" }; delegationOption = new JComboBox(options); delegationOption.setSelectedIndex(0); authMethodsPanel.add(new JLabel("Delegation Type:"), gbc4); authMethodsPanel.add(delegationOption, gbc5); String optionsP[] = { "Pre-RFC Impersonation", "RFC Impersonation", "Legacy" }; proxyOption = new JComboBox(optionsP); proxyOption.setSelectedIndex(0); authMethodsPanel.add(new JLabel("Proxy Type:"), gbc6); authMethodsPanel.add(proxyOption, gbc7); authMethodsPanel.add(new JLabel("Proxy Lifetime (hours):"), gbc8); proxyLength.setColumns(5); authMethodsPanel.add(proxyLength, gbc9); gbc.gridx = 0; proxySave = new JCheckBox("Save Grid Proxies to Disk"); authMethodsPanel.add(proxySave, gbc10); // IconWrapperPanel iconAuthMethodsPanel = new IconWrapperPanel( new ResourceIcon(SshToolsConnectionHostTab.class, AUTH_ICON), authMethodsPanel); // This panel JPanel mine = new JPanel(); mine.setLayout(new GridBagLayout()); mine.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTH; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 0; mine.add(iconMainConnectionDetailsPanel, gbc); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTH; gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 1; gbc.insets = new Insets(20, 2, 2, 2); mine.add(iconAuthMethodsPanel, gbc); setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); this.add(mine, BorderLayout.NORTH); // Set up the values in the various components addAuthenticationMethods(); }
From source file:net.nikr.eve.jeveasset.gui.tabs.tracker.TrackerTab.java
public TrackerTab(Program program) { super(program, TabsTracker.get().title(), Images.TOOL_TRACKER.getIcon(), true); filterDialog = new TrackerFilterDialog(program); jPopupMenu = new JPopupMenu(); jPopupMenu.addPopupMenuListener(listener); JMenuItem jMenuItem;//from w ww . j a v a2s. c o m jMenuItem = new JMenuItem(TabsTracker.get().edit(), Images.EDIT_EDIT.getIcon()); jMenuItem.setActionCommand(TrackerAction.EDIT.name()); jMenuItem.addActionListener(listener); jPopupMenu.add(jMenuItem); jMenuItem = new JMenuItem(TabsTracker.get().delete(), Images.EDIT_DELETE.getIcon()); jMenuItem.setActionCommand(TrackerAction.DELETE.name()); jMenuItem.addActionListener(listener); jPopupMenu.add(jMenuItem); JMenuInfo.createDefault(jPopupMenu); jIskValue = new JMenuItem(); jIskValue.setEnabled(false); jIskValue.setForeground(Color.BLACK); jIskValue.setHorizontalAlignment(SwingConstants.RIGHT); jIskValue.setDisabledIcon(Images.TOOL_VALUES.getIcon()); jPopupMenu.add(jIskValue); jDateValue = new JMenuItem(); jDateValue.setEnabled(false); jDateValue.setForeground(Color.BLACK); jDateValue.setHorizontalAlignment(SwingConstants.RIGHT); jPopupMenu.add(jDateValue); jEditDialog = new JTrackerEditDialog(program); jSelectionDialog = new JSelectionDialog(program); JSeparator jDateSeparator = new JSeparator(); jQuickDate = new JComboBox<QuickDate>(QuickDate.values()); jQuickDate.setActionCommand(TrackerAction.QUICK_DATE.name()); jQuickDate.addActionListener(listener); JLabel jFromLabel = new JLabel(TabsTracker.get().from()); jFrom = createDateChooser(); JLabel jToLabel = new JLabel(TabsTracker.get().to()); jTo = createDateChooser(); jAll = new JCheckBox(General.get().all()); jAll.setSelected(true); jAll.setActionCommand(TrackerAction.ALL.name()); jAll.addActionListener(listener); jAll.setFont(new Font(jAll.getFont().getName(), Font.ITALIC, jAll.getFont().getSize())); jTotal = new JCheckBox(TabsTracker.get().total()); jTotal.setSelected(true); jTotal.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jTotal.addActionListener(listener); jWalletBalance = new JCheckBox(TabsTracker.get().walletBalance()); jWalletBalance.setSelected(true); jWalletBalance.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jWalletBalance.addActionListener(listener); jWalletBalanceFilters = new JButton(Images.LOC_INCLUDE.getIcon()); jWalletBalanceFilters.setActionCommand(TrackerAction.FILTER_WALLET_BALANCE.name()); jWalletBalanceFilters.addActionListener(listener); jAssets = new JCheckBox(TabsTracker.get().assets()); jAssets.setSelected(true); jAssets.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jAssets.addActionListener(listener); jAssetsFilters = new JButton(Images.LOC_INCLUDE.getIcon()); jAssetsFilters.setActionCommand(TrackerAction.FILTER_ASSETS.name()); jAssetsFilters.addActionListener(listener); jSellOrders = new JCheckBox(TabsTracker.get().sellOrders()); jSellOrders.setSelected(true); jSellOrders.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jSellOrders.addActionListener(listener); jEscrows = new JCheckBox(TabsTracker.get().escrows()); jEscrows.setSelected(true); jEscrows.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jEscrows.addActionListener(listener); jEscrowsToCover = new JCheckBox(TabsTracker.get().escrowsToCover()); jEscrowsToCover.setSelected(true); jEscrowsToCover.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jEscrowsToCover.addActionListener(listener); jManufacturing = new JCheckBox(TabsTracker.get().manufacturing()); jManufacturing.setSelected(true); jManufacturing.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jManufacturing.addActionListener(listener); jContractCollateral = new JCheckBox(TabsTracker.get().contractCollateral()); jContractCollateral.setSelected(true); jContractCollateral.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jContractCollateral.addActionListener(listener); jContractValue = new JCheckBox(TabsTracker.get().contractValue()); jContractValue.setSelected(true); jContractValue.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jContractValue.addActionListener(listener); JSeparator jOwnersSeparator = new JSeparator(); jAllProfiles = new JCheckBox(TabsTracker.get().allProfiles()); jAllProfiles.setActionCommand(TrackerAction.PROFILE.name()); jAllProfiles.addActionListener(listener); jOwners = new JMultiSelectionList<String>(); jOwners.getSelectionModel().addListSelectionListener(listener); JScrollPane jOwnersScroll = new JScrollPane(jOwners); JLabel jHelp = new JLabel(TabsTracker.get().help()); jHelp.setIcon(Images.MISC_HELP.getIcon()); JLabel jNoFilter = new JLabel(TabsTracker.get().helpLegacyData()); jNoFilter.setIcon(new ShapeIcon(NO_FILTER)); JLabel jFilter = new JLabel(TabsTracker.get().helpNewData()); jFilter.setIcon(new ShapeIcon(FILTER_AND_DEFAULT)); JDropDownButton jSettings = new JDropDownButton(Images.DIALOG_SETTINGS.getIcon()); jIncludeZero = new JCheckBoxMenuItem(TabsTracker.get().includeZero()); jIncludeZero.setSelected(true); jIncludeZero.setActionCommand(TrackerAction.INCLUDE_ZERO.name()); jIncludeZero.addActionListener(listener); jSettings.add(jIncludeZero); DateAxis domainAxis = new DateAxis(); domainAxis.setDateFormatOverride(dateFormat); domainAxis.setVerticalTickLabels(true); domainAxis.setAutoTickUnitSelection(true); domainAxis.setAutoRange(true); domainAxis.setTickLabelFont(jFromLabel.getFont()); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRange(true); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setTickLabelFont(jFromLabel.getFont()); //XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, new XYLineAndShapeRenderer(true, true)); render = new MyRender(); XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, render); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.getRenderer() .setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: {2} ({1})", dateFormat, iskFormat)); plot.setDomainCrosshairLockedOnData(true); plot.setDomainCrosshairStroke(new BasicStroke(1)); plot.setDomainCrosshairPaint(Color.BLACK); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairLockedOnData(true); plot.setRangeCrosshairVisible(false); jNextChart = new JFreeChart(plot); jNextChart.setAntiAlias(true); jNextChart.setBackgroundPaint(jPanel.getBackground()); jNextChart.addProgressListener(null); jNextChart.getLegend().setItemFont(jFrom.getFont()); jChartPanel = new ChartPanel(jNextChart); jChartPanel.addMouseListener(listener); jChartPanel.setDomainZoomable(false); jChartPanel.setRangeZoomable(false); jChartPanel.setPopupMenu(null); jChartPanel.addChartMouseListener(listener); jChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); jChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); jChartPanel.setMinimumDrawWidth(10); jChartPanel.setMinimumDrawHeight(10); int AssetsGapWidth = PANEL_WIDTH - jAssets.getPreferredSize().width - jAssetsFilters.getPreferredSize().width; if (AssetsGapWidth < 0) { AssetsGapWidth = 0; } int WalletGapWidth = PANEL_WIDTH - jWalletBalance.getPreferredSize().width - jWalletBalanceFilters.getPreferredSize().width; if (WalletGapWidth < 0) { WalletGapWidth = 0; } layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup() .addGroup(layout.createSequentialGroup().addComponent(jHelp).addGap(20).addComponent(jNoFilter) .addGap(20).addComponent(jFilter).addGap(20, 20, Integer.MAX_VALUE).addComponent(jSettings) .addGap(6)) .addComponent(jChartPanel)).addGroup( layout.createParallelGroup().addComponent(jQuickDate, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup() .addComponent(jFromLabel, LABEL_WIDTH, LABEL_WIDTH, LABEL_WIDTH) .addComponent(jToLabel, LABEL_WIDTH, LABEL_WIDTH, LABEL_WIDTH)) .addGap(0) .addGroup(layout.createParallelGroup() .addComponent(jFrom, PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH) .addComponent(jTo, PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH))) .addComponent(jDateSeparator, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jAll, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jTotal, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addGroup(layout.createSequentialGroup().addComponent(jWalletBalance) .addGap(0, 0, WalletGapWidth).addComponent(jWalletBalanceFilters)) .addGroup(layout.createSequentialGroup().addComponent(jAssets) .addGap(0, 0, AssetsGapWidth).addComponent(jAssetsFilters)) .addComponent(jSellOrders, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jEscrows, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jEscrowsToCover, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jManufacturing, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jContractCollateral, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jContractValue, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jOwnersSeparator, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jAllProfiles, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jOwnersScroll, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH))); layout.setVerticalGroup(layout.createParallelGroup() .addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup() .addComponent(jHelp, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jNoFilter, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jFilter, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jSettings, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())) .addComponent(jChartPanel)) .addGroup(layout.createSequentialGroup() .addComponent(jQuickDate, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addGroup(layout.createParallelGroup() .addComponent(jFromLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jFrom, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())) .addGroup(layout.createParallelGroup() .addComponent(jToLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jTo, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())) .addComponent(jDateSeparator, 3, 3, 3) .addComponent(jAll, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jTotal, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addGroup(layout.createParallelGroup() .addComponent(jWalletBalance, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jWalletBalanceFilters, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())) .addGroup(layout.createParallelGroup() .addComponent(jAssets, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jAssetsFilters, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())) .addComponent(jSellOrders, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jEscrows, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jEscrowsToCover, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jManufacturing, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jContractCollateral, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jContractValue, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jOwnersSeparator, 3, 3, 3) .addComponent(jAllProfiles, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jOwnersScroll, 70, 70, Integer.MAX_VALUE))); }
From source file:org.esa.snap.rcp.statistics.StatisticsPanel.java
private JPanel createAccuracyPanel() { final JPanel accuracyPanel = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); final JLabel label = new JLabel("Histogram accuracy:"); accuracyModel = new AccuracyModel(); final BindingContext bindingContext = new BindingContext( PropertyContainer.createObjectBacked(accuracyModel)); final SpinnerNumberModel accuracyNumberModel = new SpinnerNumberModel(accuracyModel.accuracy, 0, Util.MAX_ACCURACY, 1); final JSpinner accuracySpinner = new JSpinner(accuracyNumberModel); ((JSpinner.DefaultEditor) accuracySpinner.getEditor()).getTextField().setEditable(false); bindingContext.bind("accuracy", accuracySpinner); final JCheckBox checkBox = new JCheckBox("Auto accuracy"); bindingContext.bind("useAutoAccuracy", checkBox); final IntervalValidator rangeValidator = new IntervalValidator(new ValueRange(0, Util.MAX_ACCURACY)); final PropertyDescriptor accuracyDescriptor = bindingContext.getPropertySet().getDescriptor("accuracy"); accuracyDescriptor.setValidator(rangeValidator); checkBox.setSelected(accuracyModel.useAutoAccuracy); bindingContext.getPropertySet().getProperty("useAutoAccuracy") .addPropertyChangeListener(new PropertyChangeListener() { @Override/*from www . j av a 2 s . c om*/ public void propertyChange(PropertyChangeEvent evt) { label.setEnabled(!checkBox.isSelected()); accuracySpinner.setEnabled(!checkBox.isSelected()); if (checkBox.isSelected()) { bindingContext.getBinding("accuracy").setPropertyValue(3); } computePanel.updateEnablement(); } }); label.setEnabled(false); accuracySpinner.setEnabled(false); accuracySpinner.setToolTipText("Specify the number of histogram bins (#bins: 10^accuracy)."); accuracySpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { computePanel.updateEnablement(); } }); GridBagUtils.addToPanel(accuracyPanel, new TitledSeparator("Histogram accuracy"), gbc, "fill=HORIZONTAL, weightx=1.0,anchor=NORTH,gridwidth=2"); GridBagUtils.addToPanel(accuracyPanel, checkBox, gbc, "gridy=1,insets.left=5,insets.top=2"); GridBagUtils.addToPanel(accuracyPanel, label, gbc, "gridy=2, insets.left=26,weightx=0.0,fill=NONE,anchor=WEST,gridwidth=1"); GridBagUtils.addToPanel(accuracyPanel, accuracySpinner, gbc, "gridx=1,weightx=1.0,fill=HORIZONTAL,insets.right=5,insets.left=5"); return accuracyPanel; }
From source file:ucar.unidata.util.AccountManager.java
/** * Make the gui/*from w ww. ja v a 2 s . com*/ */ private void makeDialog() { serverLabel = new JLabel(" "); nameFld = new JTextField("", 10); passwdFld = new JPasswordField("", 10); saveCbx = new JCheckBox("Save Password"); JButton okBtn = new JButton("OK"); ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { ok = true; dialog.dispose(); } }; nameFld.addActionListener(okListener); passwdFld.addActionListener(okListener); okBtn.addActionListener(okListener); JButton cancelBtn = new JButton("Cancel"); cancelBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { ok = false; dialog.dispose(); } }); GuiUtils.tmpInsets = GuiUtils.INSETS_5; JPanel contents = GuiUtils.doLayout(new Component[] { GuiUtils.rLabel("Name:"), nameFld, GuiUtils.rLabel("Password:"), passwdFld, GuiUtils.filler(), saveCbx }, 2, GuiUtils.WT_N, GuiUtils.WT_N); contents = GuiUtils.topCenterBottom(serverLabel, contents, GuiUtils.wrap(GuiUtils .doLayout(new Component[] { okBtn, new JLabel(" "), cancelBtn }, 3, GuiUtils.WT_N, GuiUtils.WT_N))); dialog = GuiUtils.createDialog("Server Authentication", true); dialog.getContentPane().add(GuiUtils.inset(contents, 5)); dialog.pack(); dialog.setLocation(200, 200); }
From source file:dnd.BasicDnD.java
public BasicDnD() { super(new BorderLayout()); JPanel leftPanel = createVerticalBoxPanel(); JPanel rightPanel = createVerticalBoxPanel(); //Create a table model. DefaultTableModel tm = new DefaultTableModel(); tm.addColumn("Column 0"); tm.addColumn("Column 1"); tm.addColumn("Column 2"); tm.addColumn("Column 3"); tm.addRow(new String[] { "Table 00", "Table 01", "Table 02", "Table 03" }); tm.addRow(new String[] { "Table 10", "Table 11", "Table 12", "Table 13" }); tm.addRow(new String[] { "Table 20", "Table 21", "Table 22", "Table 23" }); tm.addRow(new String[] { "Table 30", "Table 31", "Table 32", "Table 33" }); //LEFT COLUMN //Use the table model to create a table. table = new JTable(tm); leftPanel.add(createPanelForComponent(table, "JTable")); //Create a color chooser. colorChooser = new JColorChooser(); leftPanel.add(createPanelForComponent(colorChooser, "JColorChooser")); //RIGHT COLUMN //Create a textfield. textField = new JTextField(30); textField.setText("Favorite foods:\nPizza, Moussaka, Pot roast"); rightPanel.add(createPanelForComponent(textField, "JTextField")); //Create a scrolled text area. textArea = new JTextArea(5, 30); textArea.setText("Favorite shows:\nBuffy, Alias, Angel"); JScrollPane scrollPane = new JScrollPane(textArea); rightPanel.add(createPanelForComponent(scrollPane, "JTextArea")); //Create a list model and a list. DefaultListModel listModel = new DefaultListModel(); listModel.addElement("Martha Washington"); listModel.addElement("Abigail Adams"); listModel.addElement("Martha Randolph"); listModel.addElement("Dolley Madison"); listModel.addElement("Elizabeth Monroe"); listModel.addElement("Louisa Adams"); listModel.addElement("Emily Donelson"); list = new JList(listModel); list.setVisibleRowCount(-1);/*from w w w . jav a 2 s. c om*/ list.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); list.setTransferHandler(new TransferHandler() { public boolean canImport(TransferHandler.TransferSupport info) { // we only import Strings if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { return false; } JList.DropLocation dl = (JList.DropLocation) info.getDropLocation(); if (dl.getIndex() == -1) { return false; } return true; } public boolean importData(TransferHandler.TransferSupport info) { if (!info.isDrop()) { return false; } // Check for String flavor if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { displayDropLocation("List doesn't accept a drop of this type."); return false; } JList.DropLocation dl = (JList.DropLocation) info.getDropLocation(); DefaultListModel listModel = (DefaultListModel) list.getModel(); int index = dl.getIndex(); boolean insert = dl.isInsert(); // Get the current string under the drop. String value = (String) listModel.getElementAt(index); // Get the string that is being dropped. Transferable t = info.getTransferable(); String data; try { data = (String) t.getTransferData(DataFlavor.stringFlavor); } catch (Exception e) { return false; } // Display a dialog with the drop information. String dropValue = "\"" + data + "\" dropped "; if (dl.isInsert()) { if (dl.getIndex() == 0) { displayDropLocation(dropValue + "at beginning of list"); } else if (dl.getIndex() >= list.getModel().getSize()) { displayDropLocation(dropValue + "at end of list"); } else { String value1 = (String) list.getModel().getElementAt(dl.getIndex() - 1); String value2 = (String) list.getModel().getElementAt(dl.getIndex()); displayDropLocation(dropValue + "between \"" + value1 + "\" and \"" + value2 + "\""); } } else { displayDropLocation(dropValue + "on top of " + "\"" + value + "\""); } /** This is commented out for the basicdemo.html tutorial page. ** If you add this code snippet back and delete the ** "return false;" line, the list will accept drops ** of type string. // Perform the actual import. if (insert) { listModel.add(index, data); } else { listModel.set(index, data); } return true; */ return false; } public int getSourceActions(JComponent c) { return COPY; } protected Transferable createTransferable(JComponent c) { JList list = (JList) c; Object[] values = list.getSelectedValues(); StringBuffer buff = new StringBuffer(); for (int i = 0; i < values.length; i++) { Object val = values[i]; buff.append(val == null ? "" : val.toString()); if (i != values.length - 1) { buff.append("\n"); } } return new StringSelection(buff.toString()); } }); list.setDropMode(DropMode.ON_OR_INSERT); JScrollPane listView = new JScrollPane(list); listView.setPreferredSize(new Dimension(300, 100)); rightPanel.add(createPanelForComponent(listView, "JList")); //Create a tree. DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Mia Familia"); DefaultMutableTreeNode sharon = new DefaultMutableTreeNode("Sharon"); rootNode.add(sharon); DefaultMutableTreeNode maya = new DefaultMutableTreeNode("Maya"); sharon.add(maya); DefaultMutableTreeNode anya = new DefaultMutableTreeNode("Anya"); sharon.add(anya); sharon.add(new DefaultMutableTreeNode("Bongo")); maya.add(new DefaultMutableTreeNode("Muffin")); anya.add(new DefaultMutableTreeNode("Winky")); DefaultTreeModel model = new DefaultTreeModel(rootNode); tree = new JTree(model); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JScrollPane treeView = new JScrollPane(tree); treeView.setPreferredSize(new Dimension(300, 100)); rightPanel.add(createPanelForComponent(treeView, "JTree")); //Create the toggle button. toggleDnD = new JCheckBox("Turn on Drag and Drop"); toggleDnD.setActionCommand("toggleDnD"); toggleDnD.addActionListener(this); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); splitPane.setOneTouchExpandable(true); add(splitPane, BorderLayout.CENTER); add(toggleDnD, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:org.esa.beam.visat.toolviews.stat.HistogramPanel.java
private JPanel createOptionsPanel() { final JLabel numBinsLabel = new JLabel("#Bins:"); JTextField numBinsField = new JTextField(Integer.toString(NUM_BINS_DEFAULT)); numBinsField.setPreferredSize(new Dimension(50, numBinsField.getPreferredSize().height)); final JCheckBox histoLogCheck = new JCheckBox("Log10 scaled bins"); histoLogCheck.addActionListener(configChangeListener); bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_NUM_BINS) .setDescription("Set the number of bins in the histogram"); bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_NUM_BINS) .setValueRange(new ValueRange(2.0, 2048.0)); bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_NUM_BINS).setDefaultValue(NUM_BINS_DEFAULT); bindingContext.bind(PROPERTY_NAME_NUM_BINS, numBinsField); bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM) .setDescription("Use log-10 scaled values for computation of histogram"); bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM).setDefaultValue(false); bindingContext.bind(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM, histoLogCheck); log10HistEnablement = bindingContext.bindEnabledState(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM, true, new Enablement.Condition() { @Override// ww w . j ava 2 s .co m public boolean evaluate(BindingContext bindingContext) { return getRaster() != null && getRaster().getStx().getMaximum() > 0; } }); PropertyChangeListener logChangeListener = new AxisControlChangeListener(); xAxisRangeControl.getBindingContext().addPropertyChangeListener(logChangeListener); xAxisRangeControl.getBindingContext().getPropertySet() .addProperty(bindingContext.getPropertySet().getProperty(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM)); xAxisRangeControl.getBindingContext().getPropertySet() .addProperty(bindingContext.getPropertySet().getProperty(PROPERTY_NAME_LOG_SCALED)); xAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_LOG_SCALED) .setDescription("Toggle whether to use a logarithmic x-axis"); log10AxisEnablement = xAxisRangeControl.getBindingContext().bindEnabledState(PROPERTY_NAME_LOG_SCALED, true, new Enablement.Condition() { @Override public boolean evaluate(BindingContext bindingContext) { HistogramPanelModel.HistogramConfig currentConfig = createHistogramConfig(); boolean hasStx = model.hasStx(currentConfig); // log10 xAxis is enabled when current histogram exists and is NOT log10 scaled return dataset != null && hasStx && !model.getStx(currentConfig).isLogHistogram(); } }); JPanel dataSourceOptionsPanel = GridBagUtils.createPanel(); GridBagConstraints dataSourceOptionsConstraints = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2"); GridBagUtils.addToPanel(dataSourceOptionsPanel, new JLabel(" "), dataSourceOptionsConstraints, "gridwidth=2,gridy=0,gridx=0,weightx=0"); GridBagUtils.addToPanel(dataSourceOptionsPanel, numBinsLabel, dataSourceOptionsConstraints, "insets.top=2,insets.left=4,gridwidth=1,gridy=1,gridx=0,weightx=1"); GridBagUtils.addToPanel(dataSourceOptionsPanel, numBinsField, dataSourceOptionsConstraints, "insets.top=0,insets.left=0,insets.right=2,gridwidth=1,gridy=1,gridx=1"); GridBagUtils.addToPanel(dataSourceOptionsPanel, histoLogCheck, dataSourceOptionsConstraints, "insets.right=0,gridwidth=2,gridy=2,gridx=0"); xAxisRangeControl.getBindingContext().bind(PROPERTY_NAME_LOG_SCALED, new JCheckBox("Log10 scaled")); xAxisRangeControl.getBindingContext().addPropertyChangeListener(PROPERTY_NAME_LOG_SCALED, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { ValueAxis oldAxis = chart.getXYPlot().getDomainAxis(); ValueAxis newAxis = StatisticChartStyling.updateScalingOfAxis((Boolean) evt.getNewValue(), oldAxis, true); chart.getXYPlot().setDomainAxis(newAxis); } }); JPanel displayOptionsPanel = GridBagUtils.createPanel(); GridBagConstraints displayOptionsConstraints = GridBagUtils .createConstraints("anchor=SOUTH,fill=HORIZONTAL,weightx=1"); GridBagUtils.addToPanel(displayOptionsPanel, xAxisRangeControl.getPanel(), displayOptionsConstraints, "gridy=2"); JPanel optionsPanel = GridBagUtils.createPanel(); GridBagConstraints gbc = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1"); GridBagUtils.addToPanel(optionsPanel, dataSourceOptionsPanel, gbc, "gridy=0"); GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=1,fill=VERTICAL,weighty=1"); GridBagUtils.addToPanel(optionsPanel, displayOptionsPanel, gbc, "gridy=2,fill=HORIZONTAL,weighty=0"); GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=3,fill=VERTICAL,weighty=1"); GridBagUtils.addToPanel(optionsPanel, xAxisRangeControl.getBindingContext().getBinding(PROPERTY_NAME_LOG_SCALED).getComponents()[0], gbc, "gridy=4"); return optionsPanel; }
From source file:com.sec.ose.osi.ui.frm.main.identification.autoidentify.JPanImportSPDX.java
private JCheckBox getJCheckOverwrite() { if (jCheckOverwrite == null) { jCheckOverwrite = new JCheckBox("Overwrite if the file already identified."); jCheckOverwrite.setSelected(true); }/*from w w w .j a v a 2 s . c o m*/ return jCheckOverwrite; }
From source file:com.midas.classify.gui.DecisionTreeViewer.java
public DecisionTreeViewer(DelegateTree<TreeNode, TreeEdge> tr, String[] cls) { setLayout(new BorderLayout()); // ---------------------------------------------- // // INICIALIZACION DE COMPONENTES DE VISUALIZACION // // ---------------------------------------------- // tree = tr;//from w w w. ja va 2 s . c om classNames = cls; classColors = new TreeMap(); nodeColor = Color.BLUE; for (int i = 0; i < cls.length; ++i) { classColors.put(cls[i], Color.RED); } leafNodes = new TreeSet(); for (TreeNode n : tr.getVertices()) { if (tr.isLeaf(n)) { for (String s : cls) { if (n.toString().startsWith(s)) { leafNodes.add(s); break; } } } } TreeLayout<TreeNode, TreeEdge> layout = new TreeLayout(tr); vv = new VisualizationViewer(layout); vv.setBackground(Color.white); vv.getRenderContext().setEdgeFontTransformer(new EdgeFontTransformer()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<TreeNode, TreeEdge>()); PickedState<TreeNode> picked_state = vv.getPickedVertexState(); vv.getRenderContext().setVertexFillPaintTransformer(new VertexFillColorTransformer<TreeNode>(picked_state)); vv.getRenderContext().setVertexDrawPaintTransformer(new VertexDrawColorTransformer<TreeNode>(picked_state)); vv.getRenderContext().setVertexFontTransformer(new VertexFontTransformer()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); GraphZoomScrollPane scrollPane = new GraphZoomScrollPane(vv); gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final ScalingControl scaler = new CrossoverScalingControl(); // ---------------------------------------- // // INICIALIZACION DE COMPONENTES DE CONTROL // // ---------------------------------------- // fontChooser = new JFontChooser(); JPanel pControl = new JPanel(new GridLayout(7, 1, 4, 2)); JPanel pZoom = new JPanel(new GridLayout(1, 2, 2, 2)); pZoom.setBorder(new TitledBorder("Zoom")); bZoomIn = new JButton("+"); bZoomIn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); bZoomOut = new JButton("-"); bZoomOut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); pZoom.add(bZoomIn); pZoom.add(bZoomOut); JPanel pFont = new JPanel(new GridLayout(1, 2, 2, 2)); pFont.setBorder(new TitledBorder("Fonts")); bNodeFont = new JButton("Node Font"); bNodeFont.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fontChooser.showDialog(null); if (r == JFontChooser.OK_OPTION) { nodeFont = fontChooser.getSelectedFont(); vv.repaint(); } } }); bEdgeFont = new JButton("Edge Font"); bEdgeFont.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fontChooser.showDialog(null); if (r == JFontChooser.OK_OPTION) { edgeFont = fontChooser.getSelectedFont(); vv.repaint(); } } }); pFont.add(bNodeFont); pFont.add(bEdgeFont); bNodeColor = new JButton("Node Color"); bNodeColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { nodeColor = JColorChooser.showDialog(null, "Select color for intern nodes", Color.RED); vv.repaint(); } }); JPanel pMode = new JPanel(); pMode.setBorder(new TitledBorder("Mode")); cbMode = new JComboBox(); cbMode.addItem(ModalGraphMouse.Mode.TRANSFORMING); cbMode.addItem(ModalGraphMouse.Mode.PICKING); cbMode.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { gm.setMode((ModalGraphMouse.Mode) e.getItem()); } }); pMode.add(cbMode); JPanel pColors = new JPanel(new GridLayout(1, 2, 2, 2)); pColors.setBorder(new TitledBorder("Node Colors")); cbClasses = new JComboBox(classNames); cbClasses.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(null, "Select class color for " + cbClasses.getSelectedItem(), Color.RED); classColors.put(cbClasses.getSelectedItem().toString(), c); vv.repaint(); } }); pColors.add(cbClasses); pColors.add(bNodeColor); JPanel pLabelPosition = new JPanel(); pLabelPosition.setBorder(new TitledBorder("Label Position")); cbLabelPosition = new JComboBox(); cbLabelPosition.addItem(Renderer.VertexLabel.Position.N); cbLabelPosition.addItem(Renderer.VertexLabel.Position.NE); cbLabelPosition.addItem(Renderer.VertexLabel.Position.E); cbLabelPosition.addItem(Renderer.VertexLabel.Position.SE); cbLabelPosition.addItem(Renderer.VertexLabel.Position.S); cbLabelPosition.addItem(Renderer.VertexLabel.Position.SW); cbLabelPosition.addItem(Renderer.VertexLabel.Position.W); cbLabelPosition.addItem(Renderer.VertexLabel.Position.NW); cbLabelPosition.addItem(Renderer.VertexLabel.Position.N); cbLabelPosition.addItem(Renderer.VertexLabel.Position.CNTR); cbLabelPosition.addItem(Renderer.VertexLabel.Position.AUTO); cbLabelPosition.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem(); vv.getRenderer().getVertexLabelRenderer().setPosition(position); vv.repaint(); } }); cbLabelPosition.setSelectedItem(Renderer.VertexLabel.Position.SE); pLabelPosition.add(cbLabelPosition); chkShowEdgeNames = new JCheckBox("Show Edge Name"); chkShowEdgeNames.addActionListener(new ActionListener() { ToStringLabeller strLabeller = new ToStringLabeller(); ConstantTransformer none = new ConstantTransformer(null); @Override public void actionPerformed(ActionEvent e) { AbstractButton src = (AbstractButton) e.getSource(); if (src.isSelected()) { vv.getRenderContext().setEdgeLabelTransformer(strLabeller); } else { vv.getRenderContext().setEdgeLabelTransformer(none); } vv.repaint(); } }); chkShowEdgeNames.setSelected(true); chkShowNodeNames = new JCheckBox("Show Node Name"); chkShowNodeNames.addActionListener(new ActionListener() { ToStringLabeller strLabeller = new ToStringLabeller(); ConstantTransformer none = new ConstantTransformer(null); @Override public void actionPerformed(ActionEvent e) { AbstractButton src = (AbstractButton) e.getSource(); if (src.isSelected()) { vv.getRenderContext().setVertexLabelTransformer(strLabeller); } else { vv.getRenderContext().setVertexLabelTransformer(none); } vv.repaint(); } }); chkShowNodeNames.setSelected(true); pControl.add(pZoom); pControl.add(pFont); pControl.add(pMode); pControl.add(pLabelPosition); pControl.add(pColors); pControl.add(chkShowNodeNames); pControl.add(chkShowEdgeNames); // Agregar componentes al panel add(scrollPane); JPanel p = new JPanel(new FlowLayout()); p.add(pControl); add(p, BorderLayout.EAST); }