7 Replies - 8188 Views - Last Post: 03 May 2011 - 04:14 AM Rate Topic: -----

#1 elvea  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 22-April 11

GUI Calendar

Posted 25 April 2011 - 03:34 AM

Hi,

I've been trying out this code http://www.dreaminco...er-application/, but I would like to add the function of adding/removing an event by clicking inside the calendar. Ideas on how I can do that? Any type of help is greatly appreciated!
Is This A Good Question/Topic? 0
  • +

Replies To: GUI Calendar

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2857
  • View blog
  • Posts: 10,960
  • Joined: 15-July 08

Re: GUI Calendar

Posted 25 April 2011 - 03:43 AM

Just add a standard listener to it, but then find the cell that was selected with the following methods:
http://download.orac...ectedRows%28%29
http://download.orac...edColumns%28%29

Since you know only one cell will ever be selected at a time (as per the tutorial), this is a safe method for doing so.
Was This Post Helpful? 1
  • +
  • -

#3 elvea  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 22-April 11

Re: GUI Calendar

Posted 25 April 2011 - 04:22 AM

Could you explain it in a bit more detail? And how do I add a MouseListener? Because I tried this
handelerC handeler = new handelerC();
panel.addMouseListener(handeler);

private class handelerC implements MouseListener {

public void mouseEntered(MouseEvent event) {
statusBar.setText("hi");

}

public void mouseExited(MouseEvent event) {
statusBar.setText("bye");

}

public void mouseClicked(MouseEvent event) {
statusBar.setText("you clicked");

}



But it didn't work.
Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2857
  • View blog
  • Posts: 10,960
  • Joined: 15-July 08

Re: GUI Calendar

Posted 25 April 2011 - 02:48 PM

Don't you want to set the MouseListener on the JTable instead?
Was This Post Helpful? 0
  • +
  • -

#5 elvea  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 22-April 11

Re: GUI Calendar

Posted 26 April 2011 - 04:30 AM

We want a MouseListener so we can click on different days and add text to that specific day. So if adding the MouseListener on the JTable will make that work, that's what I want!
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10180
  • View blog
  • Posts: 37,586
  • Joined: 27-December 08

Re: GUI Calendar

Posted 26 April 2011 - 08:13 AM

That's exactly what you want. Check out the JTable rowAtPoint() and columnAtPoint() methods as well. :)
Was This Post Helpful? 1
  • +
  • -

#7 elvea  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 22-April 11

Re: GUI Calendar

Posted 02 May 2011 - 05:55 AM

So I changed this part:

tableModel = new DefaultTableModel(){public boolean isCellEditable(int rowIndex, int mColIndex){return false;}};


Returning true instead of false. And now I can write in the cells, but it isn't pretty, haha.

Someone told me that I could use something called TableCellEditor, but I don't really understand how that works. Is there anyone who feels like explaining it a bit?
Was This Post Helpful? 0
  • +
  • -

#8 elvea  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 22-April 11

Re: GUI Calendar

Posted 03 May 2011 - 04:14 AM

Anyone?
Just a little help would be so appreciated!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1