Paru kutty

Greenhorn
+ Follow
since May 16, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paru kutty

hi,I would like to know how to read combobox item &write selected item into a textfile...have used getSelectedItem() to retrieve the combobox selected item..then how can i write content into textfile??would appreciate it much if someone can help me here...thanking you in advance...
15 years ago
hi,I am not getting the textfield width properly...I am using scrollpane,but textarea is not narrow that it can't be seen...Am using grid bag layout..


Thanks in advance....
[ June 05, 2008: Message edited by: Rob Prime ]
15 years ago
hi,I want to know how to add jpanel to jframe .will this much in my code do?
JPanel jp=new jPanel();
jp.setSize(200,50);
jp.add(button1);//here i add components
jp.add(button2);
frame.setContentPane( BorderLayout.CENTER);
Am using Grid Bag layout...have already included the code before in this session,so I am not reposting it...thanks in advance
15 years ago
yes,i am using grid bag layout...will post the code with this....

public class GridBagWindow extends JFrame {
boolean inAnApplet = true;
final boolean shouldFill = true;
final boolean shouldWeightX = true;

public GridBagWindow() {
JButton button;
JFrame frame = new JFrame("Title Bar Text");
JPanel panel = new JPanel();
frame.setSize(256,256);
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.getContentPane().add(panel);
frame.pack();
JTextField fname,lname,jtadd,jtpla,jtdist,jtfam;
JTextArea jtxta;
JScrollPane js;
JLabel jl1,jl2,jadd2,jplace,jdist,jfam,jsex,jstat,jadd1;
JComboBox jcmb,jcmb1;
Container contentPane = getContentPane();
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
contentPane.setLayout(gridbag);
//JPanel jp=new JPanel(new GridBagLayout());
if (shouldFill) {
//natural height, maximum width
c.fill = GridBagConstraints.HORIZONTAL;
}
jl1 = new JLabel("First Name");
c.ipadx=2;
c.ipady=2;
c.gridx = 0;
c.gridy = 0;
gridbag.setConstraints(jl1, c);
contentPane.add(jl1);

fname = new JTextField(10);
if (shouldWeightX) {
c.weightx = 2;
}
c.gridx = 1;
c.gridy = 0;
gridbag.setConstraints(fname, c);
contentPane.add(fname);


jl2 = new JLabel("Last Name");
c.gridx = 0;
c.gridy = 1;
gridbag.setConstraints(jl2, c);
contentPane.add(jl2);



lname = new JTextField(10);
if (shouldWeightX) {
c.weighty = 2;
}
c.gridx = 1;
c.gridy = 1;
gridbag.setConstraints(lname, c);
contentPane.add(lname);


jadd1 = new JLabel("add1"); //add1 label,tetxfield
c.gridx = 0;
c.gridy = 2;
gridbag.setConstraints(jadd1, c);
contentPane.add(jadd1);


//jtxta = new JLabel(10,20);
c.gridx = 1;
c.gridy =2;
jtxta = new JTextArea(250,450);
jtxta.setEditable(true);
/*js=new JScrollPane(jtxta);
gridbag.setConstraints(js,c);
contentPane.add(js);*/
js = new JScrollPane(jtxta);
js.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
js.setPreferredSize(new Dimension(150, 100));
/* js.setBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder(""),
BorderFactory.createEmptyBorder(5,5,5,5)),
js.getBorder()));*/
gridbag.setConstraints(js,c);
contentPane.add(js);


jplace = new JLabel("Place"); //add2 label,tetxfield
c.gridx = 0;
c.gridy = 3;
gridbag.setConstraints(jplace, c);
contentPane.add(jplace);




jtpla = new JTextField(10);
if (shouldWeightX) {
c.weighty = 2;
}
c.gridx = 1;
c.gridy = 3;
gridbag.setConstraints(jtpla, c);
contentPane.add(jtpla);


jdist = new JLabel("District"); //district label,tetxfield
c.gridx =0;
c.gridy = 4;
gridbag.setConstraints(jdist, c);
contentPane.add(jdist);




jtdist = new JTextField(10);
if (shouldWeightX) {
c.weighty = 2;
}
c.gridx = 1;
c.gridy =4;
gridbag.setConstraints(jtdist, c);
contentPane.add(jtdist);


jfam = new JLabel("Family members"); //district label,tetxfield
c.gridx =0;
c.gridy = 5;
gridbag.setConstraints(jfam, c);
contentPane.add(jfam);


jtfam = new JTextField(10);
if (shouldWeightX) {
c.weighty = 2;
}
c.gridx =1;
c.gridy =5;
gridbag.setConstraints(jtfam, c);
contentPane.add(jtfam);


jsex = new JLabel("sex"); //sex label,tetxfield
c.gridx =0;
c.gridy = 6;
gridbag.setConstraints(jsex, c);
contentPane.add(jsex);


jcmb=new JComboBox();
String[] itemStr = { "male", "female"};
JMenu[] menus = new JMenu[2];
menus[0] = new JMenu(itemStr[0]);
menus[1] = new JMenu(itemStr[1]);
jcmb.addItem(itemStr[0]);
jcmb.addItem(itemStr[1]);
if (shouldWeightX) {
c.weighty = 2;
}
c.gridx = 1;
c.gridy = 6;
gridbag.setConstraints(jcmb, c);
contentPane.add(jcmb);


jstat = new JLabel("marital status"); //status label,tetxfield
c.gridx =0;
c.gridy = 7;
gridbag.setConstraints(jstat, c);
contentPane.add(jstat);


jcmb1=new JComboBox();
String[] itemStr1 = { "single", "married"};
JMenu[] menu1 = new JMenu[2];
menu1[0] = new JMenu(itemStr1[0]);
menu1[1] = new JMenu(itemStr1[1]);
jcmb1.addItem(itemStr1[0]);
jcmb1.addItem(itemStr1[1]);
if (shouldWeightX) {
c.weighty = 2;
}
c.gridx = 1;
c.gridy = 7;
gridbag.setConstraints(jcmb1, c);
contentPane.add(jcmb1);


button = new JButton("Button 5");
c.ipady = 0; //reset to default
c.weighty = 2; //request any extra vertical space
c.anchor = GridBagConstraints.SOUTH; //bottom of space
c.insets = new Insets(5,5,5,5); //top padding
c.gridx = 1; //aligned with button 2
c.gridwidth = 2; //2 columns wide
c.gridy = 8; //third row
gridbag.setConstraints(button, c);
contentPane.add(button);


addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
if (inAnApplet) {
dispose();
} else {
System.exit(0);
}
}
});
this.setVisible(true);
}

public static void main(String args[]) {
GridBagWindow window = new GridBagWindow();
window.inAnApplet = false;

window.setTitle("GridBagLayout");
window.pack();
window.setVisible(true);
}
}
15 years ago
how can I arrange spacing between the two textfields in two rows?kindly someone help me...thanking you in advance...
15 years ago
hello,i would like to know how to retrieve my system's mac id,cpu id using java..thanking you in advance...take care
15 years ago