Janak,
Thank you for your answer, it was very helpful and I am now able to
position the dialog where I want it.
I have a different problem now though with the dialog text field.
About 1/8 of the time when the dialog pops-up the text fields does not
have focus (the cursor is not in the text field) and most frustratingly
I can not enter any text into the text field. I must close the dialog
and re-open it, sometimes 3 or 4 times before I can enter text in the
field.
Following is the dialog code:
private void showModalDialog(ULCTable table, String col, Point location)
{
ULCFrame parent = new ULCFrame();
final ULCDialog dialog = new ULCDialog(parent, "Search " + col);
ULCBoxPane dialogPane = new ULCBoxPane(1, 2);
final ULCTextField text = new ULCTextField(25);
text.setText(col);
text.select(0,col.length());
text.setBackground(Color.lightGray);
text.requestFocus();
dialogPane.add(ULCBoxPane.BOX_LEFT_CENTER, text);
ULCButton closeButton = new ULCButton("Search");
closeButton.addActionListener(new IActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
dialog.setVisible(false);
searchTableData(searchColumn, text.getValue());
}
});
dialogPane.add(ULCBoxPane.BOX_RIGHT_BOTTOM, closeButton);
dialog.add(dialogPane);
dialog.setDefaultButton(closeButton);
dialog.setSize(250, 150);
dialog.setResizable(false);
dialog.setLocation(location);
dialog.setVisible(true);
text.setVisible(true);
}
On Tue, 2006-10-03 at 20:36 +0530, Janak Mulani wrote:
> Hi Sharon,
>
> Please see the snippet at the end of this mail. It has a custom table header
> which listens to mouse events on the underlying JTableHeader.
>
> I am just using a method invocation from client to server instead of
> generating an event. You can modify if you wish to generate an event.
>
> >in the event. When I add the event source as an arg I get an error on
> >the client side:
> >'No coder registered for class
> >com.ulcjava.base.client.UITableHeader.BasicTableHeader'
>
> Event source is the UITablehHeader.BasicTableHeader - a client side proxy
> object. ULC framework does not know how to serialises this class to be able
> to send it to the server. Moreover, it does not make sense to send this
> class to the server because client side classes (UI*) are not available on
> the server.
>
> I hope this helps.
>
> Thanks and regards,
>
> Janak
>
> >-----Original Message-----
> >From: [EMAIL PROTECTED]
> >[mailto:[EMAIL PROTECTED] Behalf Of Sharon O'Connor
> >Sent: Monday, October 02, 2006 9:28 PM
> >To: [email protected]
> >Subject: [ULC-developer] Setting location of a dialog
> >
> >
> >Hi,
> >
> >I am trying to set the location of a dialog box so that it will appear
> >as close as possible to a table column that was clicked. The purpose is
> >that the columns are searchable so I would like the dialog in which the
> >user is going to enter the text they are searching for to 'pop-up' next
> >to the column they are searching on.
> >
> >My applet that is contained within a frame in my webapp. I am able to
> >create an event and send the point that is clicked to the server-side
> >but the point is relative to the table. I have yet to figure out how to
> >set the location of the dialog using this point. I have also tried
> >setLocationRelativeTo(ULCTable) but this does not set it close to the
> >header or the column.
> >
> >I have overridden UITableHeader in order to fire off the event but I
> >have been unsuccessful in setting the actual header as one of the args
> >in the event. When I add the event source as an arg I get an error on
> >the client side:
> >'No coder registered for class
> >com.ulcjava.base.client.UITableHeader.BasicTableHeader'
> >
> >If I do not try to send the actual event source from the client to the
> >server it all works fine, except that I can not set the location of the
> >dialog where I want it.
> >
> >
> >Following is the event code in my UITableHeader:
> >
> > public void mousePressed(MouseEvent event) {
> > JTableHeader header = (JTableHeader)getBasicComponent();
> > int colIndex = header.columnAtPoint(event.getPoint());
> > TableColumnModel model = header.getColumnModel();
> > TableColumn col = model.getColumn(colIndex);
> >
> > Object[] args = new Object[4];
> > args[0] = event.getPoint();
> > args[1] = event.getSource().toString();
> > args[2] = col.getModelIndex();
> > args[3] = event.getSource(); //This causes an error on the
> >client side
> > fireMandatoryEventULC("foo", "foo", args);
> >
> >
> >Following is the code in my dispatcher:
> >
> > protected class ComboSortedTableHeaderDispatcher extends
> >ULCTableHeaderDispatcher{
> > public EventObject createFooEvent
> >(com.ulcjava.base.application.util.Point p, String source, int col,
> >UITableHeader.BasicTableHeader header){
> >
> > ComboSortedHeaderEvent event = new ComboSortedHeaderEvent
> >(source, "foo");
> > event.setPoint(p);
> > event.setColumn(getTable().getColumnModel().getColumn(col));
> > event.setTable(getTable());
> > return event;
> > }
> >
> >Thank you for any suggestions in advance.
> >
> >--
> >Sharon O'Connor
> >Software Engineer
> >Meridias Capital
> >
> >Tel: 866-369-7755 ext. 4096
>
> ----------------
>
>
> import java.awt.event.MouseEvent;
> import java.awt.event.MouseListener;
>
> import javax.swing.table.JTableHeader;
> import javax.swing.table.TableColumn;
> import javax.swing.table.TableColumnModel;
>
> import com.ulcjava.base.application.AbstractApplication;
> import com.ulcjava.base.application.ULCBoxPane;
> import com.ulcjava.base.application.ULCDialog;
> import com.ulcjava.base.application.ULCFrame;
> import com.ulcjava.base.application.ULCScrollPane;
> import com.ulcjava.base.application.ULCTable;
> import com.ulcjava.base.application.table.DefaultTableModel;
> import com.ulcjava.base.application.table.ULCTableHeader;
> import com.ulcjava.base.application.util.Dimension;
> import com.ulcjava.base.application.util.Point;
> import com.ulcjava.base.client.UITableHeader;
> import com.ulcjava.base.development.DevelopmentRunner;
>
> public class DialogLocationInTableSnippet extends AbstractApplication {
> public void start() {
> final ULCTable table = new ULCTable(new SnippetTableModel(10,
> 3));
> table.setTableHeader(new ULCMyTableHeader(table));
>
> ULCBoxPane content = new ULCBoxPane(true);
> ULCScrollPane scp = new ULCScrollPane(table);
> content.add(ULCBoxPane.BOX_EXPAND_EXPAND, scp);
> ULCFrame frame = new ULCFrame("ULCTableColDragSnippet");
> frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
> frame.add(content);
> frame.setSize(300, 300);
> frame.setVisible(true);
>
> }
>
> public static void main(String[] args) {
> DevelopmentRunner
>
> .setApplicationClass(DialogLocationInTableSnippet.class);
> DevelopmentRunner.run();
> }
>
> private static class SnippetTableModel extends DefaultTableModel {
> public SnippetTableModel(int rowCount, int columnCount) {
> super(createRows(rowCount, columnCount),
> createColumnNames(columnCount));
> }
>
> private static Object[][] createRows(int rowCount, int
> columnCount) {
> Object[][] result = new Object[rowCount][];
> for (int i = 0; i < rowCount; i++) {
> result[i] = new Object[columnCount];
> for (int j = 0; j < columnCount; j++) {
> result[i][j] = i + ":" + j + " AAAa";
> }
> }
>
> return result;
> }
>
> private static String[] createColumnNames(int columnCount) {
> String[] result = new String[columnCount];
> for (int i = 0; i < columnCount; i++) {
> result[i] = Integer.toString(i);
> }
>
> return result;
> }
> }
>
> public static class ULCMyTableHeader extends ULCTableHeader {
> private ULCTable myTable;
>
> protected String typeString() {
> return UIMyTableHeader.class.getName();
> }
>
> public ULCMyTableHeader(ULCTable table) {
> super(table);
> myTable = table;
> }
>
> public void displaySearchDialog(Point location, Integer
> colIndex) {
> ULCDialog d = new ULCDialog(null, "Search column "
> +
> myTable.getColumnName(colIndex.intValue()));
> d.setSize(new Dimension(200, 70));
> d.setLocation(location);
> d.setVisible(true);
> }
>
> protected class ULCMyTableHeaderDispatcher extends
> ULCTableHeader.ULCTableHeaderDispatcher {
> public void displaySearchDialog(Point location, Integer
> colIndex) {
>
> ULCMyTableHeaderDispatcher.this.displaySearchDialog(location,
> colIndex);
> }
> }
> }
>
> public static class UIMyTableHeader extends UITableHeader implements
> MouseListener {
>
> protected void postInitializeState() {
> super.postInitializeState();
> getBasicTableHeader().addMouseListener(this);
> }
>
> public void mouseClicked(MouseEvent e) {
> }
>
> public void mouseEntered(MouseEvent e) {
> }
>
> public void mouseExited(MouseEvent e) {
> }
>
> public void mousePressed(MouseEvent event) {
> java.awt.Point tableLocation =
> getBasicTableHeader().getTable()
> .getLocationOnScreen();
> java.awt.Point relativeColumnLocation =
> event.getPoint();
> java.awt.Point dialogLocation = new
> java.awt.Point(tableLocation.x
> + relativeColumnLocation.x,
> tableLocation.y
> + relativeColumnLocation.y);
> JTableHeader header = (JTableHeader)
> getBasicComponent();
> int colIndex = header.columnAtPoint(event.getPoint());
> TableColumnModel model = header.getColumnModel();
> TableColumn col = model.getColumn(colIndex);
> Object[] args = new Object[2];
> args[0] = dialogLocation;
> args[1] = new Integer(col.getModelIndex());
> invokeULC("displaySearchDialog", args);
> }
>
> public void mouseReleased(MouseEvent e) {
> }
> }
>
> }
>
--
Sharon O'Connor
Software Engineer
Meridias Capital
Tel: 866-369-7755 ext. 4096
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer