Textfield help
Cant someone help with code below on how I can put 2 dates in
two textfields with code below. the fields are named Datefrom and
Dateto
thanks
<?php
$country=$_REQUEST['SelectDate'];
switch($country)
case "1" :
Datefrom textfield = Datefrom;
Dateto; textfield = Dateto;
break;
case "2" :
Datefrom textfield = Datefrom;
Dateto; textfield = Dateto;
break;
?>
<form action="" name="form3" id="form3">
<select name="SelectDate" id="SelectDate" onchange="">
<option value="1">Current Year</option>
<option value="2">Current Year-to-date</option>
<option value="3">Yesterday</option>
<option value="4">Last Week</option>
<option value="5">Last Week-to-date</option>
<option value="6">Last Month</option>
<option value="7">Last Month-to-date</option>
<option value="8">Last Year</option>
<option value="9">Last Year-to-date</option>
<option value="10">Today</option>
<option value="11">Current Month</option>
<option value="12">Current Quarter</option>
<option value="13">Current
Quarter-to-date</option>
<option value="14">All Dates</option>
</select>
from
<input name="Datefrom" type="text" id="Datefrom"
value="<?php echo date("Y-01-01"); ?>" size="10" />
to
<input name="Dateto" type="text" id="Dateto"
value="<?php echo date("Y-12-31"); ?>" size="10" />
<input name="Datenow" type="hidden" id="Datenow"
value="<?php echo date("Y-m-d"); ?>" size="10"/>
<input type="submit" name="button2" id="button2"
value="New date" />
</form>
Hello, how do you modify the contents of a TextField
once its been implemented? setText, See the documentation
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/TextField.html
And how do you accept user
input from the Textfield and store it somewhere? Add a save button, and call getText when you want to get the text.
Help
would be appreciated thanks.Btw. Why are you using AWT instead of Swing?
Similar Messages
-
Trying to convert a int back to a textfield - help
Okay this is what I want. I want to type a number in a TextField and double it.... So lets say I type in 10, it will output 20.. But I cant seem to get it to work. The integer won't change it back to a textfield usable text thing .. any help? And yes, i'll admit, its for school, not really for marks, but just to learn.. Theres like 10 of them. And I've been trying to get it to work for awhile, and I ain't asking for coding, or cheating. I'm just asking for help :)
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Myname extends Applet implements ActionListener
Button pressMe = new Button("Enter a number");
TextField answer = new TextField(10);
Font bigfont = new Font("TimesRoman", Font.ITALIC,24);
public void init()
add(pressMe);
add(answer);
answer.requestFocus();
pressMe.addActionListener(this);
public void actionPerformed(ActionEvent thisEvent)
int doubleamount = (new Integer(answer.getText())).intValue();
int doubleamount2 = doubleamount + doubleamount;
answer.setText(doubleamonut2);
invalidate();
validate();
Thats what I haveYou need a String.valueOf (doubleamount2)to convert your int to a String, and you don't need
the revalidate ().
Kind regards,
LeviYeah, Levi is correct. :-) -
Validate the TextField component according to the Key Event
Hi
I want to validate the TextField component in my program , such that when the user enters characters i want to restrict the character to be printed on the TextField.
help me
rgds
nissamHi
here is my code ..the thing is that i dont want to print the pressed character in the TextField...i am unable to catch the key press event with the code u given...
thanks
nisam
import java.awt.*;
import java.awt.event.*;
class TestKey
Frame frm;
TextField test;
Label result;
TestKey()
test = new TextField();
TextArea ee =new TextArea();
result = new Label();
test.addKeyListener(new KeyAdapter()
// e.getKeyChar() gets the key char typed.
//public void processKeyEvent(KeyEvent e){
/*if((e.getID()==KeyEvent.ITEM_EVENT_MASK))
{//&&(e.getKeyChar()=='c')){
System.out.println("Charatcter...."+e.getKeyChar());
public void keyPressed(KeyEvent e)
int code = e.getKeyCode();
if(((code <= 57) && (code >= 48))|| code == 155 || code== 35 || code == 40||
code == 34 || code == 37 || code == 12 || code == 39 ||
code == 36 || code == 38 || code == 33 || code == 106)
e.setKeyCode('\0');
result.setText(""+e.getKeyCode());
else
return;
public void set()
frm=new Frame();
test.setBounds(50,50,100,60);
result.setBounds(50,140,250,50);
frm.setSize(230,340);
frm.setVisible(true);
frm.add(test);
frm.add(result);
public static void main(String args[])
TestKey testk =new TestKey();
testk.set(); -
I created textfield at runtime using createTextField method,
then i tried to clear the textfield, i used
removeTextField() method
but it is not removing the textfield, even i used
textfield.visible=false
then also not it is showing the textfield, help me to remove
textfieldcreate an array to store your textfields and store their references in that array. then loop through that array (from end to beginning) and remove them when you want:
// these lines should execute once only at the start of your fla to initialize tfA and removeTF()
var tfA:Array = [];
function removeTF(){
for(var i:Number=tfA.length-1;i>=0;i--){
tfA[i].removeTextField();
// then when you create tf's, store them:
this.createTextField("scroll_txt", this.getNextHighestDepth(), 0, 0, 0, 0);
this.createTextField("newszlatest", this.getNextHighestDepth(), 143, 170, 648, 233);
tfA.push(scroll_txt);
tfA.push(newszlatest);
// then when you want to remove them all, call removeTF(): -
Hello
I want to create a textfield that only allows user to key in numerics and with fixed character length (means only a fixed length of characters can be entered).
I have viewed this post:
http://forum.java.sun.com/thread.jspa?threadID=536977&messageID=2597211
and one of the reply said that the numeric part can be done with key listener, but I just don`t know how to do this, even after viewing the API.
Hope that anyone could help me on this.
Regards.Well the last question you posted dealt with JFrames and JPanels which are Swing components.
This question deals with a "textfield" which is an AWT component. Most people don't work with both AWT and Swing so I don't know if you just made a typing mistake and meant to say JTextField. Because if you did mean to say JTextField, then the question should have been posted in the Swing forum, so we know for sure that this is a Swing related question. -
TextFields / labels in Applet...Urgent help needed please!!
I have been trying for days to add labels and textFields to my applet and can only manage to display one.
My assignment instructions suggest I use makeTextField method and call the setEditable method from the makeTextField method to avoid repetition of code.
The following is my code...I must have this done in the next couple of days so if someone could please please give me some assistance it would be really appreciated....also, thoughts on my layout would be great as well...i cant seem to set up my buttons in the correct order.
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class Registry4b extends Applet implements ActionListener {
public void init() {
backgroundColor = new Color(200,255,255);
this.setLayout(new FlowLayout(FlowLayout.CENTER,4,1));
makeButtons();
row1 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),backgroundColor);
row1.add(clearB);
row1.add(studFindB);
row1.add(studForB);
row1.add(courB);
row2 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),backgroundColor);
row2.add(studBackB);
row2.add(courFindB);
row2.add(courForB);
row2.add(studB);
row3 = makePanel(new FlowLayout(FlowLayout.LEFT,4,2),backgroundColor);
row3.add(courBackB);
add(row1);
add(row2);
add(row3);
Panel p = new Panel(new BorderLayout());
Label studID = new Label("STUDENT ID");
TextField entry = new TextField(" ");
p.add(studID,BorderLayout.WEST);
p.add(entry,BorderLayout.CENTER);
Label firstTF = new Label("FIRST NAME");
makePanel(new BorderLayout(2,2),backgroundColor);
add("West",courBackB);
add("East",studB);
makePanel(new BorderLayout(2,2),backgroundColor);
add("North",p);
add("South",courForB);
makePanel(new BorderLayout(2,2),backgroundColor);
add("North",courFindB);
add("South",studBackB);
makePanel(new BorderLayout(2,2),backgroundColor);
add("West",p);
add("East",studForB);
setBackground(backgroundColor);
clearB.addActionListener(this);
courBackB.addActionListener(this);
studB.addActionListener(this);
courForB.addActionListener(this);
courFindB.addActionListener(this);
studBackB.addActionListener(this);
courB.addActionListener(this);
studForB.addActionListener(this);
studFindB.addActionListener(this);
private Label makeLabel(String label) {
Label label1 = new Label(label,Label.RIGHT);
label1.setFont(new Font("Courier",Font.BOLD,10));
return label1;
public void start() {
appletWidth = 8*4+row1.getSize().width;
appletHeight = 8*(2+courBackB.getSize().height);
public void paint(Graphics g) {
setSize(appletWidth,appletHeight);
validate();
public void actionPerformed(ActionEvent e) {
String s = (String)e.getActionCommand();
private Button makeButton(String label, Color color, Font font) {
Button b = new Button(label);
b.setBackground(color);
b.setFont(font);
return b;
private Panel makePanel(LayoutManager lm, Color c) {
Panel p = new Panel();
p.setLayout(lm);
p.setBackground(c);
return p;
private void makeButtons() {
Font f = new Font("Courier", Font.BOLD, 10);
Color grey = new Color(255,100,100);
clearB = makeButton("CLEAR",grey,f);
studB = makeButton(" STUDENTS ",grey,f);
studForB = makeButton("->",grey,f);
studFindB = makeButton("FIND",grey,f);
courFindB = makeButton("FIND",grey,f);
studBackB = makeButton("<-",grey,f);
courB = makeButton(" COURSES ",grey,f);
courBackB = makeButton("<-",grey,f);
courForB = makeButton("->",grey,f);
TextField addressTF = new TextField("ADDRESS", 10);
static final String initialString = " ";
String Filler = " ";
Panel row1, row2, row3, p1;
int appletWidth, appletHeight;
Button clearB, studForB, studFindB, courFindB,
studBackB,courB, courBackB, studB, courForB;
Color backgroundColor;
the buttons currently dont do anything. this is stage 1 of 3 for my 3 part assignment. for now i am just supposed to get the format right and show sample text in the textfields.
the format is supposed to look something like the following (cant copy existing as it is protected)
<- STUDENTS -> CLEAR <- COURSES ->
student id FIND course id FIND
last name_________first name______course name_____
address________________________________________
city______province___________p.code______________
phone__________e-mail_______coordinator___________
#of courses completed_____ #of students passed______
student's average grade___ students grade ave grade___
messages______________________________________
the ones in caps are buttons and the rest are labels with text fields beside most of the labels.
i apologize for the extremely long question but i hope this is what you were looking for to give me some help...anything would be greatly appreciated!!
thanks in advance for anything someone can do for mehi,
may this helps to solve your problem
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class Registry4b extends Applet implements ActionListener {
TextField sid;
TextField cid;
public void init() {
backgroundColor = new Color(200,255,255);
setLayout(new GridLayout(2,1)); // 2 rows, one column, first row for search, the second for output
Panel up=new Panel(new GridLayout(3,1)); // search panel
Panel down=new Panel(new GridLayout(1,1)); //output panel
down.add(new Label("Just for the output"));
Panel p1=makePanel(new GridLayout(1,7),backgroundColor);
makeButtons();
p1.add(studBackB);
p1.add(studB);
p1.add(studForB);
p1.add(clearB);
p1.add(courBackB);
p1.add(courB);
p1.add(courForB);
up.add(p1);
Panel p2=makePanel(new GridLayout(1,3),backgroundColor);
p2.add(makeLabel("Student ID"));
sid=new TextField("");
p2.add(sid);
p2.add(studFindB);
up.add(p2);
Panel p3=makePanel(new GridLayout(1,3),backgroundColor);
cid=new TextField("");
p3.add(makeLabel("Course ID"));
p3.add(cid);
p3.add(courFindB);
up.add(p3);
add(up);
add(down);
private Label makeLabel(String label) {
Label label1 = new Label(label,Label.RIGHT);
label1.setFont(new Font("Courier",Font.BOLD,10));
return label1;
public void start() {
//appletWidth = 8*4+120;//row1.getSize().width;
//appletHeight = 8*(2+courBackB.getSize().height);
appletWidth=200;
appletHeight=90;
public void paint(Graphics g) {
setSize(appletWidth,appletHeight);
validate();
public void actionPerformed(ActionEvent e) {
String s = (String)e.getActionCommand();
private Button makeButton(String label, Color color, Font font) {
Button b = new Button(label);
b.setBackground(color);
b.setFont(font);
return b;
private Panel makePanel(LayoutManager lm, Color c) {
Panel p = new Panel();
p.setLayout(lm);
p.setBackground(c);
return p;
private void makeButtons() {
Font f = new Font("Courier", Font.BOLD, 10);
Color grey = new Color(255,100,100);
clearB = makeButton("CLEAR",grey,f);
studB = makeButton(" STUDENTS ",grey,f);
studForB = makeButton("->",grey,f);
studFindB = makeButton("FIND",grey,f);
courFindB = makeButton("FIND",grey,f);
studBackB = makeButton("<-",grey,f);
courB = makeButton(" COURSES ",grey,f);
courBackB = makeButton("<-",grey,f);
courForB = makeButton("->",grey,f);
TextField addressTF = new TextField("ADDRESS", 10);
static final String initialString = " ";
String Filler = " ";
Panel row1, row2, row3, p1;
int appletWidth, appletHeight;
Button clearB, studForB, studFindB, courFindB, studBackB,courB, courBackB, studB, courForB;
Color backgroundColor;
}interesting for you is only the init()
regards -
Help needed to extract a value from Textfield
Hi,
I am new to AWT prgramming .
I have created a menu called " Menu System Test window " and it contains toplevel menu item "File" and File Menu contains subitems "Product Evaluation" and "Exit".
When i click File->Product Evaluation it displays a new Frame named "ProductEvaluationMeasurementTool" with some check boxes ,radiobuttons, buttons , text fields.
After compiling the program if i check some check boxes and radiobuttons and press Button1 it displays the result as no of checkboxes checked divided by total no of checkboxes(which i have declared as 18 in my code) in textField1.
I also have textField2 for entering user input.
now my question is after compiling program i check some checkboxes , enter some value in textField2 and press Button2. The result should be diplayed as no of checkboxes checked plus the value added in textField2 divided by total no of checkboxes(which is 18 in my code) . This result should be displayed in textField3.
Can anyone help me?
Thanks in advance
i am sending my code.
import java.awt.*;
import java.awt.event.*;
import java.awt.Component;
import java.awt.Checkbox;
import javax.swing.*;
// Make a main window with a top-level menu: File
public class MainWindow extends Frame {
public MainWindow() {
super("Menu System Test Window");
setSize(500, 500);
// make a top level File menu
FileMenu fileMenu = new FileMenu(this);
// make a menu bar for this frame
// and add top level menus File and Menu
MenuBar mb = new MenuBar();
mb.add(fileMenu);
setMenuBar(mb);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
exit();
public void exit() {
setVisible(false); // hide the Frame
dispose(); // tell windowing system to free resources
System.exit(0); // exit
public static void main(String args[]) {
MainWindow w = new MainWindow();
w.setVisible(true);
// Encapsulate the look and behavior of the File menu
class FileMenu extends Menu implements ActionListener {
private MainWindow mw; // who owns us?
private MenuItem itmPE = new MenuItem("ProductEvaluation");
private MenuItem itmExit = new MenuItem("Exit");
public FileMenu(MainWindow main)
super("File");
this.mw = main;
this.itmPE.addActionListener(this);
this.itmExit.addActionListener(this);
this.add(this.itmPE);
this.add(this.itmExit);
// respond to the Exit menu choice
public void actionPerformed(ActionEvent e)
if (e.getSource() == this.itmPE)
Frame f = new Frame("ProductMeasurementEvaluationTool");
f.setSize(1290,1290);
f.setLayout(null);
TextField t1 = new TextField("textField1");
t1.setBounds(230, 630, 50, 24);
f.add(t1);
TextField t2 = new TextField("textField2");
t2.setBounds(430, 630, 50, 24);
f.add(t2);
TextField t3 = new TextField("textField3");
t3.setBounds(630, 630, 50, 24);
f.add(t3);
Label l1 = new Label("Select the appropriate metrics for Measurement Process Evaluation");
l1.setBounds(380, 50, 380, 20);
f.add(l1);
Label l2 = new Label("Architecture Metrics");
l2.setBounds(170, 100, 110, 20);
f.add(l2);
Label l3 = new Label("RunTime Metrics");
l3.setBounds(500, 100, 110, 20);
f.add(l3);
Label l4 = new Label("Documentation Metrics");
l4.setBounds(840, 100, 130, 20);
f.add(l4);
JRadioButton rb1 = new JRadioButton("Componenent Metrics",false);
rb1.setBounds(190, 140, 133, 20);
f.add(rb1);
JRadioButton rb2 = new JRadioButton("Task Metrics",false);
rb2.setBounds(540, 140, 95, 20);
f.add(rb2);
JRadioButton rb3 = new JRadioButton("Manual Metrics",false);
rb3.setBounds(870, 140, 108, 20);
f.add(rb3);
JRadioButton rb4 = new JRadioButton("Configuration Metrics",false);
rb4.setBounds(190, 270, 142, 20);
f.add(rb4);
JRadioButton rb6 = new JRadioButton("DataHandling Metrics",false);
rb6.setBounds(540, 270, 142, 20);
f.add(rb6);
JRadioButton rb8 = new JRadioButton("Development Metrics",false);
rb8.setBounds(870, 270, 141, 20);
f.add(rb8);
Checkbox c10 = new Checkbox("Size");
c10.setBounds(220, 170, 49, 20);
f.add(c10);
Checkbox c11 = new Checkbox("Structure");
c11.setBounds(220, 190, 75, 20);
f.add(c11);
Checkbox c12 = new Checkbox("Complexity");
c12.setBounds(220, 210, 86, 20);
f.add(c12);
Checkbox c13 = new Checkbox("Size");
c13.setBounds(220, 300, 49, 20);
f.add(c13);
Checkbox c14 = new Checkbox("Structure");
c14.setBounds(220, 320, 75, 20);
f.add(c14);
Checkbox c15 = new Checkbox("Complexity");
c15.setBounds(220, 340, 86, 20);
f.add(c15);
Checkbox c19 = new Checkbox("Size");
c19.setBounds(580, 170, 49, 20);
f.add(c19);
Checkbox c20 = new Checkbox("Structure");
c20.setBounds(580, 190, 75, 20);
f.add(c20);
Checkbox c21 = new Checkbox("Complexity");
c21.setBounds(580, 210, 86, 20);
f.add(c21);
Checkbox c22 = new Checkbox("Size");
c22.setBounds(580, 300, 49, 20);
f.add(c22);
Checkbox c23 = new Checkbox("Structure");
c23.setBounds(580, 320, 75, 20);
f.add(c23);
Checkbox c24 = new Checkbox("Complexity");
c24.setBounds(580, 340, 86, 20);
f.add(c24);
Checkbox c28 = new Checkbox("Size");
c28.setBounds(920, 170, 49, 20);
f.add(c28);
Checkbox c29 = new Checkbox("Structure");
c29.setBounds(920, 190, 75, 20);
f.add(c29);
Checkbox c30 = new Checkbox("Complexity");
c30.setBounds(920, 210, 86, 20);
f.add(c30);
Checkbox c31 = new Checkbox("Size");
c31.setBounds(920, 300, 49, 20);
f.add(c31);
Checkbox c32 = new Checkbox("Structure");
c32.setBounds(920, 320, 75, 20);
f.add(c32);
Checkbox c33 = new Checkbox("Complexity");
c33.setBounds(920, 340, 86, 20);
f.add(c33);
ActionListener action = new MyActionListener(f, t1, t2,t3);
Button b1 = new Button("Button1");
b1.setBounds(230, 600, 120, 24);
b1.addActionListener(action);
f.add(b1);
Button b2 = new Button("Button2");
b2.setBounds(430, 600, 120, 24);
b2.addActionListener(action);
f.add(b2);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
System.exit(0);
f.show();
else
{ mw.exit();}
class MyActionListener implements ActionListener
private Frame frame;
private TextField textField1;
private TextField textField2;
private TextField textField3;
public MyActionListener(Frame frame, TextField tf1, TextField tf2,TextField tf3)
this.frame = frame;
this.textField1 = tf1;
this.textField2 = tf2;
this.textField3 = tf3;
public void actionPerformed(ActionEvent e)
String s = e.getActionCommand();
if (s.equals("Button1"))
Component[] components = this.frame.getComponents();
int numOfCheckBoxes = 18;
int numChecked = 0;
for (int i = 0; i < components.length; i++)
if (components[i] instanceof Checkbox)
if (((Checkbox)components).getState())
numChecked++;
double ratio = (double) numChecked / (double) numOfCheckBoxes;
this.textField1.setText(Double.toString(ratio));
else
if (s.equals("Button2"))
Component[] components = this.frame.getComponents();
int numOfCheckBoxes = 18;
int numChecked = 0;
for (int i = 0; i < components.length; i++)
if (components[i] instanceof Checkbox)
if (((Checkbox)components[i]).getState())
numChecked++;
double ratio = (double) numChecked / (double) numOfCheckBoxes;
// I think some methods should be writen here to get the user input from textField2 before displaying ratio in textField3
this.textField3.setText(Double.toString(ratio));// The result should be diplayed as
// no of checkboxes checked -> numChecked
// plus the value added in textField2 -> input
double input = Double.parseDouble(textField3.getText());
// divided by total no of checkboxes -> numOfCheckBoxes
double ratio = (numChecked + input) / (double) numOfCheckBoxes;
// This result should be displayed in textField3
this.textField2.setText(Double.toString(ratio)); -
Hi guys,
I'm getting a java.lang.NullPointerException (with no other details of error) when i try to write to a textfield on my GUI. the line: TF1.setText("F"); is where the problem is occurring. that line is within a loop ->
if(freq >87 && freq < 100)
System.out.println("Note =F" +freq);
TF1.setText("F");
the textfield has been constructed and initialised and given an initial value. what i need to happen is the string in the textfield to be constantly updated (overwritten) with the new string.
the initial value from TextField TF1= new TextField("", 10);
TF1.setText("blank");
works fine, but one the loop above is entered, the current frequency is printed to the command line and then "java.lang.NullPointerException" is thrown.
I'm struggling with this, and have a deadline to meet so I would much appreciate some help.The Gui class is this:
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.TextField;
import javax.swing.JFrame;
import javax.swing.*;
public class Gui extends JFrame{
public static void main(String args[])
Project project = new Project();
project.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
project.setSize( 250, 200 ); // set frame size
project.setVisible( true ); // display frame
// new Project(){//constructor
Panel p, p1;
p = new Panel();
p.setLayout (new FlowLayout(FlowLayout.LEFT,5,5));
project.add(p, BorderLayout.NORTH);
p1 = new Panel();
p1.setLayout (new FlowLayout(FlowLayout.LEFT,5,5));
p1.setLayout (new GridLayout(4,1));
project.setTitle("Guitar Tuner Prototype");
TextField TF1= new TextField("", 10);
TF1.setText("blank");
p1.add(TF1);
TF1.setVisible(true);
p1.setVisible(true);
p.add(p1);
//Capture input data from the microphone
project.captureAudio();
project.captureThread();
}//end constructor
//end main
The project.java class has the "private TextField TF1; at the top. the project.java class also contains the loop thats writing to the texfield as specified in th original post.. -
Hi,I have developed a Layout(with the help of a colleague..Jim Andreau)
which has a GridLayout and some TextFields.
I need to reduce the size of the TextField.It takes the whole stretch
of the layout.
Transaction Number:[ ]
even though the length is 5.
Can anyone please tell me how to reduce the size to so that it looks:
Transaction Number:[ ]
Here is my code:
Box b2 = Box.createVerticalBox();
Container c = getContentPane():
public void methodName(){
JTextFieldtransaction_Tf = new JTextField(5);
transaction_Tf.setMaximumSize(new Dimension(Short.MAX_VALUE, 20));
Box transactionBox = Box.createHorizontalBox();
transactionBox.add(new JLabel(Transaction Number"));
transactionBox.add(transaction_Tf.s);
b2.add(transactionBox);
// Add b2 to the Container.
c.add(b2) ;
show();
How to reduce the size of the TextField....??Box transactionBox = Box.createHorizontalBox();
transactionBox.add(new JLabel(Transaction
ion Number"));
transactionBox.add(transaction_Tf.s);
b2.add(transactionBox);
b2.add(Box.createHorizontalGlue());...
The horizontal glue will expand to fill whatever extra space is left over after the text field. -
Conditional Validation on Textfield(s) based on Select/List - help needed.
Hey Gang,
I have a simple page where a select/list menu with values "1" through "5" determines how many following textfields require validation. There is an "onchange" event which calls a function to update the validation. Below is my code:
[ body tag *spry js/css scripts are called in head]
<form id="form1" name="form1" method="post" action="">
<p>
<select name="menu" id="menu" onchange="menuFunction()">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</p>
<p>
<span id="sprytextfield1"><input type="text" name="text1" id="text1" /></span><br />
<span id="sprytextfield2"><input type="text" name="text2" id="text2" /></span><br />
<span id="sprytextfield3"><input type="text" name="text3" id="text3" /></span><br />
<span id="sprytextfield4"><input type="text" name="text4" id="text4" /></span><br />
<span id="sprytextfield5"><input type="text" name="text5" id="text5" /></span>
</p>
<p><input type="submit" name="submit" id="submit" value="Submit" /></p>
</form>
<script type="text/javascript">
<!--
function menuFunction() {
var menuNum = document.getElementById('menu').value;
for(i=1; i<=5; i++) {
if(i<=menuNum) {
eval("var sprytextfield" +i+ "= new Spry.Widget.ValidationTextField(\"sprytextfield" +i+ "\")" );
} else {
eval("var sprytextfield" +i+ "= new Spry.Widget.ValidationTextField(\"sprytextfield" +i+ "\", \"none\", {isRequired:false})" );
//-->
</script>
[ / body tag etc... ]
The function seems to work when it requires the validation for the textfields, but not when removing the validation. I've tried doing eval("sprytextfield" +i+ ".destroy()"); as well without success.
I've searched through forums and could not find an answer to this (sorry if I missed it) ... so hopefully somebody can point me in the right direction. (*I found the post w/ the link http://www.spry-it.com/examples/spry-widget-validation-generation-and-destroy/ -- however that page doesn't seem to work *Chrome)
Thanks for any help! =)
~MikeHave a look here http://forums.adobe.com/message/2651124#2651124
If that doesn't help please come back here.
Ben -
A little help in AWT.. (reading a textfield from another class)
I got this Panel with a varying number of TextFields (to input a matrix).
so i did (in the Panel sub-class)
TextField Determinant[] = new TextField[l*l];
for (int i = 0; i < l*l; i++)
add(Determinant[i] = new TextField(""+i));
then i want to read them into a 2 dimensional array after pressing a button (in the Button subclass)
for (int i = 0; i < det.length; i++)
for (int j = 0; j < det.length; j++)
det[i][j] = (double)Panel1.Determinant[k].getText();
k += 1;
but then the compiler complains:
C:\java projects\GoButton.java:30: cannot resolve symbol
symbol : variable Panel1
location: class GoButton
det[i][j] = (double)Panel1.Determinant[k].getText();
how do i get the Button-subclass to "know" the Textfields in the Panel subclass?
(they're both public)
help please! :)Is "Panel1" a class name or a variable or field name?
If the latter, you ought to use Java naming conventions: only class names and constants start with upper-case letters. So "Determinant" in your code is also poorly named.
Also I'd strong advise against using "l" (a single lower-case ell) as an identifier. It's really hard to read.
Also when you post code, please wrap it in [code][/code] tags, so we can read it.
Assuming that "Panel1" is a field or variable -- then you need to either make it accessible by the other classes that need to access it, or better yet pass its value as an argument to those things that need it.
Or maybe restructure your code so that the things that need to use it are in the same class as Panel1, possibly as member classes. -
Access Present Textfield value in Help Text
Hi
I have a Text item and I wanted to access the Value of that text item in the text field property "Help Text". How I refer present focused textfield value in their "Help Text" property.
Regards
Kiran AkkirajuKiran,
The current value in session state of the item is available using &ITEM. notation (note trailing period). For example in the help text for item P1_X you can type:
Current value of this item is &P1_X..
Scott -
Need help in arranging choice group and textfield on screen
Hi friends
i want to display choice element (along with its text) and textfield(small one) in a single row.i want many such rows.
i tried my best to do that.but couldent get as what i wished ,textfields comes down.
Actually i want value inside textfield and name of the choice element when i click on any choice element,I did that functionality but only alignment is problem.
if anyone has tried or any idea about how to get this alignment please let me know.you can achieve this fairly easily with group policy.
create an OU and put your remote desktop servers in that OU.
configure both user and computer policies in a group policy and link it to that ou.
you need to enable loopback mode - you may want it in merge or replace depending on your other policies you have. Probably replace though I would guess. this is set in the computer configuration > admin templates > system / group policy section.
now remove the policy you have currently setup for your users on the users OU containing the rdp users. If you want you can move these users back to your main users OU.
when your users login to the RDP server the settings in the user section of the GPO linked to the RDP Servers OU will apply.
when the user logs in to their own computer the policies from the user OU and computer OU will apply - but not the more restrictive RDP OU.
hope that makes sense.
Regards,
Denis Cooper
MCITP EA - MCT
Help keep the forums tidy, if this has helped please mark it as an answer
My Blog
LinkedIn: -
hello to all
i am using textField for user input and i want to remove this text field from that form and after i want to add some another inputs like choice group on that form so i want to remove textField and add a choice group.
we can a remove choicegroup field from form like(form.delete(choicegroupName))
but as same type we can not remove a textField item.
i use coding for delete a textField form.delete(typeOfCar);
it is giving error
delete(int) in javax.microedition.lcdui.Form cannot be applied to (javax.microedition.lcdui.TextField form.delete(typeOfCar);
sir plz help mejust when adding the TextField to the form call it like
int textFieldPos = form.add(textField);
this saves the index of this Textfield in the textFieldPos variable. This can be used to remove this component, by calling
form.delete(textFieldPos).
hth
Kay -
HELP! My TextField is freaking out...
Hello!
I'm creating a command-based client where i have a textfield for handling input. Now, i'm having a problem with handling TextField events (or something in that way)... I want to be able to type in commands, but i should also be able to use the numpad keys for calling some other methods that i bind to them.... now, everything works well, the methods are called when i press the numpad keys (i use a keyListener). The problem however is that after the numpad keys have been pressed and the appropriate methods have been called the keyPressed event(or whatever it is) seems to be passed on to the textfield, so the number is printed in the textfield... i dont want the number to be printed, only the method to be called... anyone got an idea? Stop the event from being forwarded or something??? (it is really nessecary for the the textfield to be in focus, since i should be able to type commands or press the numpad shortcuts at any time)... help!keyListener). The problem however is that after the
numpad keys have been pressed and the appropriate
methods have been called the keyPressed event(or
whatever it is) seems to be passed on to the
textfield, so the number is printed in the
textfield... i dont want the number to be printed,Use setEditable(false); on the textfield to keep input from going to it.
(it is really nessecary for the the textfield to be in
focus, since i should be able to type commands or
press the numpad shortcuts at any time)... help!The component that has the focus will detect keyevents and forward them to keylisteners. If you are responding to keyevents, you MIGHT not need the textfield, just a keylistener on the components in your applet/application.
Maybe you are looking for
-
Images Split After Saving in Camera Raw
I am editing in camera raw from Bridge, I edit, then save. At first the thumbnail remains the same then shortly it becomes 2 half images. Very frustrating!!! I just started this new workflow giving bridge a try and I was very excited about it .. unti
-
Two Different Imported TIFFs Show The Same Image in Premiere Pro
I noticed sometime ago that some imported TIFFs with alpha channel are not showing the correct image. Recently I upgraded to Premiere Pro CC (for PC) to see if such issue was solved, however it is not. Basically just importing the TIFFs into the proj
-
Dear all, when i just configured the isdn from the branch side and the dialer from the PRI line, it is automaticlly come up even the primary link is still up. i check the intersting traffic which i exclude the eigrp routing protocol form it. when i c
-
Oracle Login with sysdba not working
Hi All, I have oracle datatbase version 9.2.0.4 on solaris 9. I have assigned sysdba to a user with grant command. when i am trying to login with as sysdba option from a remote system running windows 2000 server, its giving error as follows. ORA-0103
-
Changing group from calendar year to GL year
I am currently using Crystal reports with a ERP system called IQMS. I am trying to grab data from our genral ledger year (1 of august to 31 of july) instead of the calendar year. The data can come from either the year or the week (52 weeks). I am cur