Search in sources :

Example 26 with JTextField

use of javax.swing.JTextField in project nhin-d by DirectProject.

the class ComponentCreation method createBrowseFile.

/**
	 * Process the container pane to create file chooser or directory chooser swing component as per the identifier given as parameter
	 * @param type This decide which component should be created
	 * @param labelData This is the value of a component/or can be used as title of the component
	 * @param c is a object of GridBagConstarins, and used to set any grid layout
	 * @param pane Container object to add component into this pane
	 * @param gridx This is the x index integer value for the component inside the grid
	 * @param gridy This is the y index integer value for the component inside the grid
	 * @return void 
	 */
public void createBrowseFile(String type, String lableData, GridBagConstraints c, Container pane, int gridx, int gridy) {
    JTextField filename = new JTextField();
    filename.setText(lableData);
    ComponentCreation ex = new ComponentCreation();
    JButton open = new JButton("Browse");
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = gridx;
    c.gridy = gridy;
    pane.add(filename, c);
    if (type.equalsIgnoreCase("FILE")) {
        open.addActionListener(ex.new OpenL(filename));
    }
    if (type.equalsIgnoreCase("DIRECTORY")) {
        open.addActionListener(ex.new OpenD(filename));
    }
    c.fill = GridBagConstraints.NONE;
    c.gridx = gridx + 1;
    c.gridy = gridy;
    pane.add(open, c);
    filename.setEditable(false);
}
Also used : JButton(javax.swing.JButton) JTextField(javax.swing.JTextField)

Example 27 with JTextField

use of javax.swing.JTextField in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 28 with JTextField

use of javax.swing.JTextField in project jdk8u_jdk by JetBrains.

the class Test6968363 method run.

@Override
public void run() {
    if (this.frame == null) {
        Thread.setDefaultUncaughtExceptionHandler(this);
        this.frame = new JFrame(getClass().getSimpleName());
        this.frame.add(NORTH, new JLabel("Copy Paste a HINDI text into the field below"));
        this.frame.add(SOUTH, new JTextField(new MyDocument(), "स", 10));
        this.frame.pack();
        this.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.frame.setLocationRelativeTo(null);
        this.frame.setVisible(true);
    } else {
        this.frame.dispose();
        this.frame = null;
    }
}
Also used : JFrame(javax.swing.JFrame) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Example 29 with JTextField

use of javax.swing.JTextField in project jdk8u_jdk by JetBrains.

the class InputContextMemoryLeakTest method init.

public static void init() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            frame = new JFrame();
            frame.setLayout(new FlowLayout());
            JPanel p1 = new JPanel();
            button = new JButton("Test");
            p1.add(button);
            frame.add(p1);
            text = new WeakReference<JTextField>(new JTextField("Text"));
            p = new WeakReference<JPanel>(new JPanel(new FlowLayout()));
            p.get().add(text.get());
            frame.add(p.get());
            frame.setBounds(500, 400, 200, 200);
            frame.setVisible(true);
        }
    });
    Util.focusComponent(text.get(), 500);
    Util.clickOnComp(button, new Robot());
    //References to objects testes for memory leak are stored in Util.
    //Need to clean them
    Util.cleanUp();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            frame.remove(p.get());
        }
    });
    Util.waitForIdle(null);
    //After the next caret blink it automatically TextField references
    Thread.sleep(text.get().getCaret().getBlinkRate() * 2);
    Util.waitForIdle(null);
    assertGC();
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JFrame(javax.swing.JFrame) WeakReference(java.lang.ref.WeakReference) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) Robot(java.awt.Robot)

Example 30 with JTextField

use of javax.swing.JTextField in project jdk8u_jdk by JetBrains.

the class DeadKeyMacOSXInputText method createAndShowGUI.

static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();
    textField.requestFocusInWindow();
    toolkit.realSync();
}
Also used : JTextField(javax.swing.JTextField)

Aggregations

JTextField (javax.swing.JTextField)311 JLabel (javax.swing.JLabel)188 JPanel (javax.swing.JPanel)173 JButton (javax.swing.JButton)107 BorderLayout (java.awt.BorderLayout)85 JCheckBox (javax.swing.JCheckBox)58 Dimension (java.awt.Dimension)57 ActionEvent (java.awt.event.ActionEvent)56 ActionListener (java.awt.event.ActionListener)49 JScrollPane (javax.swing.JScrollPane)47 BoxLayout (javax.swing.BoxLayout)41 Insets (java.awt.Insets)37 GridBagLayout (java.awt.GridBagLayout)36 FlowLayout (java.awt.FlowLayout)35 GridBagConstraints (java.awt.GridBagConstraints)35 JComboBox (javax.swing.JComboBox)29 JTextArea (javax.swing.JTextArea)28 JRadioButton (javax.swing.JRadioButton)23 GridLayout (java.awt.GridLayout)22 JTable (javax.swing.JTable)22