List of usage examples for java.awt TextField TextField
public TextField() throws HeadlessException
From source file:FileLister.java
/** * Constructor: create the GUI, and list the initial directory. *///from ww w . j av a 2s . c o m public FileLister(String directory, FilenameFilter filter) { super("File Lister"); // Create the window this.filter = filter; // Save the filter, if any // Destroy the window when the user requests it addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); list = new List(12, false); // Set up the list list.setFont(new Font("MonoSpaced", Font.PLAIN, 14)); list.addActionListener(this); list.addItemListener(this); details = new TextField(); // Set up the details area details.setFont(new Font("MonoSpaced", Font.PLAIN, 12)); details.setEditable(false); buttons = new Panel(); // Set up the button box buttons.setLayout(new FlowLayout(FlowLayout.RIGHT, 15, 5)); buttons.setFont(new Font("SansSerif", Font.BOLD, 14)); up = new Button("Up a Directory"); // Set up the two buttons close = new Button("Close"); up.addActionListener(this); close.addActionListener(this); buttons.add(up); // Add buttons to button box buttons.add(close); this.add(list, "Center"); // Add stuff to the window this.add(details, "North"); this.add(buttons, "South"); this.setSize(500, 350); listDirectory(directory); // And now list initial directory. }
From source file:jgnash.ui.report.compiled.PayeePieChart.java
private JPanel createPanel() { JButton refreshButton = new JButton(rb.getString("Button.Refresh")); JButton addFilterButton = new JButton(rb.getString("Button.AddFilter")); final JButton saveButton = new JButton(rb.getString("Button.SaveFilters")); JButton deleteFilterButton = new JButton(rb.getString("Button.DeleteFilter")); JButton clearPrefButton = new JButton(rb.getString("Button.MasterDelete")); filterCombo = new JComboBox<>(); startField = new DatePanel(); endField = new DatePanel(); txtAddFilter = new TextField(); filterList = new ArrayList<>(); filtersChanged = false;//from w ww . j a va 2 s . co m useFilters = new JCheckBox(rb.getString("Label.UseFilters")); useFilters.setSelected(true); showPercentCheck = new JCheckBox(rb.getString("Button.ShowPercentValues")); combo = AccountListComboBox.getFullInstance(); final LocalDate dStart = DateUtils.getFirstDayOfTheMonth(LocalDate.now().minusYears(1)); long start = pref.getLong(START_DATE, DateUtils.asEpochMilli(dStart)); startField.setDate(DateUtils.asLocalDate(start)); currentAccount = combo.getSelectedAccount(); PieDataset[] data = createPieDataSet(currentAccount); JFreeChart chartCredit = createPieChart(currentAccount, data, 0); chartPanelCredit = new ChartPanel(chartCredit, true, true, true, false, true); // (chart, properties, save, print, zoom, tooltips) JFreeChart chartDebit = createPieChart(currentAccount, data, 1); chartPanelDebit = new ChartPanel(chartDebit, true, true, true, false, true); FormLayout layout = new FormLayout("p, $lcgap, 70dlu, 8dlu, p, $lcgap, 70dlu, $ugap, p, $lcgap:g, left:p", "d, $rgap, d, $ugap, f:p:g, $rgap, d"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); layout.setRowGroups(new int[][] { { 1, 3 } }); // row 1 builder.append(combo, 9); builder.append(useFilters); builder.nextLine(); builder.nextLine(); // row 3 builder.append(rb.getString("Label.StartDate"), startField); builder.append(rb.getString("Label.EndDate"), endField); builder.append(refreshButton); builder.append(showPercentCheck); builder.nextLine(); builder.nextLine(); // row 5 FormLayout subLayout = new FormLayout("180dlu:g, 1dlu, 180dlu:g", "f:180dlu:g"); DefaultFormBuilder subBuilder = new DefaultFormBuilder(subLayout); subBuilder.append(chartPanelCredit); subBuilder.append(chartPanelDebit); builder.append(subBuilder.getPanel(), 11); builder.nextLine(); builder.nextLine(); // row 7 builder.append(txtAddFilter, 3); builder.append(addFilterButton, 3); builder.append(saveButton); builder.nextLine(); // row builder.append(filterCombo, 3); builder.append(deleteFilterButton, 3); builder.append(clearPrefButton); builder.nextLine(); JPanel panel = builder.getPanel(); combo.addActionListener(e -> { Account newAccount = combo.getSelectedAccount(); if (filtersChanged) { int result = JOptionPane.showConfirmDialog(null, rb.getString("Message.SaveFilters"), "Warning", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { saveButton.doClick(); } } filtersChanged = false; String[] list = POUND_DELIMITER_PATTERN.split(pref.get(FILTER_TAG + newAccount.hashCode(), "")); filterList.clear(); for (String filter : list) { if (!filter.isEmpty()) { //System.out.println("Adding filter: #" + filter + "#"); filterList.add(filter); } } refreshFilters(); setCurrentAccount(newAccount); pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate())); }); refreshButton.addActionListener(e -> { setCurrentAccount(currentAccount); pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate())); }); clearPrefButton.addActionListener(e -> { int result = JOptionPane.showConfirmDialog(null, rb.getString("Message.MasterDelete"), "Warning", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { try { pref.clear(); } catch (Exception ex) { System.out.println("Exception clearing preferences" + ex); } } }); saveButton.addActionListener(e -> { final StringBuilder sb = new StringBuilder(); for (String filter : filterList) { sb.append(filter); sb.append('#'); } //System.out.println("Save = " + FILTER_TAG + currentAccount.hashCode() + " = " + sb.toString()); pref.put(FILTER_TAG + currentAccount.hashCode(), sb.toString()); filtersChanged = false; }); addFilterButton.addActionListener(e -> { String newFilter = txtAddFilter.getText(); filterList.remove(newFilter); if (!newFilter.isEmpty()) { filterList.add(newFilter); filtersChanged = true; txtAddFilter.setText(""); } refreshFilters(); }); deleteFilterButton.addActionListener(e -> { if (!filterList.isEmpty()) { String filter = (String) filterCombo.getSelectedItem(); filterList.remove(filter); filtersChanged = true; } refreshFilters(); }); useFilters.addActionListener(e -> setCurrentAccount(currentAccount)); showPercentCheck.addActionListener(e -> { ((PiePlot) chartPanelCredit.getChart().getPlot()) .setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels); ((PiePlot) chartPanelDebit.getChart().getPlot()) .setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels); }); return panel; }
From source file:DummyAppletContext.java
private void init(Applet applet, int default_width, int default_height, String args[], int startidx) { URL.setURLStreamHandlerFactory(this); applets.addElement(applet);// www . j a v a 2 s. c o m applet.setStub(this); initial_width = default_width; initial_height = default_height; parseArgs(args, startidx); status = new TextField(); status.setEditable(false); add("Center", applet); add("South", status); appletResize(initial_width, initial_height); show(); applet.init(); applet.start(); }
From source file:gdsc.smlm.ij.plugins.SpotAnalysis.java
private void createFrame() { Panel mainPanel = new Panel(); add(mainPanel);// ww w. j av a2 s . c om inputChoice = new Choice(); mainPanel.add(createChoicePanel(inputChoice, "")); widthTextField = new TextField(); mainPanel.add(createTextPanel(widthTextField, "PSF width", "1.2")); blurTextField = new TextField(); mainPanel.add(createTextPanel(blurTextField, "Blur (relative to width)", "1")); gainTextField = new TextField(); mainPanel.add(createTextPanel(gainTextField, "Gain", "37.7")); exposureTextField = new TextField(); mainPanel.add(createTextPanel(exposureTextField, "ms/Frame", "20")); smoothingTextField = new TextField(); mainPanel.add(createTextPanel(smoothingTextField, "Smoothing", "0.25")); profileButton = new Button("Profile"); profileButton.addActionListener(this); addButton = new Button("Add"); addButton.addActionListener(this); deleteButton = new Button("Remove"); deleteButton.addActionListener(this); saveButton = new Button("Save"); saveButton.addActionListener(this); saveTracesButton = new Button("Save Traces"); saveTracesButton.addActionListener(this); currentLabel = new Label(); mainPanel.add(createLabelPanel(currentLabel, "", "")); rawFittedLabel = new Label(); mainPanel.add(createLabelPanel(rawFittedLabel, "", "")); blurFittedLabel = new Label(); mainPanel.add(createLabelPanel(blurFittedLabel, "", "")); JPanel buttonPanel = new JPanel(); FlowLayout l = new FlowLayout(); l.setVgap(0); buttonPanel.setLayout(l); buttonPanel.add(profileButton, BorderLayout.CENTER); buttonPanel.add(addButton, BorderLayout.CENTER); buttonPanel.add(deleteButton, BorderLayout.CENTER); buttonPanel.add(saveButton, BorderLayout.CENTER); buttonPanel.add(saveTracesButton, BorderLayout.CENTER); mainPanel.add(buttonPanel); listModel = new DefaultListModel<Spot>(); onFramesList = new JList<Spot>(listModel); onFramesList.setVisibleRowCount(15); onFramesList.addListSelectionListener(this); //mainPanel.add(onFramesList); JScrollPane scrollPane = new JScrollPane(onFramesList); scrollPane.getVerticalScrollBarPolicy(); mainPanel.add(scrollPane); GridBagLayout mainGrid = new GridBagLayout(); int y = 0; GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.insets = new Insets(2, 2, 2, 2); for (Component comp : mainPanel.getComponents()) { c.gridy = y++; mainGrid.setConstraints(comp, c); } mainPanel.setLayout(mainGrid); }
From source file:org.opensc.test.pkcs11.PINEntry.java
/** * Contructs a PINEntry instance. //from ww w. j a v a 2 s . c om */ public PINEntry() { super(); Frame frame = new Frame("PIN entry"); frame.setLayout(new GridLayout(2, 2)); frame.add(new Label("Event:")); this.label = new Label("NO_EVENT"); frame.add(this.label); this.prompt = new Label(); frame.add(this.prompt); this.listener = new PINListener(frame); this.textField = new TextField(); this.textField.setEchoChar('*'); this.textField.addKeyListener(this.listener); frame.add(this.textField); frame.addWindowListener(this.listener); frame.pack(); frame.setVisible(true); GraphicsConfiguration gc = frame.getGraphicsConfiguration(); Rectangle r = gc.getBounds(); Point p = new Point((r.width - frame.getWidth()) / 2, (r.height - frame.getHeight()) / 2); frame.setLocation(p); }