spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

How can i access to a textfield in other jframe with java?


Here is an example(if I understood your question correctly):

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.UIManager;
import
javax.swing.UnsupportedLookAndFeelException;

public class Intro {

    static int count = 0;

    public static void main(String[] args) {

        try {
           
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException |
InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException
e) {
            e.printStackTrace();
        }

        final JFrame frame1 = new JFrame("frame
1");
        final JFrame frame2 = new JFrame("frame
2");
        final JButton button = new
JButton("Button");
        final JTextField textFieald = new
JTextField("0");

        button.setPreferredSize(new Dimension(100,
40));
        button.setFocusable(false);
        button.addActionListener(new
ActionListener() {
            @Override
            public void
actionPerformed(ActionEvent arg0) {
               
textFieald.setText(Integer.toString(++count));
            }
        });

       
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame1.getContentPane().add(button);
        frame1.pack();
        frame1.setLocationRelativeTo(null);
        frame1.setVisible(true);

       
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame2.getContentPane().add(textFieald);
        frame2.pack();
        frame2.setLocationRelativeTo(null);
        frame2.setVisible(true);

    }
}

Categories : Java

Related to : How can i access to a textfield in other jframe with java?
Changing the value of a textfied in JFrame class1, JFrame class2,... by selecting an item from jtable in Jframe class3
As @AndrewThompson wisely mentioned, the use of multiple JFrame is a bad practice. In this case a (non-)modal dialog would be a better choice. Now let's assume you choose non-modal dialogs, then you still having the same problem. There are several ways to solve it but essentially you need to keep a reference to the frame/dialog which opened the calendar's frame. Even better, you can use interface

Categories : Java
ExtJs: Manually fire paste event in textfield when that textfield is focused
It looks like the object firing the event is different than the object listening for the event. fld.on('paste', me.pasteFromClipboard,fld); fld.on('click', function(evt,target){ fld.fireEvent('paste'); // Trigger Paste Event. },fld); Now, both the firing and listening is tied to the fld

Categories : Javascript
Closing jframe from another jframe
Since there is no object of jframeA I don't understand how to close this frame from jframeB on click of a button. If you expect to act on an object, then you need to save a reference to it. Login jframeA = new Login(); // ... jframeA.setVisible(false); jframeA.dispose(); jframeA = null;

Categories : Java
JavaFX TextField CSS
Try this in your CSS file: .text-field { -fx-background-color: #a9a9a9 , white , white; -fx-background-insets: 0 -1 -1 -1, 0 0 0 0, 0 -1 3 -1; } .text-field:focused { -fx-background-color: #a9a9a9 , white , white; -fx-background-insets: 0 -1 -1 -1, 0 0 0 0, 0 -1 3 -1; }

Categories : Java
How can i get textField value from ext.net through jquery
Generally speaking, there is no need to use jQuery to access Ext.NET components on client side. Each component is shared in the Ext.NET namespace which is "App" by default. A component's id is a key in the namespace. To retrieve a TextField's value, please use the getValue method. var value = App.TextField1.getValue();

Categories : Jquery
Recently Add
Redirecting the output directory of 'mvn package' or 'mvn compile' command
No suitable constructor found for ProductoExtranjero
java Composite design pattern(Directory &File)
Java JTree's ui refresh after removing node from parent
First REST Spring application
How to cancel Indexing of a Solr document using Update Request Processor
PowerMock - Mock a Singleton with a Private Constructor
Calling a Postgres stored function SQL error
Where to store Morphlines Java custom command class?
Generic repository using map
How can I scroll a ScrolledComposited in Eclipse SWT Design view?
2 Frames/layout in 1 Activity
Writing a switch differently
Next button opens another activity when its reaches the array limit
Is EclipseLink MOXy capable of applying JSR-303 Bean Validation when unmarshalling XML to object?
Why my jdk can't work,and before the java_home, there is a space that is not from me
How to add List of objects in a Map
How to make notepad++ function like regular notepad in cmd?
Cell renderer and the lost focus
how can I implement iterable for LinkedList>
Disable Androids image-crunch in eclipse (run as) builds
java 8 lambda myMap.stream().count() != myMap.size() after merging myMap
Issue with Calendar calculation that spans 2 calendar years
JSF 2.0 Spring bean injection
Java Regex ReplaceAll with grouping
Getting any word and last word using sed
Clicking on link on JEditorPane throws IOException
printing out difference of two arrays
Spring Bean Alias in JavaConfig
Using Factory Method to Create Generics
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.