Jtable mouse header cursor


,

when the mouse cursor is over the boundary between the headers of two adjacent columns in a jtable, it changes to a double headed arrow, indicating that the column width can be changed by dragging the mouse. How can I put a listener that tells me when the mouse icon has changed from a simpe mouse pointer to a double headed arrow
Posted On: Tuesday 2nd of October 2012 11:40:45 PM Total Views:  100
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




create a jtable which can combine and split and the image change also

hi newbie here and would like to know how to create a jtable with default images and with specific column and rows that if you combine the cells the image enlarge and when split the image decreases.
VIEWS ON THIS POST

213

Posted on:

Wednesday 19th September 2012
View Replies!

Suppress normal mouse click behavior when it is a popup trigger

Hi. I am trying to create a GUI in which left and right mouse clicks perform different actions. The left click selects and performs operations and the right click opens a context menu. To be platform independent, I'm using the isPopupTrigger method to determine whether a click is what I would call a "right" click. My problem is that mouse clicks of any kind are triggering the normal click behavior. I can open my context menu when a mouse event is a popup trigger but then the normal click behavior occurs also. I can work around the problem by doing the following. I'm using Windows so mouseReleased is the point at which isPopupTrigger will return true. public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showContextMenu(e); } else { doNormalClickBehavior(e.getPoint()); } }
VIEWS ON THIS POST

104

Posted on:

Saturday 22nd September 2012
View Replies!

how to make mouse clicked event in jlist

Hi My GUI page contains JList and table. Based on the selection in jlist, each time table has to be modified, i.e., if i select first value in jlist and I am adding one or more rows in the table. And then if i click second value in jlist means, a new table have to appear and have to add some new values. Likewise the table should be.. Can anyone suggest me, how to do like this.. I need to complete this within today.. But i dont know how to do.. help please!!
VIEWS ON THIS POST

110

Posted on:

Saturday 22nd September 2012
View Replies!

trying to run a c-shell script from a mouse pressed event in netbeans

have a form that has a menu and sub menu's. I want the user to be able to click on a menu item and have the script run itself. So i created java utility class and added it to the project. Here is the code of what my class looks like import java.io.Writer; import java.io.BufferedReader; import java.sql.*; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringWriter; import java.sql.*; public class RunShellScript { public static void runShellScript (String unixCommand) { try { Runtime runtime=Runtime.getRuntime(); Process process=runtime.exec(new String [] { "/bin/csh", "-c", unixCommand}); int exitValue=process.waitFor(); System.err.println("exit value: " + exitValue); BufferedReader buf=new BufferedReader (new InputStreamReader(process.getInputStream())); String line=""; while ((line=buf.readLine()) !=null) { System.out.println("exec response: " + line); } }catch (Exception e) { System.out.println(e); } } }
VIEWS ON THIS POST

137

Posted on:

Saturday 22nd September 2012
View Replies!

How to call mouseClicked() of JButton without clicking it?

. I'm making simple gallery, and i have small problem. I have for List of 20 JButtons (which icon is my Image). I don't want to add MouseListeners to each JButton. And i tried to add Action Listener in a loop. I tried something like this: int licznik = 0; while (licznik < miniaturyObrazkow.size()-1) { miniaturyObrazkow.get(licznik).addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { pokazZdjecie.setIcon(obrazkiFull.get(licznik)); duzeZdjecie.revalidate(); duzeZdjecie.repaint(); } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } }); licznik++; }
VIEWS ON THIS POST

84

Posted on:

Monday 24th September 2012
View Replies!

How to call mouseClicked() of JButton without clicking it?

. I'm making simple gallery, and i have small problem. I have for List of 20 JButtons (which icon is my Image). I don't want to add MouseListeners to each JButton. And i tried to add Action Listener in a loop. I tried something like this: int licznik = 0; while (licznik < miniaturyObrazkow.size()-1) { miniaturyObrazkow.get(licznik).addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { pokazZdjecie.setIcon(obrazkiFull.get(licznik)); duzeZdjecie.revalidate(); duzeZdjecie.repaint(); } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } }); licznik++; }
VIEWS ON THIS POST

128

Posted on:

Monday 24th September 2012
View Replies!

Detecting global mouse click

I have an application which has several transparent components, and I want to detect a mouse click on them. Unfortunately, transparent components don't seem to register any mouse events. So is there any way of detecting a mouse click just on a kind of global basis Once a click is detected, I can easily tell whether the mouse is inside my component by doing a "component.getBounds().contains(mousex, mousey)". I really need is to detect the click, and which button it is that's been clicked. Many
VIEWS ON THIS POST

58

Posted on:

Monday 24th September 2012
View Replies!

Get Robot.mouseWheel(i) to work with touchpad?

I'm writing a program that uses Robot.mouseWheel(i) to scroll a third party application. It works fine on my desktop, but doesn't work on the laptop where I need it to work. the other robot methods I use work on the laptop. Anybody have any idea how I could go about trying to get it to work hp probook 655b synaptics ps/2 port touchpad latest touchpad driver
VIEWS ON THIS POST

79

Posted on:

Monday 24th September 2012
View Replies!

jtable, defaulttable model

hello how can i remove column in JTable i have already made a button that when triggered it will add column through DefaultTableModel tbl = new DefaultTableModer(): tbl.addColumn(columnList.get(x)) now what im trying to do is make a column vanish T T and im surprised i did not see a removeColumn method xD is there anyway i can remove columns through runtime and if JTable.remove(component) is the answer how how can i use it xD
VIEWS ON THIS POST

211

Posted on:

Monday 24th September 2012
View Replies!

how to move mouse pointer programatically ?

how can i make mouse pointer move programatically in java
VIEWS ON THIS POST

81

Posted on:

Monday 24th September 2012
View Replies!

Generating pdf from jtable

I am developing a tool in java to generate pdf from jtable. I tried to use itext but I am getting black pdf. Below is the code that I used. import java.awt.BorderLayout; import java.awt.Graphics2D; import java.awt.Shape; import java.io.FileOutputStream; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTable; //import com.itextpdf.awt.PdfGraphics2D; import com.itextpdf.text.Document; import com.itextpdf.text.PageSize; import com.itextpdf.text.pdf.PdfContentByte; //import com.itextpdf.text.pdf.PdfTemplate; import com.itextpdf.text.pdf.PdfWriter; public class Pdf extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JTable table; public Pdf() { getContentPane().setLayout(new BorderLayout()); createTable(); } private void createTable() { Object[][] data = {{ "a", "b", "e", new Integer(5), new Boolean(false) } }; String[] columnNames = { "A", "B", "C", "D", "E" }; table = new JTable(data, columnNames); JPanel tPanel = new JPanel(new BorderLayout()); tPanel.add(table.getTableHeader(), BorderLayout.NORTH); tPanel.add(table, BorderLayout.CENTER); getContentPane().add(tPanel, BorderLayout.CENTER); } private void print() { Document document = new Document(PageSize.A4.rotate()); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("jTable.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); Graphics2D g2 = cb.createGraphicsShapes(500, 500); Shape oldClip = g2.getClip(); g2.clipRect(0, 0, 500, 500); table.print(g2); g2.setClip(oldClip); g2.dispose(); cb.restoreState(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); } public static void main(String[] args) { Pdf frame = new Pdf(); frame.pack(); frame.setVisible(true); frame.print(); } }
VIEWS ON THIS POST

199

Posted on:

Monday 24th September 2012
View Replies!

Create and dynamically change buttons in jtable column

I am having a lot of problems fully grasping tablecellrenderer and tablecelleditor. I have researched a lot, looked in a lot of forums, but still can't solve my problem. Without posting an sscce (because my code is probably very incorrect), how would I do the following: Create a jtable with a column that has ButtonX in it. Then when another column in a specific row gets a certain value, ButtonX will change to ButtonY, but other rows will remain what they are already. In the following example, all rows started with ButtonX, but when Progress changed from Uploading to Complete, ButtonX became ButtonY. Row Name Progress Abort/Complete 0 File 1 Complete ButtonY 1 File 2 Complete ButtonY 2 File 3 Uploading ButtonX The buttons need to update accordingly if a row is deleted. For example if row 0 is deleted, it should look like: Row Name Progress Abort/Complete 0 File 2 Complete ButtonY 1 File 3 Uploading ButtonX
VIEWS ON THIS POST

274

Posted on:

Monday 24th September 2012
View Replies!

Printing mouse cordinates

My goal is to print the mouse coordinates when the mouse is clicked within a frame and displayed in a text box. Here is my code so far, please help! import java.awt.*; import java.awt.event.*; public class Mouse extends Frame implements MouseListener, WindowListener { TextField text = new TextField(20); public static void main(String[] args){ Mouse mse = new Mouse(); mse.setSize(300, 300); mse.setVisible(true); } Mouse(){ super("Mouse Position"); setLayout(new FlowLayout()); addWindowListener(this); add(text); } public void mouseClicked(MouseEvent e){ text.setText(Point getPoint()); } public void windowClosing(WindowEvent e) { //Method to properly close the window dispose(); System.exit(0); } }
VIEWS ON THIS POST

59

Posted on:

Tuesday 25th September 2012
View Replies!

Draw multiple circles on mouse click

Hi all, So far i managed to get a circle to show itself on the JPanel when the mouse is clicked. The only problem i have is that it doesn't show multiple circles when clicked, instead it deletes the pervious one. I have a method called paint() where the graphics is drawn. public void paint(Graphics g) { //Conversion to 2D graphics Graphics2D g2d = (Graphics2D)g; super.paint(g2d); //Enables antialiasing to the graphics object g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int red = (int) (Math.random()*256); int green = (int)(Math.random()*256); int blue = (int)(Math.random()*256); g2d.setColor(new Color(red, green, blue)); g2d.drawString("I am a circle", mouseX, mouseY); g2d.fillOval(mouseX, mouseY, 20, 20); }
VIEWS ON THIS POST

81

Posted on:

Tuesday 25th September 2012
View Replies!

mousePressed and responding to it

When I create and event and I respond it with method mousePressed() then what is difference between these two: public void mousePressed(MouseEvent e) { if (e.getSource().equals(panel)) { panel.repaint(); } }
VIEWS ON THIS POST

55

Posted on:

Wednesday 26th September 2012
View Replies!

method for mouse when the mouse stopped Dragging but is not released yet

. I am interested how to do this thing: for e.g., I want to draw a square when the mouse stopped Dragging but is not released yet I tried mouse pressed but it calls it only at the beginning. So, I have no idea, any help Cheers in advance!
VIEWS ON THIS POST

71

Posted on:

Wednesday 26th September 2012
View Replies!

Request focus for the first cell of a jtable.

I'm having a JTable which is having text field in each of its cell. I would like to set the cursor in the first cell of each row in the Jtable. I'm trying to find some solution but not able to succeed. Please provide me some working example. Quick solution will be appreciated. TableColumn column0 = jTable2.getColumnModel().getColumn(0); JTextField textField = new JTextField(); textField.requestFocus(); DefaultCellEditor cellEditorFristColumn = new DefaultCellEditor(textField); column0.setCellEditor(cellEditorFristColumn); DefaultTableCellRenderer defaultRenderer = new DefaultTableCellRenderer(); defaultRenderer.requestFocus(); jTable2.getColumnModel().getColumn(0).setCellRenderer(defaultRenderer);
VIEWS ON THIS POST

304

Posted on:

Friday 28th September 2012
View Replies!

Window (Game) not registering mouse clicks occasionally

Hi folks, I've been learning Java and OOP in my spare time for fun lately. After finishing with Head First Java, I'm currently reading through Daniel Liang's excellent Introduction to Java Programming Comprehensive and Core Java Vol 1. I'm currently programming some of the exercise problems at the end of the Event driven programming chapter of the first book. Here is the exercise problem: Write a program that displays a circle of radius 10pixels filled with a random color at a random location on a panel. When you click the circle, it is gone and a new random-color circle is displayed at another random location. After twenty circles are clicked, display the time spent in the panel. I've coded this up and it works perfectly, except that when clicking in rapid succession, some of the clicks are not registered. I have noticed this with other programs I have written as well, and when I run the compiled class files provided by the author of the book (to try running all the exercise problems), I observe a similar behavior. Is this a concurrency issue due to conflicts with the GUI EDT I haven't read up on threads and concurrency yet, but if that is the case, I'd like to identify where the issue is being produced. With the bug as is, this exercise is a bit pointless because you can never get a great "score" due to the unregistered click events. PS - I have added in some stuff to avoid bugs when resizing the window. I know that I could have set it to not be resizable, but I was just playing around with the code to see if I could handle that case without making a hash of things. Also, I'd appreciate any general comments about the program and what I could do to improve it. import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class Exercise16_27 extends JFrame { public Exercise16_27() { add(new MoveCircleGamePanel()); } public static void main(String [] args) { JFrame frame = new Exercise16_27(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.pack(); frame.setVisible(true); } }
VIEWS ON THIS POST

59

Posted on:

Sunday 30th September 2012
View Replies!

some event in swing which is similar to mouse events, sensed throu touch screen

hi, Actually i am using the touch screen in my application, front end. But the problem is ,on particular button i have added the event, mouse pressed and mouse released. ie. in state of mouse pressed some task is performed and ,on release of mouse some other task gets executed. all the task takes place when operations are performed throu mouse, but while using fingers on touch screen, task don't get perform . So please let me know any event which could work similar to mouse press and mouse release on touch screen.
VIEWS ON THIS POST

95

Posted on:

Monday 1st October 2012
View Replies!

TreeSelectionHandler and mouseovers

TreeSelectionHandler's valueChanged event is being fired whenever I move the mouse over a node. That's a problem. I have some drag-and-drop logic, and when I drag something from a higher node to a lower node, the event is being fired whenever I pass over the in-between nodes on the way to the final drop location. My program has some code for validating the drop location, but I don't want that code to run simply because I moused over a node. I thought about writing my own MouseListener, but there's no guarantee that MouseEvent will be fired before TreeSelectionEvent. How do I get TreeSelectionHandler to respond to an actual mouse click, rather than the "mouse entered" event
VIEWS ON THIS POST

69

Posted on:

Monday 1st October 2012
View Replies!