public Component getDemoPanel() { final String[] fontNames = DemoData.getFontNames(); // create file text field List<String> urls = null; try { urls = readUrls(); } catch (IOException e) { //noinspection CallToPrintStackTrace e.printStackTrace(); } JTextField urlTextField = new JTextField("http://"); urlTextField.setName("URL IntelliHint"); SelectAllUtils.install(urlTextField); ListDataIntelliHints intelliHints = new ListDataIntelliHints<String>(urlTextField, urls); intelliHints.setCaseSensitive(false); JTextField pathTextField = new JTextField(); SelectAllUtils.install(pathTextField); FileIntelliHints fileIntelliHints = new FileIntelliHints(pathTextField); fileIntelliHints.setFilter( new FilenameFilter() { public boolean accept(File dir, String name) { return !_applyFileFilter || dir.getAbsolutePath().contains("Program") || name.contains("Program"); } }); fileIntelliHints.setFolderOnly(false); fileIntelliHints.setFollowCaret(true); fileIntelliHints.setShowFullPath(false); // create file text field JTextField fileTextField = new JTextField(); fileTextField.setName("File IntelliHint"); SelectAllUtils.install(fileTextField); new FileIntelliHints(fileTextField); // create file text field JTextArea fileTextArea = new JTextArea(); new FileIntelliHints(fileTextArea); fileTextArea.setRows(4); // create file text field JTextField fontTextField = new JTextField(); fontTextField.setName("Font IntelliHint"); SelectAllUtils.install(fontTextField); ListDataIntelliHints fontIntelliHints = new ListDataIntelliHints<String>(fontTextField, fontNames); fontIntelliHints.setCaseSensitive(false); JTextField textField = new JTextField(); SelectAllUtils.install(textField); //noinspection UnusedDeclaration new AbstractListIntelliHints(textField) { protected JLabel _messageLabel; @Override public JComponent createHintsComponent() { JPanel panel = (JPanel) super.createHintsComponent(); _messageLabel = new JLabel(); panel.add(_messageLabel, BorderLayout.BEFORE_FIRST_LINE); return panel; } // update list model depending on the data in textfield public boolean updateHints(Object value) { if (value == null) { return false; } String s = value.toString(); s = s.trim(); if (s.length() == 0) { return false; } try { long l = Long.parseLong(s); boolean prime = isProbablePrime(l); _messageLabel.setText(""); if (prime) { return false; } else { Vector<Long> list = new Vector<Long>(); long nextPrime = l; for (int i = 0; i < 10; i++) { nextPrime = nextPrime(nextPrime); list.add(nextPrime); } setListData(list); _messageLabel.setText("Next 10 prime numbers:"); _messageLabel.setForeground(Color.DARK_GRAY); return true; } } catch (NumberFormatException e) { setListData(new Object[0]); _messageLabel.setText("Invalid long number"); setListData(new Object[0]); _messageLabel.setForeground(Color.RED); return true; } } }; DefaultTableModel model = new DefaultTableModel(0, 1) { private static final long serialVersionUID = -2794741068912785630L; @Override public Class<?> getColumnClass(int columnIndex) { return String.class; } @Override public String getColumnName(int column) { return "Font"; } }; model.addRow(new Object[] {"Arial"}); model.addRow(new Object[] {"Tahoma"}); SortableTable table = new SortableTable(model); table .getColumnModel() .getColumn(0) .setCellEditor( new TextFieldCellEditor(String.class) { private static final long serialVersionUID = 2023654568542192380L; @Override protected JTextField createTextField() { JTextField cellEditorTextField = new JTextField(); ListDataIntelliHints fontIntellihints = new ListDataIntelliHints<String>(cellEditorTextField, fontNames); fontIntellihints.setCaseSensitive(false); return cellEditorTextField; } }); table.setPreferredScrollableViewportSize(new Dimension(100, 100)); JPanel panel = new JPanel(); panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS, 3)); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); panel.add(new JLabel("ListDataIntelliHints TextField for URLs: ")); panel.add(urlTextField); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); // create path text field panel.add( new JLabel("FileIntelliHints TextField for paths (folders only, show partial path):")); panel.add(pathTextField); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); panel.add( new JLabel("FileIntelliHints TextField for files (files and folders, show full path):")); panel.add(fileTextField); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); panel.add(new JLabel("FileIntelliHints TextArea for files (each line is for a new file):")); panel.add(new JScrollPane(fileTextArea)); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); panel.add(new JLabel("IntelliHints TextField to choose a font:")); panel.add(fontTextField); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); panel.add(new JLabel("A custom IntelliHints for prime numbers: ")); panel.add(textField); panel.add(Box.createVerticalStrut(6), JideBoxLayout.FIX); panel.add(new JLabel("Using IntelliHint in JTable's cell editor")); panel.add(new JScrollPane(table), JideBoxLayout.FLEXIBLE); panel.add(Box.createGlue(), JideBoxLayout.VARY); return panel; }
private void refresh(int index) { GridBagConstraints c = new GridBagConstraints(); // No connector ................ if (acs.size() == 0) { add(new JLabel(bundle.getString("CTL_No_Connector")), c); return; } // Connector switch ................ if (acs.size() > 1) { c.insets = new Insets(0, 0, 3, 3); add(new JLabel(bundle.getString("CTL_Connector")), c); cbConnectors = new JComboBox(); int i, k = acs.size(); for (i = 0; i < k; i++) { AttachingConnector ac = (AttachingConnector) acs.get(i); int jj = ac.name().lastIndexOf('.'); String s = (jj < 0) ? ac.name() : ac.name().substring(jj + 1); cbConnectors.addItem(s + " (" + ac.description() + ")"); } c = new GridBagConstraints(); c.insets = new Insets(0, 3, 3, 0); c.weightx = 1.0; c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.gridwidth = 0; cbConnectors.setSelectedIndex(index); cbConnectors.setActionCommand("SwitchMe!"); cbConnectors.addActionListener(this); add(cbConnectors, c); } ac = (AttachingConnector) acs.get(index); // Transport ................ c = new GridBagConstraints(); c.insets = new Insets(3, 0, 0, 3); add(new JLabel(bundle.getString("CTL_Transport")), c); JTextField tfTransport = new JTextField(ac.transport().name()); tfTransport.setEnabled(false); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(3, 3, 0, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfTransport, c); // Other params ................ args = ac.defaultArguments(); tfParams = new JTextField[args.size()]; Iterator it = args.keySet().iterator(); int i = 0; while (it.hasNext()) { String name = (String) it.next(); Argument a = (Argument) args.get(name); c = new GridBagConstraints(); c.insets = new Insets(6, 0, 0, 3); c.anchor = GridBagConstraints.WEST; add(new JLabel(a.label() + ": "), c); JTextField tfParam = new JTextField(a.value()); tfParams[i++] = tfParam; tfParam.setName(name); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(6, 3, 0, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfParam, c); } c = new GridBagConstraints(); c.weighty = 1.0; JPanel p = new JPanel(); p.setPreferredSize(new Dimension(1, 1)); add(p, c); }
public void execute_TestCase2() throws Exception { setUndecorated(true); setRootPaneCheckingEnabled(false); setForeground(Color.BLACK); setBackground(Color.WHITE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 774, 353); setLocationRelativeTo(null); setVisible(true); contentPane = new JPanel(); contentPane.setFocusCycleRoot(true); contentPane.setDebugGraphicsOptions(DebugGraphics.NONE_OPTION); contentPane.setBounds(new Rectangle(100, 100, 130, 100)); contentPane.setBackground(Color.WHITE); setContentPane(contentPane); contentPane.setLayout(null); JLabel lblEnterThePath = new JLabel("Select Path of Working Folder"); lblEnterThePath.setForeground(new Color(128, 128, 128)); lblEnterThePath.setFont(new Font("Tahoma", Font.BOLD, 11)); lblEnterThePath.setBackground(new Color(0, 0, 0)); lblEnterThePath.setBounds(63, 104, 187, 31); contentPane.add(lblEnterThePath); txtHello = new JTextField(); txtHello.setName(""); txtHello.setBounds(271, 104, 296, 31); txtHello.setEditable(false); contentPane.add(txtHello); txtHello.setColumns(10); JLabel lblSelectPathOf = new JLabel("Select Path of Configuration File"); lblSelectPathOf.setForeground(new Color(128, 128, 128)); lblSelectPathOf.setFont(new Font("Tahoma", Font.BOLD, 11)); lblSelectPathOf.setBounds(63, 149, 187, 28); contentPane.add(lblSelectPathOf); textField_1 = new JTextField(); textField_1.setBounds(271, 146, 296, 31); textField_1.setEditable(false); contentPane.add(textField_1); textField_1.setColumns(10); JLabel lblWelcomeToVitalhealth = new JLabel("Welcome to VitalHealth Test Automation Framework"); lblWelcomeToVitalhealth.setHorizontalTextPosition(SwingConstants.CENTER); lblWelcomeToVitalhealth.setForeground(new Color(128, 128, 128)); lblWelcomeToVitalhealth.setFont(new Font("Tahoma", Font.BOLD, 14)); lblWelcomeToVitalhealth.setHorizontalAlignment(SwingConstants.CENTER); lblWelcomeToVitalhealth.setBackground(Color.BLACK); lblWelcomeToVitalhealth.setBounds(191, 22, 465, 34); contentPane.add(lblWelcomeToVitalhealth); Button button = new Button("Browse"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { showOpenFileDialog(); } }); button.setForeground(Color.WHITE); button.setFont(new Font("Dialog", Font.BOLD, 12)); button.setBackground(new Color(51, 153, 255)); button.setBounds(573, 104, 113, 31); contentPane.add(button); Button button_1 = new Button("Browse"); button_1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { showOpenFileDialog1(); } }); button_1.setForeground(Color.WHITE); button_1.setFont(new Font("Dialog", Font.BOLD, 12)); button_1.setBackground(new Color(51, 153, 255)); button_1.setBounds(573, 146, 113, 31); contentPane.add(button_1); Button button_2 = new Button("RUN TEST"); button_2.setForeground(Color.WHITE); button_2.setFont(new Font("Dialog", Font.BOLD, 12)); button_2.setBackground(new Color(30, 144, 255)); button_2.setBounds(63, 205, 623, 34); contentPane.add(button_2); Button button_3 = new Button("DOWNLOAD SAMPLE EXCEL WEB"); button_3.setActionCommand("DOWNLOAD SAMPLE EXCEL WEB"); button_3.setForeground(new Color(128, 128, 128)); button_3.setFont(new Font("Dialog", Font.BOLD, 12)); button_3.setBackground(Color.WHITE); button_3.setBounds(564, 309, 200, 34); contentPane.add(button_3); Button button_4 = new Button("DOWNLOAD SAMPLE EXCEL MOBILE"); button_4.setForeground(new Color(128, 128, 128)); button_4.setFont(new Font("Dialog", Font.BOLD, 12)); button_4.setBackground(Color.WHITE); button_4.setActionCommand("DOWNLOAD SAMPLE EXCEL MOBILE"); button_4.setBounds(23, 309, 227, 34); contentPane.add(button_4); JLabel icon = new JLabel(""); Image img = new ImageIcon(this.getClass().getResource("/VitalHealth.png")).getImage(); icon.setIcon(new ImageIcon(img)); icon.setBounds(23, 11, 173, 71); contentPane.add(icon); // L1 l1 = new L1(); L2 l2 = new L2(); button_4.addActionListener(new L1(Constants.Download_ExcelWeb, Constants.Excel_NameMobile)); button_3.addActionListener(new L1(Constants.Download_ExcelWeb, Constants.Excel_NameWeb)); button_2.addActionListener(l2); }