java code
View Answers
September 22, 2008 at 11:11 AM
Hi Aswini
refer this code and modify it as per ur requirement
public class FieldEnable extends JFrame{
public String[] filedvalue = {"MyName","","","Age","city",""};
private JTextField textfield[];
private JPanel panel = new JPanel();
public FieldEnable(){
int len = filedvalue.length;
textfield = new JTextField[len];
for(int i=0; i<len; i++){
if(filedvalue[i].equals("")){
textfield[i] = new JTextField(filedvalue[i],15);
textfield[i].setEditable(true);
panel.add(textfield[i]);
}else{
textfield[i] = new JTextField(filedvalue[i],15);
textfield[i].setEditable(false);
panel.add(textfield[i]);
}
}//for
Container container = getContentPane();
container.add(panel,"Center");
setSize(new Dimension(300,300));
setVisible(true);
}
public static void main(String s[]){
new FieldEnable();
}
}
Thanks
Rajaniakant
September 22, 2008 at 11:11 AM
Hi Aswini
refer this code and modify it as per ur requirement
public class FieldEnable extends JFrame{
public String[] filedvalue = {"MyName","","","Age","city",""};
private JTextField textfield[];
private JPanel panel = new JPanel();
public FieldEnable(){
int len = filedvalue.length;
textfield = new JTextField[len];
for(int i=0; i<len; i++){
if(filedvalue[i].equals("")){
textfield[i] = new JTextField(filedvalue[i],15);
textfield[i].setEditable(true);
panel.add(textfield[i]);
}else{
textfield[i] = new JTextField(filedvalue[i],15);
textfield[i].setEditable(false);
panel.add(textfield[i]);
}
}//for
Container container = getContentPane();
container.add(panel,"Center");
setSize(new Dimension(300,300));
setVisible(true);
}
public static void main(String s[]){
new FieldEnable();
}
}
Thanks
Rajanikant
September 22, 2008 at 11:51 AM
September 22, 2008 at 12:36 PM
Hi,
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class TextFieldTest extends JFrame {
public static void main(String[] args) {
new TextFieldTest();
}
public TextFieldTest() {
super("JTextField Update Test");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
final JTextField field = new JTextField("Test: ",15);
getContentPane().add(field);
final JToggleButton button = new JToggleButton("Disable Field");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
field.setEnabled(!field.isEnabled());
if (field.isEnabled()) {
button.setText("Disable Field");
}
else {
button.setText("Enable Field");
}
}
});
button.setMaximumSize(new Dimension(100, 25));
button.setPreferredSize(new Dimension(100, 25));
getContentPane().add(Box.createRigidArea(new Dimension(0, 0)));
getContentPane().add(button);
getContentPane().add(Box.createRigidArea(new Dimension(0, 0)));
setSize(400, 200);
setVisible(true);
}
}
------------------------
Thanks.
Related Tutorials/Questions & Answers:
JAVA code For JAVA code For
JAVA code For "Traffic signals Identification for vehicles
java codejava code what is the
code to turn off my pc through
java program
Advertisements
JAVA CODEJAVA CODE
JAVA SOURCE
CODE TO BLOCK A PARTICULAR WEB SITES(SOCIAL WEB SITE
java codejava code write a
java code to convert hindi to english using arrays
java codejava code hi any one please tell me the
java code to access any link
i mean which method of which class is used to open any link in
java program
java codejava code need
java code for chart or graph which compare the performance of aprior algorithm and coherent rule algorithm.plz any one help me out
java codejava code write a
java code for finding a string in partiular position in a delimited text file and replace the word with the values given by user and write the file in new location
java codejava code sir how to merge the cells in excel using
java code please help me and also how to make the text placed in the cell to be center
java codejava code sir how to merge the cells in excel using
java code please help me and also how to make the text placed in the cell to be center
java codejava code I need the
java code that would output the following:
HARDWARE ITEMS
CODE DESCRIPTION UNIT PRICE
K16 Wood screws,brass,20mm $7.75
D24 Wood glue,clear,1 liter $5.50
M93
Java code Java code Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes
java codejava code develop a banking system in
java java codejava code HOW TO PRINT 1 TO 100 WITHOUT USING CONDITIONAL,ANY LOOP AND ARRAY IN
JAVA AND C.URGENT SIR PLZ Hi,
You can use following
code:
class MyClass
{
public static void main(String[] args)
{
int
java codejava code how to extract html tags using
java Java codeJava code Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any... the following
code:
import java.util.*;
import java.text.*;
class NumberProgram
java codejava code int g()
{
System.out.println("Inside method g");
int h()
{
System.out.println("Inside method h");
}
}
Find the error in the following... cannot define a method inside another method. Anyways, we have modified your
code java codejava code what is meaning bufferedreader
java codejava code what is meaning bufferedreader
java codejava code i want HSVcolor descriptor for color image in
java coding
Java codeJava code Create a calculator class which will have methods add, multiply, divide & subtract
Hi Friend,
Try the following
code:
class Calculation{
public int add(int a,int b){
return a+b
Java codeJava code An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus...; Hi Friend,
Try the following
code:
import java.util.*;
import
java codejava code I am beginer in
java my question is how can i fill data from mysql database to jcombobox using netbeans
Java CodeJava Code Write a
java program, which creates multiple threads. Each thread performs add/delete/update operations on an ArrayList simultaneously
java codejava code hi,
Can any one tell me " How to read the data which is present om an image in
java java codejava code Write a program in
java for lru caching using two inputs one using integer and another using string of uppercase only
Java codeJava code Create a class called Student which has the following methods:
i. Average: which would accept marks of 3 examinations & return... & returns the name.
Hi Friend,
Try the following
code:
import
Java codeJava code Create a Bank class with methods deposit & withdraw. The deposit method would accept attributes amount & balance & returns....
Hi Friend,
Try the following
code:
import javax.swing.*;
class
Java codeJava code Create an Employee class which has methods netSalary which would accept salary & tax as arguments & returns the netSalary which... the following
code:
import java.util.*;
class Employee
{
static Scanner input=new
java codejava code An employee _id consist of 5 digits is stored in a string variable strEmpid. Now Mr.Deb wants to store this Id in Integer type to IntEmpid. write
Java statements to do
java codejava code input any word
ie risk,resul is--
r
ri
ris
risk
java codejava code Write a program to find the difference between sum of the squares and the square of the sums of n numbers
java codejava code Develop a program that accepts the area of a square and will calculate its perimeter
java codejava code Create a calculator class which will have methods add, multiply, divide & subtract
Java codeJava code Create Book having following attributes: Book ID, Title, Author and Price. Create Periodical which has the following additional attributes... Friend,
Try the following
code:
import java.util.*;
class Book{
int id
java codejava code Develop the program calculateCylinderVolume., which accepts radius of a cylinder's base disk and its height and computes the volume of the cylinder
java codejava code Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
java codejava code Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes
java codejava code
java database
code to retrieve data at runtime and please... language="
java"%>
<%@page import="java.sql.*"%>
<form method="post... e){}
%>
If you want the application
Java Swing then
Visit
java codejava code Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
java codejava code Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
java codejava code Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
Java codeJava code Develop the program calculatePipeArea. It computes the surface area of a pipe, which is an open cylinder. The program accpets three values: the pipes inner radius, its length, and the thickness of its wall
java codejava code An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
java codejava code Develop the program calculateHeight, which computes the height that a rocket reaches in a given amount of time. If the rocket accelerates at a constant rate g, it reaches a speed of g · t in t time units and a height
java codejava code Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
java codejava code Create an Employee class which has methods netSalary which would accept salary & tax as arguments & returns the netSalary which is tax deducted from the salary. Also it has a method grade which would accept
java codejava code Create Product having following attributes: Product ID, Name, Category ID and UnitPrice. Create ElectricalProduct having the following additional attributes: VoltageRange and Wattage. Add a behavior to change
java codejava code Create Book having following attributes: Book ID, Title, Author and Price. Create Periodical which has the following additional attributes: Period (weekly, monthly etc...) .Add a behavior to modify the Price
java codejava code Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional attributes:loading capacity( 100 tonsâ?¦).Add a behavior to change the color
Java codeJava code Create Product having following attributes: Product ID, Name, Category ID and UnitPrice. Create ElectricalProduct having the following additional attributes: VoltageRange and Wattage. Add a behavior to change