List of usage examples for javax.swing JTextField JTextField
public JTextField(int columns)
TextField
with the specified number of columns. From source file:com.bsoft.baseframe.baseframe_utils.beanUtils.Classgenerator.java
/** * ???// w ww . j a v a 2 s .c o m */ public Classgenerator() { setTitle("?"); setSize(WIDTH, HEIGHT); setLocationRelativeTo(null); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 1)); JPanel _beanPanel = new JPanel(); _beanPanel.setBorder(BorderFactory.createTitledBorder("?")); JPanel _otherPanel = new JPanel(); _otherPanel.setBorder(BorderFactory.createTitledBorder("?")); JLabel _tbLabel = new JLabel("??*"); _tb = new JTextField(25); _beanPanel.add(_tbLabel); _beanPanel.add(_tb); JLabel _stbbLabel = new JLabel("??*"); _stb = new JTextField(25); _beanPanel.add(_stbbLabel); _beanPanel.add(_stb); JLabel _ibatisLabel = new JLabel("IBTS*"); _ibatis = new JTextField(25); _beanPanel.add(_ibatisLabel); _beanPanel.add(_ibatis); JLabel _svLabel = new JLabel("SERVICE"); _sv = new JTextField(23); _otherPanel.add(_svLabel); _otherPanel.add(_sv); // JLabel _sviLabel = new JLabel("??*"); // _zwmc = new JTextField("?",25); // _zwmc.setEditable(false); // _otherPanel.add(_sviLabel); // _otherPanel.add(_zwmc); JLabel _detail = new JLabel("(?ServiceService??,"); JLabel _detail2 = new JLabel("??Service???.impl)"); _detail.setFont(new Font("", Font.ITALIC, 12)); _detail2.setFont(new Font("", Font.ITALIC, 12)); _otherPanel.add(_detail); _otherPanel.add(_detail2); panel.add(_beanPanel); panel.add(_otherPanel); add(panel, BorderLayout.CENTER); JPanel btnPanel = new JPanel(); JButton _saveBtn = new JButton("?"); _saveBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int msg_code = clickSaveBtn(e); showMsg(msg_code); } }); JButton _restBtn = new JButton("?"); //? _restBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { _tb.setText(null); _stb.setText(null); _ibatis.setText(null); _sv.setText(null); // _svi.setText(null); } }); btnPanel.add(_saveBtn); btnPanel.add(_restBtn); add(btnPanel, BorderLayout.SOUTH); }
From source file:MailTest.java
public MailTestFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); setTitle("MailTest"); setLayout(new GridBagLayout()); // we use the GBC convenience class of Core Java Volume 1 Chapter 9 add(new JLabel("From:"), new GBC(0, 0).setFill(GBC.HORIZONTAL)); from = new JTextField(20); add(from, new GBC(1, 0).setFill(GBC.HORIZONTAL).setWeight(100, 0)); add(new JLabel("To:"), new GBC(0, 1).setFill(GBC.HORIZONTAL)); to = new JTextField(20); add(to, new GBC(1, 1).setFill(GBC.HORIZONTAL).setWeight(100, 0)); add(new JLabel("SMTP server:"), new GBC(0, 2).setFill(GBC.HORIZONTAL)); smtpServer = new JTextField(20); add(smtpServer, new GBC(1, 2).setFill(GBC.HORIZONTAL).setWeight(100, 0)); message = new JTextArea(); add(new JScrollPane(message), new GBC(0, 3, 2, 1).setFill(GBC.BOTH).setWeight(100, 100)); comm = new JTextArea(); add(new JScrollPane(comm), new GBC(0, 4, 2, 1).setFill(GBC.BOTH).setWeight(100, 100)); JPanel buttonPanel = new JPanel(); add(buttonPanel, new GBC(0, 5, 2, 1)); JButton sendButton = new JButton("Send"); buttonPanel.add(sendButton);//from w w w. j av a 2 s . c o m sendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { new SwingWorker<Void, Void>() { protected Void doInBackground() throws Exception { comm.setText(""); sendMail(); return null; } }.execute(); } }); }
From source file:QueryDB.java
public QueryDBFrame() { setTitle("QueryDB"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); setLayout(new GridBagLayout()); authors = new JComboBox(); authors.setEditable(false);/*from ww w . ja va2s .co m*/ authors.addItem("Any"); publishers = new JComboBox(); publishers.setEditable(false); publishers.addItem("Any"); result = new JTextArea(4, 50); result.setEditable(false); priceChange = new JTextField(8); priceChange.setText("-5.00"); try { conn = getConnection(); Statement stat = conn.createStatement(); String query = "SELECT Name FROM Authors"; ResultSet rs = stat.executeQuery(query); while (rs.next()) authors.addItem(rs.getString(1)); rs.close(); query = "SELECT Name FROM Publishers"; rs = stat.executeQuery(query); while (rs.next()) publishers.addItem(rs.getString(1)); rs.close(); stat.close(); } catch (SQLException e) { for (Throwable t : e) result.append(t.getMessage()); } catch (IOException e) { result.setText("" + e); } // we use the GBC convenience class of Core Java Volume 1 Chapter 9 add(authors, new GBC(0, 0, 2, 1)); add(publishers, new GBC(2, 0, 2, 1)); JButton queryButton = new JButton("Query"); queryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { executeQuery(); } }); add(queryButton, new GBC(0, 1, 1, 1).setInsets(3)); JButton changeButton = new JButton("Change prices"); changeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { changePrices(); } }); add(changeButton, new GBC(2, 1, 1, 1).setInsets(3)); add(priceChange, new GBC(3, 1, 1, 1).setFill(GBC.HORIZONTAL)); add(new JScrollPane(result), new GBC(0, 2, 4, 1).setFill(GBC.BOTH).setWeight(100, 100)); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { try { if (conn != null) conn.close(); } catch (SQLException e) { for (Throwable t : e) t.printStackTrace(); } } }); }
From source file:TextDemo.java
public TextDemo() { super(new GridBagLayout()); textField = new JTextField(20); textField.addActionListener(this); textArea = new JTextArea(5, 20); textArea.setEditable(false);/*from ww w . j a va 2 s. c om*/ JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); //Add Components to this panel. GridBagConstraints c = new GridBagConstraints(); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; add(textField, c); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; add(scrollPane, c); }
From source file:LabelDnD.java
public LabelDnD() { super(new GridLayout(2, 1)); textField = new JTextField(40); textField.setDragEnabled(true);//from w ww . j av a 2 s . c o m JPanel tfpanel = new JPanel(new GridLayout(1, 1)); TitledBorder t1 = BorderFactory.createTitledBorder("JTextField: drag and drop is enabled"); tfpanel.add(textField); tfpanel.setBorder(t1); label = new JLabel("I'm a Label!", SwingConstants.LEADING); label.setTransferHandler(new TransferHandler("text")); MouseListener listener = new DragMouseAdapter(); label.addMouseListener(listener); JPanel lpanel = new JPanel(new GridLayout(1, 1)); TitledBorder t2 = BorderFactory.createTitledBorder("JLabel: drag from or drop to this label"); lpanel.add(label); lpanel.setBorder(t2); add(tfpanel); add(lpanel); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:com.emental.mindraider.ui.dialogs.AddLinkToConceptJDialog.java
/** * Constructor./* ww w.ja v a 2 s . co m*/ */ public AddLinkToConceptJDialog() { super("Add Link To Note"); JPanel framePanel = new JPanel(); framePanel.setLayout(new GridLayout(3, 1)); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(new JLabel(" Predicate: ")); predicateNs = new JTextField(38); predicateNs.setText("http://" + MindRaider.profile.getHostname() + "/e-mentality/conceptLink/custom#"); predicateNs.selectAll(); p.add(predicateNs); p.add(new JLabel("#")); predicateLocalName = new JTextField(15); p.add(predicateLocalName); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new JLabel(" Note: ")); objectNs = new JTextField(38); objectNs.setText(""); objectNs.selectAll(); p.add(objectNs); findConceptButton = new JButton("Find Note"); findConceptButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OpenNoteJDialog.NoteToOpen conceptToOpen = new OpenNoteJDialog.NoteToOpen(); new OpenNoteJDialog("OpenNoteJDialog.titleLink", "OpenNoteJDialog.selectConceptToLink", "OpenNoteJDialog.link", null, conceptToOpen); if (conceptToOpen.conceptLabel != null) { objectNs.setText(conceptToOpen.conceptUri); } } }); p.add(findConceptButton); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton("Add"); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createTriplet(); } }); JButton cancelButton = new JButton("Cancel"); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AddLinkToConceptJDialog.this.dispose(); } }); framePanel.add(p); getContentPane().add(framePanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); }
From source file:gate.termraider.gui.HyponymyDebugger.java
protected void generateTable() { JTextField tempField = new JTextField("generating..."); placeholder.add(tempField);/*from w ww . j a v a 2 s . co m*/ TableModel tableModel = new HDTableModel(termbank); table = new JTable(tableModel); table.setDefaultRenderer(String.class, new MultilineCellRenderer()); table.setAutoCreateRowSorter(true); scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.remove(placeholder); this.add(scrollPane, BorderLayout.CENTER); }
From source file:com.googlecode.vfsjfilechooser2.demo.Main.java
/** * Setup the GUI components/*from w ww .j a v a2 s . c o m*/ */ private void createGUI() { fileChooser = new VFSJFileChooser(); // create a file dialog // configure the file dialog fileChooser.setAccessory(new DefaultAccessoriesPanel(fileChooser)); fileChooser.setFileHidingEnabled(false); fileChooser.setMultiSelectionEnabled(false); fileChooser.setFileSelectionMode(SELECTION_MODE.FILES_ONLY); // create the filename textbox filenameTextField = new JTextField(40); // lookup the localized string for the open button buttonText = VFSResources.getMessage("VFSJFileChooser.directoryOpenButtonText"); // the open button openButton = new JButton(new OpenAction(buttonText)); // add the components to the frame getContentPane().add(openButton, BorderLayout.WEST); getContentPane().add(filenameTextField, BorderLayout.CENTER); // setup the components pack(); }
From source file:be.fedict.eid.tsl.tool.SignSelectPkcs11FinishablePanel.java
@Override public Component getComponent() { LOG.debug("get component"); if (null == this.component) { /*//from w w w. j a v a2 s.c o m * We need to return the same component each time, else the * validate() logic doesn't work as expected. */ JPanel panel = new JPanel(); BoxLayout boxLayout = new BoxLayout(panel, BoxLayout.PAGE_AXIS); panel.setLayout(boxLayout); JPanel infoPanel = new JPanel(); infoPanel.add(new JLabel("Please select a PKCS#11 library.")); panel.add(infoPanel); JPanel browsePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel.add(browsePanel); browsePanel.add(new JLabel("PKCS#11 library:")); this.pkcs11TextField = new JTextField(30); browsePanel.add(this.pkcs11TextField); JButton browseButton = new JButton("Browse..."); browseButton.addActionListener(this); browsePanel.add(browseButton); JPanel slotIdxPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel.add(slotIdxPanel); slotIdxPanel.add(new JLabel("Slot index:")); SpinnerModel spinnerModel = new SpinnerNumberModel(0, 0, 10, 1); this.slotIdxSpinner = new JSpinner(spinnerModel); slotIdxPanel.add(this.slotIdxSpinner); this.component = panel; } return this.component; }
From source file:com.emental.mindraider.ui.dialogs.NewRdfModelJDialog.java
/** * Constructor./*from w w w . j a va 2s . c om*/ */ public NewRdfModelJDialog() { super(Messages.getString("NewRdfModelJDialog.title")); JPanel framePanel = new JPanel(); framePanel.setLayout(new GridLayout(3, 1)); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(new JLabel(Messages.getString("NewRdfModelJDialog.subject"))); subjectNs = new JTextField(30); subjectNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS); p.add(subjectNs); p.add(new JLabel("#")); subjectLocalName = new JTextField(15); p.add(subjectLocalName); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox literalCheckBox = new JCheckBox("literal", false); p.add(literalCheckBox); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton(Messages.getString("NewRdfModelJDialog.create")); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createModel(literalCheckBox); } }); JButton cancelButton = new JButton(Messages.getString("NewRdfModelJDialog.cancel")); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { NewRdfModelJDialog.this.dispose(); } }); framePanel.add(p); subjectLocalName.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { createModel(literalCheckBox); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); getContentPane().add(framePanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { subjectLocalName.requestFocusInWindow(); } }); }