How connect a Jbutton to a Jtextfield

Hi guys,
I'm creating a Jform composed by 2 elements: a Jbutton and a Jtextfield.
The Jbutton is connected to a custom method that i have written and exported from my application module. The method in question takes 1 parameter in input, and i would like that it was the text in the JtextField of the same frame.
How can i do this?
where i can find a documentation wich explains how to do this kind of things with jdeveloper 10g?
Thank you all

Don't drag the method as a button to your form, create a regular JButton and onMouseClick:
AppModule a =(AppModule)panelBinding.getApplicationModule();
a.MyCustomMethod(jTextField1.getText());

Similar Messages

  • How to Resize JButton,JTextArea and JTextFields on Mouse Over....

    Hi All...
    Hi friends.. I want to be implement my java swing application Resize the Width and Height wise of JButton,JLabel,JTextFields on mouse over etc.
    ============================
    Arjun Palanichamy.
    Senior Programmer.
    Chennai-India.

    Hi All...
    I am herewith enclosed my sample code for resize the JButton(),But This one resize the when will be extend the Button Caption letters,But i want mouse click resize the without button caption or with caption.
    sample code :
    package Resize;
    import java.awt.Container;
    import java.awt.FlowLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import java.awt.Dimension;
    import java.awt.ComponentOrientation;
    public class ReButton{
    public static boolean RIGHT_TO_LEFT = false;
    public static void addComponents(Container contentPane) {
    if (RIGHT_TO_LEFT) {
    contentPane.setComponentOrientation(
    ComponentOrientation.RIGHT_TO_LEFT);
    contentPane.setLayout(new FlowLayout());
    contentPane.add(new JButton("1"));
    contentPane.add(new JButton("100"));
    contentPane.add(new JButton("100 100"));
    contentPane.add(new JButton("100 100 100"));
    contentPane.add(new JButton("100 100 100 100"));
    contentPane.add(new JButton("5"));
    private static void createAndShowGUI() {
    JFrame frame = new JFrame("FlowLayoutDemo") {
    public Dimension getMinimumSize() {
    Dimension prefSize = getPreferredSize();
    return new Dimension(100, prefSize.height);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Set up the content pane.
    addComponents(frame.getContentPane());
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    for example can you Click this.....
    http://www.eclipse.org/vep/WebContent/docs/testcases/null-layout/null-layout.htm
    Thanks for your time.
    Arjun Palanichamy.
    Chennai-India.

  • How to enable JButton until JTextFields are not empty

    Please, l need help on how to code situation that all JTextFields in JFrame is filled before the save JButton is enable. A kind of validation which make sure that use input values into JTextFields. Thanks

    Thanks Stanislav, l was able to done it. The problem was really in checkEmpty method, l was setting focus on the textfield, immediately commented the line that setfocus and called in it in the insertUpdate() and removeUpdate() methods of DocumentListener it works. Below is the code. But if you have a better way of doing it l will appreciate and l also want to check and ensure that textfield accept string only, how do l do it?
    boolean isTextFieldEmpty() {
    Component[] component = dialogView.getControls();
    for (Component ctrl : component) {
    if (ctrl instanceof JTextField) {
    JTextField jf = (JTextField) ctrl;
    if (jf.getText().equals("")) {
    //jf.requestFocus();
    return true;
    return false;
    class DialogViewDocumentListener implements DocumentListener {
    DialogView dialogView;
    Controller controller;
    public DialogViewDocumentListener(DialogView dialogView, Controller controller) {
    this.dialogView = dialogView;
    this.controller = controller;
    @Override
    public void insertUpdate(DocumentEvent e) {
    if (!controller.isTextFieldEmpty()) {
    dialogView.enableButton();
    @Override
    public void removeUpdate(DocumentEvent e) {
    if (controller.isTextFieldEmpty()) {
    dialogView.disEnableButton();
    }

  • How to setText from tab1's JTextField to tab2's JTextField?

    Hi, How to setText from tab1's JTextField to tab2's JTextField, anyone can help me? When I press a button, it cannot pass the tab1's txt1.getText() to tab2's txt2.setText(). I have a 3 simple class that show below:
    ** Tabmain.java **
    ===================================================
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.*;
    public class Tabmain extends JFrame{
         JTabbedPane tab;
         JPanel panel1, panel2;
         JTextField txt1,txt2;
         JButton jb;
         public Tabmain(){
              super();
              addWindowListener( new WindowAdapter() {
         public void windowClosing(WindowEvent e)
         {System.exit(0);} });
              getContentPane().setLayout(new BorderLayout());
              tab = new JTabbedPane();
              tab.add("Tab1",new Tab1());
              tab.add("Tab2",new Tab2());
              getContentPane().add(tab,BorderLayout.CENTER);
              this.setSize(500,400);          
              this.setVisible(true);
         public static void main(String args[]){
              Tabmain tabmain = new Tabmain();
    ** Tab1.java **
    =======================================================
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class Tab1 extends JPanel{
         private JTextField txt1;
         private JButton jb;
         private JPanel panel1;
         public Tab1(){
              super();
              this.setLayout(new BorderLayout());
              this.add(getPanel1());
         public JPanel getPanel1(){
              panel1 = new JPanel();
              panel1.setLayout(new BorderLayout());          
              txt1 = new JTextField();
              txt1.setBounds(new Rectangle(10, 10, 100, 12));          
              panel1.add(txt1,BorderLayout.NORTH);
              jb = new JButton("OK");
              jb.addActionListener(new Action());
              panel1.add(jb,BorderLayout.SOUTH);
              return panel1;
         class Action implements ActionListener{
              public void actionPerformed(ActionEvent event){
                   String jbtxt = ((JButton)event.getSource()).getText();
                   if(jbtxt=="OK")
                        String str = txt1.getText();     
                        Tab2 tab2 = new Tab2();
                        tab2.txt2.setText(str);                    
    ** Tab2.java **
    ======================================================
    import java.awt.*;
    import javax.swing.*;
    public class Tab2 extends JPanel{
         public JTextField txt2;
         private JPanel panel2;
         public Tab2(){
              super();
              this.setLayout(new BorderLayout());
              this.add(getPanel2());
              public JPanel getPanel2(){
                   panel2 = new JPanel();
                   panel2.setLayout(new BorderLayout());          
                   txt2 = new JTextField();
                   txt2.setBounds(new Rectangle(10, 10, 100, 12));          
                   panel2.add(txt2,BorderLayout.NORTH);               
                   return panel2;
         public void setTXT(String str){
              txt2.setText(str);
    }

    in actionPerformed
    ((JTabbedPane)Tab1.this.getParent()).setSelectedIndex(1);but this will break if you add Tab1 to another panel, then add otherPanel to the tabbedPane
    doing it by passing a reference of the tabbedPane to Tab1 might be better
    //Tab1 t1 = new Tab1();
    Tab1 t1 = new Tab1(tab);
    public Tab1(){
      super();
      this.setLayout(new BorderLayout());
      this.add(getPanel1());
    change to
    public Tab1(final JTabbedPane tp){
      super();
      this.setLayout(new BorderLayout());
      this.add(getPanel1());
      jb.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ae){
          tp.setSelectedIndex(1);
    }

  • How connect a 27 cinema display to HP Pavilion with VGA video output

    how connect a 27 cinema display to HP Pavilion with VGA video output

    If it is a thunderbolt version of the apple 27" display, you don't.  The TB displays can only work with a TB source.
    I also think you are out of luck with the mini-displayport versions of the apple 27" as well.   This would imply converting an analog VGA output  to a digital input of the 27".  I suspect that there is not enough data supplied by VGA for that to work and I do not believe any adapters exist for this.

  • How can i use RTFEditorKit for JTextField.

    hi all,
    how can i use RTFEditorKit for JTextField.
    thanks in advance
    daya

    Don't cross post. This is a Swing related question and you have already posted in the Swing forum:
    http://forum.java.sun.com/thread.jspa?threadID=619619&tstart=0

  • How to preven JButton of generated actions when the user keep pressing down

    How to preven JButton of generated actions when the user keep pressing down the key or the short cut
    The code below to show the issue when the user keep pressing Alt+ O
    We want to prevent the JButton from generating multi actions just one action only
    A sample of code shows the behaviour which has to be prevented. Continue pressing "Alt +O" and you will see the standard ouptput will print time stamps
    Please notice, I am NOT interested in Mouse press which has a solution by adding a threshold ( setMultiClickThreshhold(long threshhold) on the JButton  as an attribute.
    public class TestPanel extends JPanel
       private JButton btn;
       public TestPanel()
          btn = new JButton("Open");
          this.add(btn);
          registerCommand(new MyAction(), InputEvent.ALT_MASK,
                KeyEvent.VK_O, btn, btn.getText(), 0);
       public static void registerCommand(AbstractAction action,
             int mask,
             int shortCommand,
             JComponent component,
             String actionName,
             int mnemonicIndex)
          InputMap inputMap = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
          KeyStroke knappKombination = KeyStroke.getKeyStroke(shortCommand, mask);
          if ((component instanceof AbstractButton)
                && mnemonicIndex >= 0
                && mnemonicIndex < actionName.length()
                && (shortCommand >= KeyEvent.VK_A && shortCommand <= KeyEvent.VK_Z))
             ((AbstractButton) component).setDisplayedMnemonicIndex(mnemonicIndex);
          if (inputMap != null)
             ActionMap actionMap = component.getActionMap();
             inputMap.put(knappKombination, actionName);
             if (actionMap != null)
                actionMap.put(actionName, action);
       public static class MyAction extends AbstractAction
          private static final long serialVersionUID = 1L;
          @Override
          public void actionPerformed(ActionEvent e)
             System.out.println(System.currentTimeMillis());
       public static void main(String... args)
          SwingUtilities.invokeLater(new Runnable()
             public void run()
                JFrame frame = new JFrame("Testing");
                JPanel panel = new TestPanel();
                frame.getContentPane().add(panel);
                frame.setPreferredSize(new Dimension(500, 500));
                frame.setMinimumSize(new Dimension(500, 500));
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
    }Edited by: user12130673 on 2013-feb-13 03:01

    Use KeyStroke getKeyStroke(int keyCode, int modifiers, boolean onKeyRelease) with onKeyRelease=true instead?

  • How to get User input in JTextField?

    How to get User input in JTextField? Can u anyone give me some code samples? thanks

    read the API!!!

  • How connect iPhone to TV (Philips) via USB?

    How connect iPhone to TV (Philips) via USB, because TV does't recognize iPhone.

    http://support.apple.com/kb/ht4108
    http://support.apple.com/kb/HT1454

  • How connect External monitor to iMac?

    How connect External monitor to iMac?

    How to do that depends on the iMac variant you have. iMacs have been in continuous production since 1998 in four broad families that are not 100 percent alike in behavior.
    Please look at the iMac images and descriptions in the links on this site:
    http://www.everymac.com/systems/apple/imac/index-imac.html
    and tell us what variant you believe you have.
    iMacs from the first through third-generations (G3, G4, and G5 processors) that support an external monitor were not set up to do anything other than "mirroring"--you see on the external exactly what is on the built-in display.
    Your description sounds like you have a newer iMac than this forum covers because, starting with the Intel iMacs in 2006, external monitors were allowed to do both mirroring and "extended desktop." The latter is what I believe you are seeing.
    Try this first: press the F7 key. On many Macs capable fo using external monitors, this was a shortcut to toggle between mirrored and extended display. If your keyboard has an "fn" modifier key, you may need to press that to get the F7 key to work.
    If you have an intel-powered iMac I can ask the Hosts to move you to that forum, which is much more active than this one which is for pre-2006 iMacs.

  • How connecting my iPad to sharp printer MX 2700 N ?

    How connecting my iPad to sharp printer MX 2700 N ? With an appli apple ?
    Thanck a lot.
    ZINO44

    Hi,
    Firstly please check to see if your printer in the list:
    http://support.apple.com/kb/ht4356
    If YES, you can use this to fix/setup:
    iPad: http://www.apple.com/support/ipad/assistant/airprint/
    If NO you have to print using other apps (if applicable) such as
       http://itunes.apple.com/au/app/hp-eprint/id299531647?mt=8
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • Placing a JButton inside a JTextfield aligned to right

    hi,
    i would like to add a JButton inside a JTextField. Actually the textfield shows the current path to which image is saved. So to get a file browser, user will click a small button present inside the textfield and selects the file and simultaneously the text of jtextfield is updated.
    i tried of using jTextField1.add(jButton1); but it has no effect. Neither button was displayed nor any error message was displayed.
    So plzz help me out. thanx

    You shouldn't try to put the JButton in the JTextField. A JTextField isn't meant to hold other components.
    Create a JPanel and add the JTextField and the JButton to it.

  • Can anybody tell me  how connect by level  works

    Hi ,
    Can anybody tell me how connect by level works
    select level
    from dual
    connect by level <= 10 ;

    Yes, fully agreed, but still:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:40476301944675#51121960168460
    That might be an old example, but dual's behaviour changes often whenever a new database version gets shipped, like FAST DUALwas 'invented' for Optimizer since 10G.
    Oh well, I know you know all that ;)
    though of course any one row table could be usedTrue and interesting, but would you dare to replace all references to dual on a production system to another one row table?
    Theoretically you're right, but imo (and others) Oracle keeps on doing stuff for dual 'under the hood'.
    It is a totally different 'table'.
    That's my point to OP.
    Maybe I was and am only nitpicking, I now realize, so I'll go get me some coffee ;)

  • How to set jButton to display hourglass while executing.

    Hi All,
    How to set jButton to display hourglass while executing.
    Here is my code:
        private JButton jButton5 = new JButton();
        jButton5.setText("Refresh");
        jButton5.setBounds(new Rectangle(805, 35, 145, 25));
        jButton5.setBackground(Color.green);
        jButton5.setFont(new Font("Tahoma", 1, 15));
        jButton5.setForeground(Color.blue);
        jButton5.setSize(new Dimension(145, 25));
        jButton5.setModel((ButtonModel)panelBinding.bindUIControl("Execute",jButton5));Thanks.

    user38000 wrote:
    I do not have much experience with Java, my background is database admin, could you please spell out syntax and where introduce hourglass behavior based on the code I posted.While bobear may post his code, my recommendation in this situation is that you are always better to use the advice given, the API and the tutorials to first try to do this yourself and see what happens. Then if it fails, come back with your code attempt.
    One concern of mine, and my main reason for posting is that it seems like your JButton will initialize a task that may take a bit of time to perform (hence the need for the hour-glass). I just want to make sure that you call this task in a background thread such as within a SwingWorker's doInBackground() method. For more on this, please google the Sun tutorial on Concurrency in Swing.
    Much luck!

  • How connect to a Braven 650 SPEAKER when  only link is to a 650 headset appears

    How connect a Braven 650 SPEAKER when only link is to a 650 HEADSET?

    Have you tried discoverable? Or try using the headset?  If all else fails refer to the owners manual:)  I would also try calling the manufacturers support, as sometimes these manuals are translated from Chinese, and much can be lost in translation. The site offered little in the way of info. Good luck, just tried to help. All the best

Maybe you are looking for