Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Button

Status
Not open for further replies.

miketb69

Programmer
Oct 5, 2000
2
US
Greetings! I'm fairly new to Java and I was assign to work on a Login Screen, with three buttons (OK, Cancel, Clear). I'm extending a frame and the problem is the last button, (whatever I add last) disregards the setbound and is being resized to the size of the frame, so if I make the frame bigger or smaller, the last button goes with it. I'm sure somebody out there knows a way to fix this, can anybody help me. Thank you very much.
 
here's some code, hope this helps


import com.sun.java.swing.*;
import java.awt.*;

public class JApplet1 extends JApplet
{
public void init()
{

//{{INIT_CONTROLS
getContentPane().setLayout(null);
setSize(426,266);
ok_btn.setText("OK");
getContentPane().add(ok_btn);
ok_btn.setBounds(60,204,72,40);
clear_btn.setText("Clear");
getContentPane().add(clear_btn);
clear_btn.setBounds(168,204,72,40);
cancel_btn.setText("Cancel");
getContentPane().add(cancel_btn);
cancel_btn.setBounds(276,204,72,40);
getContentPane().add(JTextField1);
JTextField1.setBounds(72,36,266,31);
getContentPane().add(JTextField2);
JTextField2.setBounds(72,108,266,31);
//}}

//{{REGISTER_LISTENERS
SymAction lSymAction = new SymAction();
ok_btn.addActionListener(lSymAction);
clear_btn.addActionListener(lSymAction);
cancel_btn.addActionListener(lSymAction);
//}}
}

//{{DECLARE_CONTROLS
com.sun.java.swing.JButton ok_btn = new com.sun.java.swing.JButton();
com.sun.java.swing.JButton clear_btn = new com.sun.java.swing.JButton();
com.sun.java.swing.JButton cancel_btn = new com.sun.java.swing.JButton();
com.sun.java.swing.JTextField JTextField1 = new com.sun.java.swing.JTextField();
com.sun.java.swing.JTextField JTextField2 = new com.sun.java.swing.JTextField();
//}}

class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == ok_btn)
ok_btn_actionPerformed(event);
else if (object == clear_btn)
clear_btn_actionPerformed(event);
else if (object == cancel_btn)
cancel_btn_actionPerformed(event);
}
}

void ok_btn_actionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.

}

void clear_btn_actionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.

}

void cancel_btn_actionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.

}
}

Dano
dskryzer@hotmail.com
What's your major malfunction
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top