JTable getColumnName not working with numbered rows
you know when you read through the same code for a day and can't find the problem but someone who has never seen it before can find the problem in a second? i've got that going on right now.
I saw a thread, http://forum.java.sun.com/thread.jspa?forumID=57&threadID=639189 , where rows numbers are neatly added to a JTable by camickr, after I implemented this I can't get my data or ColumnHeaders to line up with the corrent columns. I have three columns, { Integer, Integer, JComboBox } it's kind of an old post but I was just wondering if any one else had run into the problem.
Also when I insert a new row { Integer, Integer, "Combo Option" } it is inserted into the table as { Integer, "Combo Option", Integer }, this isn't a real high priority but any help would be appreciated, thanks.
I tried to shorten this up as much as possible, sorry but it is still kind of big:
//Main class
import java.awt.*;
import java.awt.event.*;
public class TableProblem extends javax.swing.JFrame
BoreDataJTable table;
javax.swing.JScrollPane jsp;
public TableProblem()
BoreDataDefaultTableModel model = new BoreDataDefaultTableModel( 0, 3 );
table = new BoreDataJTable( model );
table.getTableHeader().setReorderingAllowed( false );
jsp = new javax.swing.JScrollPane( table );
jsp.setViewportView( table );
this.setContentPane( jsp );
public static void main(String args[])
System.out.println("Starting App");
TableProblem f = new TableProblem();
f.setSize(300,100);
f.show();
//JTable class
import javax.swing.*;
import javax.swing.table.*;
import java.awt.Component;
public class BoreDataJTable extends JTable
public BoreDataJTable( TableModel tm )
super( tm );
setAutoCreateColumnsFromModel( false );
setAutoscrolls( false );
addColumn( new TableColumn() );
getColumnModel().getColumn(0).setCellRenderer( this.getTableHeader().getDefaultRenderer() );
getColumnModel().getColumn(0).setPreferredWidth( 25 );
getColumnModel().getColumn(0).setCellEditor( null );
getColumnModel().getColumn(0).setResizable( false );
getColumnModel().getColumn(1).sizeWidthToFit();
getColumnModel().getColumn(2).sizeWidthToFit();
setPreferredScrollableViewportSize( getPreferredSize() );
initGroundColumn( this.getColumnModel().getColumn(3) );
public boolean isCellEditable(int row, int column)
if( column < 3 )
return false;
else
return true;
public Object getValueAt( int row, int col )
if( col == 0)
return new Integer( row + 1 );
else
DefaultTableModel model = ( ( DefaultTableModel )(
this.getModel() ) );
return model.getValueAt( row, col - 1 );
public void initGroundColumn( TableColumn groundColumn )
JComboBox comboBox = new JComboBox();
comboBox.addItem( "Select" );
comboBox.addItem( "Top Soil" );
comboBox.addItem( "Clay" );
comboBox.addItem( "Sand" );
comboBox.addItem( "Gravel" );
comboBox.addItem( "Pit Run" );
comboBox.addItem( "Sand Stone" );
comboBox.addItem( "Bed Rock" );
groundColumn.setCellEditor(new DefaultCellEditor(comboBox));
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setToolTipText("Select Ground Type");
groundColumn.setCellRenderer(renderer);
//DefaultTableModel class
import javax.swing.table.*;
import javax.swing.*;
public class BoreDataDefaultTableModel extends DefaultTableModel
private final Object[] emptyRow = { new Integer(0), new Integer(0), "Select" };
private final String[] colNames = { null, "Depth (cm)", "Angel (%)", "Ground" };
int cols;
int rows;
public BoreDataDefaultTableModel( int rows, int cols )
super( rows, cols );
this.rows = rows;
this.cols = cols;
addRow( emptyRow );
public String getColumnName( int col )
return colNames[col];
}The problem is that when the JComboBox is changed, it changes the value in the "Depth" to the the JComboBox's value, also it doesn't correctly display the ColumnHeader for the JComboBox's column
Similar Messages
-
Right shift key not working with middle row of letters
The right shift key on my Macbook Pro does not work with the middle row of letters. It works with all other letters and numbers, just not A-L. Nothing out of the ordinary happened, it just stopped capitalizing
Try resetting your SMC and PRAM.
Resetting the System Management Controller >>
If that does not work, test it using an external keyboard.
Dave M.
MacOSG Founder/Ambassador An Apple User Group iTunes: MacOSG Podcast
Macsimum News Associate Editor Creator of 'Mac611 - Mobile Mac Support' -
Shift keys not working with numbers
I wiped my Apple Wireless Keyboard yesterday with a damp cloth - like I've done for years - and now I'm not able to produce symbols anymore using either of the shift keys and the numbers 1-9 on the keyboard.
I would tend to think it's a hardware issue, but what puzzles me is that using keyboard viewer all of the buttons respond normally when pressed singularly. In other words, the all the number keys work correctly, and the shift keys work normally with other buttons, just not the numbers.
Any help would be much appreciated.I'm having this same exact issue. Anyone know of a fix? Is it possible junk in the keyboard?
I tested my keys using the keyboard viewer, and when I hit function it recognizes it, but it doesn't when it is loading. -
Itunes not working with Front Row
Hello.
I'm running Front Row (current version) along with the current version of itunes.
When I access my playlists in itunes it only allows me the choice of shuffeling the playlist. When I do select that I get a message saying "a problem has occured" and then Front Row will immediatly shut off.
How do I get Front Row to let me sleect any song in the playlist instead of only shuffeling it (i've already ensured sheffeling was turned off in itunes) and how do I fix that error message?
Thanks!Tom_CAN,
I have the exact same problem.
All of my software is up to date.
Any help from the community would be appreciated.
Thanks! -
Scripts not working in Numbers
Applications: OS X Yosemite 10.10.1 Script Editor 2.7 Numbers 3.5.2 Excel in Office for mac 2011
I write a simple script...
tell application "Numbers"
activate
open "Macintosh HD:users:xxx:desktop:testfile.numbers"
set the vale of cell "c4" to "23"
end tell
I am told... Numbers got an error: Can’t set cell "c4" to "23"
The script works fine if I use the Excel app and and Excel test file? It does not work with Numbers. I enabled Apple Script under security settings and can figure anything else to try.
Any ideas?!?
tell aYou tell Numbers to set a value for cell "C4" but cells don't belong directly to Numbers; a cell belongs to a table which belongs to a sheet which belongs to a document which belongs to Numbers.
So you have to do something like :
set value of (cell "C4" of table 1 of sheet 1 of document 1) to "23"
or:
set a_table to table "sometablename" of sheet "somesheetname" of front document
tell a_table
set the value of cell "c4" to "23"
end tell -
I bought Numbers because my Excel files would not work with Mavericks. How can I import a non-functioning Excel file into numbers? (As of now, the file NAME transfers but data does not.)
HI Dave,
I'm surprised you get no message when you attempt opening the Excel document in Numbers.
I'm assuming Numbers 3.1, since you are running Mavericks.
Does the Numbers file that opens show any content?
Does it contain a table?
How large?
Does it contain more than one tab (indicating more than one sheet)?
Do those other tabs contain a table?
Have you checked those tables for data content?
There have been cases in the past of imported documents opening with white text on a white background, giving the appearance of containing nothing. Check for this by selecting a block of cells, then applying a Fill colour or a Text colour using the Format button (paintbrush).
I'd also suggest attempting to open the Excel files using LibreOffice, which can be downloaded from the linked website.
Regards,
Barry -
PreparedStatement not working with Oracle
Hi All,
I am using preparedStatement in my JDBC code to fetch/insert values from oracle9i database.
I am checking condition like if a given record does not exist then insert it else update it.
First time it works when there is no row in database, however for subsequent run it's not able to return me the result though that row exist in database and this resulting in DuplicateKeyException becuase it try to create the row in db again.
The code is working fine for MySQL DB2 and SQLServer but doesn't work in case oracle 9i
Here is mycode
//problem is here 1st time it works next time it is not retunring true though record is there in DB.
if(isItemExist("1","CORP"))
updateItem("1","CORP","DESC1");
else
insertItem("1","CORP","DESC1");
public boolean isItemExist(String itemid, String storeid)
String FIND_SQL = "SELECT item_desc from item where item_id = ? and store_id = ? ";
c = utils.getConnection();
ps = c.prepareStatement();
int i = 1;
ps.setString(i++, storeid);
ps.setString(i++, itemid);
rs = ps.executeQuery();
if(rs.next()){
return true;
utils.close(c, ps, rs);
else{
return false;
utils.close(c, ps, rs);
public void createItem(String itemid, String storeid, String item_desc)
String INSERT_SQL = "INSERT INTO item(item_id,store_id,item_desc)values(?, ?, ?)";
c = utils.getConnection();
ps = c.prepareStatement();
int i = 1;
ps.setString(i++, itemid);
ps.setString(i++, storeid);
ps.setString(i++, item_desc);
ps.executeUpdate();
utils.close(c, ps, null);
public void updateItem(String itemid, String storeid, String item_desc)
String INSERT_SQL = "UPDATE item SET item_desc = ?, store_id=? WHERE item_id = ?";
c = utils.getConnection();
ps = c.prepareStatement();
int i = 1;
ps.setString(i++, item_desc);
ps.setString(i++, storeid);
ps.setString(i++, itemid);
ps.executeUpdate();
utils.close(c, ps, null);
Kindly suggest what's wrong with code. because same code works with other databse like SQL Server, MySQL but it is not working with oracle9i.if(isItemExist("1","CORP"))
updateItem("1","CORP","DESC1");
else
insertItem("1","CORP","DESC1");
String FIND_SQL = "SELECT item_desc from item where item_id = ? and store_id = ? ";
ps.setString(i++, storeid);
ps.setString(i++, itemid);
String INSERT_SQL = "INSERT INTO item(item_id,store_id,item_desc)values(?, ?, ?)";
ps.setString(i++, itemid);
ps.setString(i++, storeid);
ps.setString(i++, item_desc);
String INSERT_SQL = "UPDATE item SET item_desc = ?, store_id=? WHERE item_id = ?";
ps.setString(i++, item_desc);
ps.setString(i++, storeid);
ps.setString(i++, itemid);My first guess, looking at the above snippets, would be that the item_id field is a number and not a string and so you should be calling ps.setInt instead of ps.setString when setting that parameter.
This is only a guess, however, since you have not posted what the actual error is, which will probably give a hint to what the actual error is. -
My AX worked successfully with WPA security for several months, then stopped. I reset it, hard and soft, used factory default, but it would not work with WPA. Changed the security to WEP 128 and it worked fine. But now my Macbook Pro won't connect automatically. I have to run diagnostics to reconnect every time I started the computer.
Went back to WPA, now my Macbook Pro connects fine again, but the AX won't won't connect. Airport utility recognizes it when I reset it, but when I go thru the configuring process with Airport Utility, AX always fails on the last step, saying it could not join the network after it restarted.
Does this make any sense to anyone?Henry,
Thank you for explaining Duane's approach. Immensely helpful! And, of course, in retrospect, makes complete sense. I'm sure there is a kb article on this somewhere....... ?
Which brings me to something in your post:
"do a hard reset of the Airport Express and use the Airport Setup Assistant to reconfigure it from scratch"
Am I missing something here because after installing Leopard, Airport Utility is the only Airport app I have in my Utilities Folder? I do remember Airport Setup Assistant being part of Tiger (but that disappeared as did the functionality of several other Airport apps (Airport Admin, etc.) after upgrading to Leopard.
So, IS there an equivalent in Leopard of the Airport Setup Assistant? Or do I use the Network app in Sys Prefs to Join an already existing network (going the route of a hard reset of AX)?
Usually, David Pogue's MM book on OS X is helpful in filling in the gaps, but his new Leopard book seems a bit sketchy this time on setting up a wireless network. I think this subject (setting up a wireless network, etc.) could almost get a MM of it's own!
If I may, can I address a related issue? Previously, in setting up the AEBS and AX to work together you do end up with what LOOKS like TWO networks (both have their own Apple network numbers and letters) even though they are working in tandem as 1 network, right?
I bought the AX to extend the range of my network because it seemed the signal from the AEBS was not quite strong enough. I set it up to be a "remote" to the AEBS's "main." I also use the AX to stream iTunes to my living room's sound system.
Again, many thanks for your help.
Message was edited by: WildBill -
Debit/Credit Shift not working with report painter
Dears,
We have defined debit/credit shift while defining financial
statement version. This functionality working well with F.01 however its not
working with report painter results. any help will be highly appreciated
Regards,
FRHi Dave,
I have gone back to the books (JP Terry's "Creating Dynamic Forms with Adobe LiveCycle Designer") and think we can improve on things...
var oFields = xfa.resolveNodes("ViolationsText[*].DebitVal"); // looks to resolve the repeating rows (I think)
var nNodesLength = oFields.length; // assigns the number of rows to a variable
var sumTotal = 0; // this is a temporary holding variable for the total, during the loop
for (var i = 0; i < nNodesLength; i++) // this loops through as previous example
if (oFields.ViolationsText[i].resolveNode("DebitVal").rawValue == "C")
sumTotal = "";
i = nNodesLength; // stops the loop
else
sumTotal += oFields.ViolationsText[i].resolveNode("DebitVal").rawValue;
this.rawValue = sumTotal;
This would go in the calculate event of your Total Debit Points field. I would be amazed if it worked first time. I haven't run through LC. Give it a lash!! (a try!!)
Good luck,
Niall -
Hi, The Airport Express does not work with iOS 7.0.4, I appreciate your help to resolve this event. Thank you,
Please locate the model number of the AirPort Express and post back that information.
The model number is located on the side of the AirPort Express. It begins with an "A" followed by four numbers.
We are not sure what you mean by "does not work". Does this mean that the AirPort Express worked at one time and has just recently stopped working?
Have you installed a newer operating system on your iOS device recently?
Or, is this a new AirPort Express that you are trying to configure for the first time?
If yes, what service will the AirPort Express perform on your network?
Please remember that we cannot see your network, so we only know as much about your problem as you can tell us. -
Why does my printer HP 3080 not work with Mac OS X VERSION 10.7.5
Why does my printer HP 3080 not work with Mac OS X VERSION 10.7.5. Am I missing a driver? If so where do I go to download it? thanks
What's the full model number and name of the printer? I can't seem to find any HP printer with the numbers 3080 in the model number.
How are you connecting the printer to the Mac?
I am a printer tech for HP. -
EPrint does not work with Google Apps for Business (hosted email)
I have looked up numerous posts, from back into 2011 even, and HP still has not resolved this.
HP's ePrint does not work with companies using Google Apps for Business (hosted email).
Our emails come from our domain, but from the servers/DNS of Google, so we wind up getting
the "550 5.7.1 Command Rehected" error.
This is a major issue as more and more companies (especially small business owners) are moving away
from having in-house/Exchange servers, and they are moving toward hosted systems.
You really need to find a way to stop rejecting emails coming from Google Apps hosted email.
It's been around 4 years now (looking at previous posts). Why hasn't HP found a resolution to this yet?I have brought your issue to the attention of an appropriate team within HP.
They will likely request information from you in order to look up your case details or product serial number.
Please look for a private message from an identified HP contact.
Additionally, keep in mind not to publicly post serial numbers and case details.
If you are unfamiliar with how the Forum's private message capability works, this post has instructions.
Aardvark1
I work on behalf of HP
Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping! -
HP ProBook 5220m Fan not working with battery power but work fine with adapter plugged in
Hi,
Any one have this issue?
HP ProBook 5220m (Bios Version F50) Fan not working with battery power but work fine with adapter plugged in.
This issue was found in my replacement motherboard. the original mother do not have this issue.
The origianl mother to be replace is due to can't power on after a power failure recovery. I believe was due to power surge killed the motherboard's power controller circuitry.
Appreciate any one can provide clue for resolving the problem.
I have tried to install speedfan to try my luck, but it can't any fan in the application to configure. (Bios Version F50)@wheng
Thank you for using HP Support Forum. I have brought your issue to the appropriate team within HP. They will likely request information from you in order to look up your case details or product serial number. Please look for a private message from an identified HP contact. Additionally, keep in mind not to publicly post ( serial numbers and case details).
If you are unfamiliar with the Forum's private messaging please click here to learn more.
Thank you,
Omar
I Work for HP -
HT6154 paired Jawbone not working with iphone 5C
Paired Jawbone is not working with iphone 5C
Hello Diesel vdub
When an incoming call happens I press the talk button on the jawbone and there's no reception.
So, I speak on the iphone.
Today the jawbone worked correctly twice in a row, woo hoo.
Finicky little puppy.
Thanks for your response DVdub. -
Apple remote contra not working with Lion
I installed Lion and my littele apple remote control does not work anymore with my mac book pro.
Is there any solution for that?
ThanksIt's not working for me either.
I know that Lion doesn't include Front Row, but the remote is not working with any other application (ex. iTunes).
Please somebody help us!
Maybe you are looking for
-
When I click on pic, gray square comes up with an exclamation point
My friend got on my computer and uploaded pics from my camera. I don't know what she did, but the pic I want is in the library as a thumbnail, so it looks like its there. But when i click it to edit it or make it larger, instead of the pics coming up
-
How to find the list of Queries for that have statistics enabled in the sys
Hi , How to find the list of Queries that have statistics enabled on them in the system. Please help me in this regard Thanks Maruthi
-
Problem in web.xml -- servletcontext
Pls look at the code and web.xml file for invoking servlet. index.html <html> <head> <title>Servlet Context Example</title> </head> <body> <form method="get" action="callservlet"> <input type="submit" value="Submit"> </form> </body> </html>ServletCon
-
Flash builder 4 html component
Hi, I have a html loader ( <mx:HTML... ) on my air app developed with flash builder 4 and I have a problem.The links that have the target="_blank" attribute can't be opened (when I ckicl a such link nothing happens). I want them to be opened in a new
-
PS CS6 extended on osx mountain lion?
what are the problems to be aware of when installing p.s. cs6 on mac osx mountain lion?