### Inline Java UI TextFieldDialog

B4J UI Application - Inline Java Example Textfield Dialog
Example B4J Project
Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
End Region
`Sub Process_Globals
Private fx As JFX
Private nativeMe As JavaObject
End Sub`
`Sub AppStart (Form1 As Form, Args() As String)
nativeMe = Me
nativeMe.RunMethod("TextFieldDialog", Null)
End Sub`
'TextField Dialog example based on swing
If JAVA
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public static void TextFieldDialog() {
JFrame frame = new JFrame("Inline Java TextFieldDialog");
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
JLabel label = new JLabel("This is a label!");
JTextField jtfText1, jtfUneditableText;
jtfText1 = new JTextField(10);
jtfUneditableText = new JTextField("Uneditable text field", 20);
jtfUneditableText.setEditable(false);
jtfText1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String disp = "text1 : "+e.getActionCommand();
JOptionPane.showMessageDialog(null, disp);
}
});
jtfUneditableText.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String disp = "text3 : "+e.getActionCommand();
JOptionPane.showMessageDialog(null, disp);
}
});
panel.add(label);
panel.add(jtfText1);
panel.add(jtfUneditableText);
frame.add(panel);
frame.setSize(500, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}// End of class TextFieldTest
End If

Changed: , Category: Inline Java, File: T6C201M1484.htm, ID: 1484