How to retrieve a specific cell in a table using SWT/JFace ?


Hi flks,
Im totally newbie in SWT/JFace so my question may be so trivial for you.
With an org.eclipse.swt.widgets.Table how can i access an specific cell of
the table i.e: Row 3, Column 4.
I can create a TableColumn or a TableItem giving a Table but is there any way to access a cell, givin a row and a column

Posted On: Tuesday 23rd of October 2012 10:35:05 PM Total Views:  105
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




Find out if there is a component in a specific cell of GridBagLayout?

Hi , it's been awhile, but I'm glad to be back. I'm making a program to layout photos in a collage, grid style. I've created a custom component that extends JPanel, called PhotoPanel. Each PhotoPanel paints it's photo on the JPanel with a transparent background. I layout the PhotoPanels in a JPanel (called the PagePanel) using GridBagLayout. Each PhotoPanel has an instance of GridBagConstraints. When properties are changed for either the page or the selected PhotoPanel, the selected PhotoPanel's GridBagConstraints is updated, and the page layout is redone: e.g. all components are removed from the PagePanel and then readded using their own, updated GridBagConstraints object. The idea is that each photo can be set up to occupy multiple cells in the grid, using the GridBagConstraints 'gridwidth' and 'gridheight' properties. My method to add all of the PhotoPanels to the PagePanel keeps track of 'row', 'column', 'maxRows', and 'maxColumns' variables to control where the PhotoPanels are added. They are simply added in sequential order like so: set the PhotoPanel's constraints, including 'row' and 'column' page.add(PhotoPanel, PhotoPanel.myConstraints); column++ if(column >= maxColumns){ column = 0; row++; } What I want is to check the GridBagLayout to see if there is already a component occupying the cell at position "row,column" so that I can skip that cell. My current approach is that I create a boolean array of size [maxRows][maxColumns] and then set the "cells" where I add components to true. For components that occupy multiple cells on the PagePanel, multiple "cells" in the array are set to true in the proper positions. It works the way I want it to right now, but I feel like it would be more reliable to be able to "ask" the GridBagLayout if a certain cell is already occupied. Is there a way to do this or should I just stick with my boolean array
VIEWS ON THIS POST

172

Posted on:

Saturday 22nd September 2012
View Replies!

disable witing in specific cells in JTable

Hi all; I am a beginner in programming, and this course I suppose to create Sudoku generator by using java in NetBeans So far I did the code for generating numbers in a JTable and show the whole solution upon request But I am straggle in how to disable writing in the visible numbers or the visible cells but enable in the empty cells I used this code but as it is cleat it disable typing in the whole table workSheetTable.getCellEditor(); Also I cant think of a way that enables me to get the answer from the empty cells and compare it with the actual solution!!! Could you help me please in this !
VIEWS ON THIS POST

120

Posted on:

Tuesday 25th September 2012
View Replies!

How to represent a directory like an application-specific file in Java Swing on Mac

, How to represent a directory like an application-specific file in Java Swing on Mac The application creates files that are stored in directories. How to represent those directories like application-specific files with icon assigned to them, etc, etc Thank you.
VIEWS ON THIS POST

81

Posted on:

Tuesday 25th September 2012
View Replies!

how to retrieve the data entered in the HTML form from my Java application?

hello, i m loading a html page in JEditorPane. the html page has a report (like table), i need to print that on paper. i want to know can I retrieve the data (i mean field values)entered in the HTML form from my Java application. If so how.. i mean this is my html page: Name of the student (in full) Examination Month and year Exam Seat no Result Class [b][i]this value from my application[/i][/b] [b][i]this value from my application[/i][/b] [b][i]this value from my application[/i][/b] [b][i]this value from my application[/i][/b] [b][i]this value from my application[/i][/b]h
VIEWS ON THIS POST

69

Posted on:

Tuesday 25th September 2012
View Replies!

in a JTable, changing column header text alignment for specific columns only

, At what classes should one look at (research) when trying to change the alignment of the header text for a specific column in a JTable I figured out how to change the entire JTableHeader text aligment through the getDefaultRenderer(), but I cannot figure out how to make certain column headers to be aligned left, while others are right.
VIEWS ON THIS POST

193

Posted on:

Monday 1st October 2012
View Replies!

is it possible to retrieve exif data using the javax.imageio package ?

hi, all! I am just wondering if it is possible to retrive by that i refer to read exif data that are part of an image objects header file like camera type and color model and so on Im very much into javas picture handling features theese days and i have wondered about this for a long time but i haven't done that much researching about this topic yet but i know that there is a library for this out there called sanselan if i remembered it correctly If there is a way to retrieve exif data using the imageio package i'd be very much greatful for any tips or hints on how to accieve this. I dont know that much about exif otherwise but i am learning more and more. best regards, krillian.
VIEWS ON THIS POST

110

Posted on:

Wednesday 17th October 2012
View Replies!

How to retrieve constant for bg-color of a JPanel?

Defining a central constant referring to the default background color of a JPanel I do the following as a first approach: public static final Color DEFAULT_BG_COLOR = new JPanel().getBackground();
VIEWS ON THIS POST

58

Posted on:

Wednesday 17th October 2012
View Replies!

retrieve data in swing

hi I want to retrieve data from database in java swing. how can do that I have 4 columns in java swing which would fetch values from database
VIEWS ON THIS POST

131

Posted on:

Wednesday 17th October 2012
View Replies!

Placing Jcombo at specific coordinates

Right now I have a constructor that creates a window and I would like to place j combo boxes on the right hand side of the window but I am not sure how to that. If that is done, then is it possible to place a jcombo box at a specific coordinate such as at (829, 208) here is a picture of what I am trying to make public class GameLayout extends JFrame{ //Standard Colors final static Color brown = new Color(196, 3, 0); private TransparentPanel transparentPanel; /** * Creates the game's window * */ public GameLayout() { transparentPanel = new TransparentPanel(); JLabel lbl = new JLabel(new ImageIcon("C:\\Program Files\\eclipse\\Workspace\\CS50\\GameLayout.jpg")); JDesktopPane dp = new JDesktopPane(); lbl.setBounds(0,0,800,800); transparentPanel.setBounds(0,0,800,800); dp.add(lbl,new Integer(10)); dp.add(transparentPanel,new Integer(350)); setLayeredPane(dp); dp.setBackground(brown); setSize(1200,833);//805,833); setLocation(50,50); setVisible(true); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); }
VIEWS ON THIS POST

55

Posted on:

Thursday 18th October 2012
View Replies!

set color of just one specific word into the text area.

i am trying to develop an application and i need to change the color of a particular word in the same TextArea from which it is being read. i have gotten this far : for(int i = 0;i < inWord.length; i++){ //inWord is a Strin[] having the words that the user has written into the TextArea i.e. txtInput if((lookup = (String) list.get(inWord[i])) == null){ //to check if the word is present or not, if not present txtInput.setForeground(Color.red); // change the foreground color txtInput.replaceRange(inWord[i],startPos,startPos+inWord[i].length()); //and replace the word at the correct position in the TextArea i.e. txtInput with changed color break; } else startPos = startPos + inWord[i].length()+1; // else find the position of where to replace. } the problem, that you all might have guessed by now, is once i use the setForeground() method.... the foreground color of entire TextArea changes to red. whereas i just want to change the color of the word that i am inserting. Also if there are any methods to directly change the color a particular word in the TextArea without reading it and reinserting it. please help. rohitrusty314.
VIEWS ON THIS POST

56

Posted on:

Sunday 21st October 2012
View Replies!

color in jtable cell

i have this code (to be entirely frank i cant recall where i found it), that paints every other line with a diferent color Color cor = table.getBackground(); if((row%2) == 0 && cor.getRed() > 20 && cor.getGreen() > 20 && cor.getBlue() > 20) setBackground(new Color(cor.getRed() - 20, cor.getGreen() - 20, cor.getBlue() - 20)); else setBackground(cor)
VIEWS ON THIS POST

147

Posted on:

Monday 22nd October 2012
View Replies!

Automatically Scroll To a specific area in a JTextPane

If I have a bunch of text in a JTextPane, and I have a particular word that is being focused on (kinda like a spell checker would), how would accomplish something like this with a JScrollPane
VIEWS ON THIS POST

35

Posted on:

Monday 22nd October 2012
View Replies!

Editable cells in a JTable

! I am working on a project for school, in which I have a JTable. The assignment requires a "Modify" button that actually works. In my JTable, the default (of course) is set for editable, however my modify button has to do something other than just look good! If I override the default setting to uneditable, is it possible to write a method that will override that setting once the modify button is pressed, or am I spinning my wheels How, should this be approached
VIEWS ON THIS POST

40

Posted on:

Monday 22nd October 2012
View Replies!

How to create border or change color in a JTable cell?

Dear Friends, I created table in my application using JTable. In this table most of the cells has JCheckBoxes (which has created by using Boolean.class). In this table some of JCheckBox cells alone to be looked differently either by changing background color or by created border to that cell. Could anyone please tell me how to set the background color for a particular cell or create the border for a particular cell
VIEWS ON THIS POST

69

Posted on:

Monday 22nd October 2012
View Replies!

How to Provide action for JTable cell?

Hi.. I need to provide action for a single cell in JTable.. me out please..
VIEWS ON THIS POST

26

Posted on:

Monday 22nd October 2012
View Replies!

Regarding adding buttons inside BorderLayout at a specific location

I am trying to draw a graph and add few buttons at the bottom of the page. I am using BorderLayout and have put the Graph (using a JPanel) at the Center and trying to add buttons to the South region (using a JPanel with GridBagLayout). What I want to find out is - Can I specifically add the buttons to a particular location in the UI (specifying the pixels, or whatever units) or Swing takes care of doing it. Can we have any control over it Or is it better achieved using GridBagLayout for the entire UI
VIEWS ON THIS POST

58

Posted on:

Monday 22nd October 2012
View Replies!

DataTip for a cell in JTable

Hi all, I have JTable in which one particular column has many characters in each cell. How to implement DataTip (in box format-not in the same line) Please help me. Thank you.
VIEWS ON THIS POST

25

Posted on:

Monday 22nd October 2012
View Replies!

How to set foucs to a cell of JTable

I am using JTextField as Component of table cell editor for the table.I want to set foucs to cell if the value of cell is > 1 .User is not allowed to do other functionality until he enters right value and till then foucs should be on that cell only. Please let me know if anyone has solution for it.
VIEWS ON THIS POST

41

Posted on:

Monday 22nd October 2012
View Replies!

Rotating an imageicon in JTable cells

i tried putting together something from what i found on the net, but i have an error in drawImage. What should i put for the parameters Image i cant cast my imageicon to an Image nor Graphics. please point out if there are any other parts which i did not do/did wrongly. thanks. class Mycellrender extends DefaultTableCellRenderer { ImageIcon test = new ImageIcon("test.JPG"); int selectcol = -1, selectrow = -1, cellwidth; public Component getTableCellRendererComponent(JTable jt,Object value,boolean isselected, boolean hasfocus,int row,int col) { super.getTableCellRendererComponent(jt,value,isselected,hasfocus,row,col); if (col == selectcol || row == selectrow || hasfocus == true) setBackground(Color.lightGray); else { setBackground(null); setBorder(BorderFactory.createLineBorder(Color.red)); //do image rotation here cellwidth = jt.getColumnModel().getTotalColumnWidth(); BufferedImage bim = new BufferedImage(cellwidth/5, cellwidth, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = (Graphics2D)(bim.createGraphics()); g2d.translate(cellwidth/5, 0); g2d.rotate(1.5708); g2d.drawImage(test, 0, 0, cellwidth, cellwidth/5, jt.getColumnModel()); setIcon(test); } return this; } public void setcol(int index) { if (selectcol == index) selectcol = -1; else selectcol = index; } public void setrow(int index) { if (selectrow == index) selectrow = -1; else selectrow = index; } }
VIEWS ON THIS POST

39

Posted on:

Monday 22nd October 2012
View Replies!

DND from one table cell to another in the same table

I've implemented dnd from a jlist to a jtable. Now I'd like to be able to drag from one cell in the table and drop into another cell in the same table. My issue is that all of the events (export and import) seem to be triggered as soon as the mouse button is pressed on a table cell, and then nothing happens when the mouse button is released over the new cell. Does anyone have experience in DND within the same JTable ms
VIEWS ON THIS POST

69

Posted on:

Tuesday 23rd October 2012
View Replies!