brownie124
Programmer
Hi,
This may be a reach as this is what we call in the Notes/Domino world as an Agent. However, it is a Java agent and the agent works outside of Notes. So, I am hoping that someone out there may have an idea as to what is going on. Anyway, from my Notes client (for those of you who have never used Notes, it is a sophisticated gui program that runs on Windows), I am launching an agent that basically creates an invisible frame. From there, I create a dialog box (awt, not swing). The dialog box has a list component, a label and a couple of buttons. The dialog box comes up, but I can't do anything in the dialog box until I minimize and maximize a window from another application. I can't select from the list, I can't click a button, and I can't move the dialog box.
Does anyone have any ideas what is going on here? I am new to Java. Is it an event queue problem? How can I force my dialog box to get focus? I have tried requestFocus() for the dialog box itself as well as a particular component.
Again, this works outside of Notes just fine, so I realize that is the culprit, I just don't know enough Java to understand what is going on and how to grab focus.
Here is the code. Ignore the Notes specific stuff. You can go right to where I create the frame:
Thank you so much,
- Michael
This may be a reach as this is what we call in the Notes/Domino world as an Agent. However, it is a Java agent and the agent works outside of Notes. So, I am hoping that someone out there may have an idea as to what is going on. Anyway, from my Notes client (for those of you who have never used Notes, it is a sophisticated gui program that runs on Windows), I am launching an agent that basically creates an invisible frame. From there, I create a dialog box (awt, not swing). The dialog box has a list component, a label and a couple of buttons. The dialog box comes up, but I can't do anything in the dialog box until I minimize and maximize a window from another application. I can't select from the list, I can't click a button, and I can't move the dialog box.
Does anyone have any ideas what is going on here? I am new to Java. Is it an event queue problem? How can I force my dialog box to get focus? I have tried requestFocus() for the dialog box itself as well as a particular component.
Again, this works outside of Notes just fine, so I realize that is the culprit, I just don't know enough Java to understand what is going on and how to grab focus.
Here is the code. Ignore the Notes specific stuff. You can go right to where I create the frame:
Code:
import java.awt.*;
import java.awt.event.*;
import lotus.domino.*;
public class ExUserClassify extends AgentBase
{
// Construction
// Attributes
Session curSession;
AgentContext curAgentContext;
Database curDatabase;
Database colDatabase;
Document curDocument;
DocumentCollection curCollection;
String strFileName;
Frame f;
// Operations
public void NotesMain()
{
int i;
try
{
// Get current Session
curSession = getSession();
// Get current AgentContext
curAgentContext = curSession.getAgentContext();
f = new Frame();
CodeChooser cc = new CodeChooser(f, "Select Class Codes", true);
}
catch(Exception e)
{
e.printStackTrace();
}
}
// Implementation
}
class CodeChooser extends Dialog implements ActionListener
{
private boolean ok;
private Dialog dialog;
private Panel myPanel;
private Panel btnPanel;
private Label myLabel;
private List myList;
private Button okBtn;
private Button cancelBtn;
CodeChooser(Frame parent, String strTitle, boolean fModal)
{
super(parent, strTitle, fModal);
setSize(300, 200);
setLayout(new BorderLayout());
// Construct the panel with our controls.
myPanel = new Panel();
//panel.setLayout(new FlowLayout());
myLabel = new Label("Select code:");
myList = new List(8, false);
myList.addActionListener(this);
// For now, just add items.
myList.add("Gwynn");
myList.add("McGwire");
myList.add("Bonds");
myList.add("Ruth");
myPanel.add(myLabel);
myPanel.add(myList);
add(myPanel, BorderLayout.CENTER);
// Create the Ok and Cancel buttons.
okBtn = new Button("Ok");
okBtn.addActionListener(this);
cancelBtn = new Button("Cancel");
cancelBtn.addActionListener(this);
// Add buttons to another panel on the southern border.
btnPanel = new Panel();
btnPanel.add(okBtn);
btnPanel.add(cancelBtn);
add(btnPanel, BorderLayout.SOUTH);
myList.requestFocus();
// Anonymous inner class for window closing event handling.
// Note use of dispose() in place of the usual System.exit(0) - the agent runs the UI like an applet.
addWindowListener (
new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
dispose();
}
public void windowActivated(WindowEvent we)
{
System.out.println("Activated window");
}
public void windowDeactivated(WindowEvent we)
{
System.out.println("Deactivated window");
}
}
);
addFocusListener (
new FocusAdapter()
{
public void focusGained(FocusEvent fe)
{
System.out.println("Gained focus");
}
public void focusLost(FocusEvent fe)
{
System.out.println("Lost focus");
}
}
);
centerScreen();
//super.show();
System.out.println("here");
}
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource() == okBtn)
{
System.out.println("Ok btn");
dispose();
}
else if (ae.getSource() == cancelBtn)
{
System.out.println("Cancel btn");
}
else if (ae.getSource() == myList)
{
System.out.println("list");
}
else
System.out.println("other events");
} //end method
private void centerScreen()
{
Dimension dim = getToolkit().getScreenSize();
Rectangle abounds = getBounds();
setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
setVisible(true);
requestFocus();
}
}
Thank you so much,
- Michael