Perhaps the worst thing is that back in the main Triton class, I have
code like this.
void setConnected(boolean isConnected) {
l_connected = isConnected;
if (l_connected) {
mi_login.setEnabled(false);
mi_logout.setEnabled(true);
} else {
mi_login.setEnabled(true);
mi_logout.setEnabled(false);
}
}
boolean isConnected() {
return(l_connected);
}
All this does is toggle the "connected" state, and enables/disables
menu items accordingly. I really, really don't like this design.
===
Gregory Woodhouse
[EMAIL PROTECTED]
"Nothing is as powerful than an idea
whose time has come."
-- Victor Hugo
On Jul 12, 2005, at 5:49 AM, Kevin Toppenberg wrote:
I've done very little with java, so let me feel my way
here.
I assume that function public LoginDialog is the
constructor for class LoginDialog. I see Frame passed
as a parameter to the constructor, but I don't see
that you use it. What is it doing?
Kevin
--- Gregory Woodhouse
<[EMAIL PROTECTED]> wrote:
Well, here's some code I wrote to implement a login
dialog (not that
I'm all that proud of it -- I think it's ugly). You
can see that this
is exactly how the reference passed to the
constructor is used.
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
public class LoginDialog extends JDialog {
private JButton l_loginButton;
private JButton l_cancelButton;
private Container l_content;
private Triton l_application;
public LoginDialog(Frame parent) {
super(parent, "Login", true);
l_application = (Triton) parent;
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
l_content = getContentPane();
l_loginButton = new JButton("Log
in");
l_loginButton.addActionListener(new
ActionListener() {
public void
actionPerformed(ActionEvent ae) {
signIn();
setVisible(false);
dispose();
}
});
l_cancelButton = new
JButton("Cancel");
l_cancelButton.addActionListener(new
ActionListener() {
public void
actionPerformed(ActionEvent ae) {
l_application.setConnected(false);
setVisible(false);
dispose();
}
});
JPanel p = new JPanel();
//p.setLayout(new GridLayout(2,1));
EmptyBorder empty = new
EmptyBorder(0, 0, 0, 10);
p.setLayout(new GridBagLayout());
p.setBorder(new EmptyBorder(new
Insets(5, 5, 5, 5)));
getContentPane().add(BorderLayout.CENTER, p);
GridBagConstraints c = new
GridBagConstraints();
c.insets = new Insets (2, 2, 2, 2);
c.anchor = GridBagConstraints.WEST;
JLabel name_label = new
JLabel("Login Name");
name_label.setBorder(empty);
c.gridwidth = 1;
c.weightx = 0.0;
p.add(name_label, c);
JTextField name = new JTextField();
c.gridx = 1; //position
c.weightx = 1.0;
c.fill =
GridBagConstraints.HORIZONTAL;
p.add(name, c);
JLabel password_label = new
JLabel("Password");
c.gridwidth = 1;
c.gridx = 0;
c.gridy = 1;
c.weightx = 0.0;
p.add(password_label, c);
JPasswordField password = new
JPasswordField();
c.weightx = 1.0;
c.gridx = 1;
p.add(password, c);
setSize(300,200);
c.weightx = 0.0;
c.gridx = 0;
c.gridy = 2;
p.add(l_loginButton, c);
c.gridx = 1;
c.gridy = 2;
c.weightx = 0.0;
c.fill= GridBagConstraints.NONE;
p.add(l_cancelButton, c);
}
protected void signIn() {
l_application.setConnected(true);
}
protected void signOut() {
l_application.setConnected(false);
}
}
===
Gregory Woodhouse
[EMAIL PROTECTED]
"The whole of science is nothing more than a
refinement
of everyday thinking." -- Albert Einstein
On Jul 11, 2005, at 5:15 PM, Kevin Toppenberg wrote:
I wonder if the reference to the JFrame is for a
messaging system. In Borland/Windows, a GUI
object
has both an 'owner' (one responsible for utimately
destroying it) as well as a 'parent' (one from
whom
one receives windows messages). I can't see why
your
objects would need to reference the JFrame (is
this a
graphic frame?) unless it was for messaging (i.e.
"time to repaint your area!")
Kevin
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With
Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to
explore the latest in dual
core and dual graphics technology at this free one
hour event hosted by HP,
AMD, and NVIDIA. To register visit
http://www.hp.com/go/dualwebinar
_______________________________________________
Hardhats-members mailing list
Hardhats-members@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hardhats-members
____________________________________________________
Sell on Yahoo! Auctions – no fees. Bid on great items.
http://auctions.yahoo.com/
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar
happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in
dual
core and dual graphics technology at this free one hour event
hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Hardhats-members mailing list
Hardhats-members@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hardhats-members
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Hardhats-members mailing list
Hardhats-members@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hardhats-members