How to when press the button and can change the value in the table?
this is my code so far with a table and a button..how can i make it when press the button and the data in table change..
* SimpleTableDemo.java is a 1.4 application that requires no other files.
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class SimpleTableDemo extends JPanel {
private boolean DEBUG = false;
private JPanel button;
private JButton enter;
public SimpleTableDemo() {
super(new BorderLayout());
//button.setBackground(Color.pink);
//setForeground(Color.pink);
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
Object[][] data = {
{"Mary", "Campione",
"Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml",
"Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath",
"Knitting", new Integer(2), new Boolean(false)},
{"Sharon", "Zakhour",
"Speed reading", new Integer(20), new Boolean(true)},
{"Philip", "Milne",
"Pool", new Integer(10), new Boolean(false)}
final JTable table = new JTable(data, columnNames);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
if (DEBUG) {
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
printDebugData(table);
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
enter = new JButton("Press me");
//Add the scroll pane to this panel.
buildButton();
add(scrollPane, BorderLayout.NORTH);
add(button, BorderLayout.CENTER);
private void buildButton(){
button = new JPanel();
button.add(enter);
private void printDebugData(JTable table) {
int numRows = table.getRowCount();
int numCols = table.getColumnCount();
javax.swing.table.TableModel model = table.getModel();
System.out.println("Value of data: ");
for (int i=0; i < numRows; i++) {
System.out.print(" row " + i + ":");
for (int j=0; j < numCols; j++) {
System.out.print(" " + model.getValueAt(i, j));
System.out.println();
System.out.println("--------------------------");
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame frame = new JFrame("SimpleTableDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
SimpleTableDemo newContentPane = new SimpleTableDemo();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
Cross-post:
http://forum.java.sun.com/thread.jspa?threadID=676105
Similar Messages
-
my iphone 4s doesnt have the slide option to turn on mirror on apple tv...after ive double clicked the button and scrolled left twice, i see the symbol and click into it but theres no mirror option??
is the latests ios version installed?
if so then are you 100% sure you have an iphone4s because if you have an iphone4 it would be absent because Iphone4 don't support it
mind you iphone4 are still being sold -
I keep getting a screen that says "Unable to Download" [song] with two choices - "done" or "try again". I have tried both and can't get rid of the screen ( and don't want the song which I never ordered to begin with. Ideas on getting rid of the screen??
Purplehiddledog wrote:
I do backup with iCloud. I can't wait until the new iMac is available so that I can once again have my files in more than 1 location without needing to rely solely on the cloud.
I also rely on iTunes and my MacBook and Time Machine as well as backing up to iCloud. I know many users know have gone totally PC free, but I chose to use iCloud merely as my third backup.
I assume that the restore would result in my ability to open Pages and Numbers and fix the problem with deleting apps, but this would also mean that if my Numbers documents still exist solely within the app and are just not on iCloud for some reason that they would be gone forever. Is that right?
In a word, yes. In a little more detail.... When you restore from an iCloud backup, you must erase the device and start all over again. There is no other way to access the backup in iCloud without erasing the device. Consequently, you are starting all over again. Therefore, it would also be my assumption that Pages and Numbers will work again and that the deleting apps issues would be fixed as well.
If the documents are not in the backup, and you do not have a backup elsewhere, the documents could be gone forever. -
Recently unable to open Pages or any documents therein. It seems to be stuck in the Cloud. Although I can open a list of the documents I can not open any of the documents.
The answer is simple... If you want to remedy this, then don't save them as PDFs.
Word opens Word and text documents. Not PDFs.
Also note that this forum is for troubleshooting Apple Software Update for Windows, a software package for Windows designed to update Apple products that run on Windows, and not related to Microsoft Office or your question in any way. If you have issues or questions about Office, it's probably best you post Office related questions on Microsoft's own forums for their Mac products.
http://www.officeformac.com/productforums -
I have a uk iTunes account but have moved to the Netherlands and can no longer connect or make purchases. Do I need to change my account to a Dutch one?
You can't transfer any content from one account to another account (nor can accounts be merged) - all content will remain tied to the account that downloaded it.
Do you not have copies of all of your downloads e.g. on your computer or backup of your downloads/library ? Whilst you are in Australia you can't redownload your UK purchases (you have to be in a country to use its store), if you have them on your computer's iTunes library then you should be able to stream them from it to your Apple TV -
Can anyone tell me why when I type a very long email, the send button is not highlighted anymore when I am done and I can't send the message? And I can't seem to save the message or anything and as soon as I touch a button, I lose the whole thing. Any suggestions?
Have you tried typing and saving using Notes or word processing Apps before sending message?
-
I have been dealing with this problem about a week. I have turned the computer completely off at night, but it does not correct the situation . I cannot print anything off the internet as long as the fax message is on there. I do not have a fax machine and do not want one.
What is that fax message '''on'''? <br />Hard to understand how that is a Firefox support issue as Firefox doesn't have any fax capabilities.
Perchance, do you have an all-in-one printer which can receive a fax message? Printer, scanner, and fax machine combined.<br />
If so, try looking at your user manual for that all-in-one to learn how to print that message. Or consult with a support forum for that brand all-in-one printer.
Or maybe your problem is with the Windows 7 Fax and Scan feature? <br />
http://windows.microsoft.com/en-us/windows/faxing-faq#1TC=windows-7 -
White screen when pressing home button and getting text
Strange thing, hopefully software bug. I press the home button to check time and all that shows is a white screen. It's not the white screen of death because I can simply press the sleep button and then go straight back to what I was doing, pressing home button, etc. and it's fine. I've even taken a screen shot of it with iPhone. All that appears is my true wallpaper, as if it didn't know it wasn't already showing it. Also, it's very random. I can't reproduce. It's pretty minor as I can quickly getout of it but I want it clean.
I've restored, restored as new, reset, turned on/off, everything I can think of. Any ideas?
I also have the speaker distortion bug many are talking about (blown speaker sound).
I have a genius bar appointment Sunday so I'm curious what they say.I suggest going through the usual troubleshooting steps:
1. Reset the phone by pressing both home and sleep/wake buttons until the Apple logo appears (ignore red slider).
2. Setting > General > Reset > Reset All Settings
3. Restore in iTunes using a backup.
4. Restore as a new iPhone
5. Take it to the Genius Bar. -
If i create a new alias in my iCloud account, and forgot the password and I can´t actually have open the account in any of the devices, how can I recover my password?
Welcome to the Apple Community.
iForgot.com -
How to use the substring and can i class method for the primitive type
MY COMPILER
public class StringLine
public static void main(String[] args)
String sentence;
char letter;
char name;
int position;
System.out.println("Enter a line of text. No punctuation please");
sentence = MyIO.readLine();
System.out.println("I have rephrase that line to read:");
position = sentence.indexOf(" ");
name = sentence.charAt(postion, position+ 1);
name = name.toUpperCase();
letter = sentence.charAt(0);
letter = letter.toLowerCase();
sentence = name + sentence.substring(position + 2)
+ letter + sentence.substring(1, position);
//////////////// I got 3 errors following:
StringLine.java:16: cannot resolve symbol
symbol : variable postion
location: class StringLine
name = sentence.charAt(postion, position+ 1);
^
StringLine.java:17: char cannot be dereferenced
name = name.toUpperCase();
^
StringLine.java:20: char cannot be dereferenced
letter = letter.toLowerCase();
^
3 errors
}position = sentence.indexOf(" ");
name = sentence.charAt(postion, position+ 1);
name = name.toUpperCase(); two error here:
1. as stated above postion is mispelled...should be position
2. you cannot perform a chatAT(int, int)
I think you want to perform a substring
String name; // should be a string instead of a char..(char is a primitive and all primitive have no method)
position = sentence.indexOf(" ");
name = sentence.substring(position, position + 1).toUpperCase();
[./code]
better yet..you should check if the sentence does contain a spaceString name;
position = sentence.indexOf(" "); // return a negative value if the search string is not part of the string
if (position != -1)
name = sentence.substring(position, position + 1).toUpperCase();
else
System.out.println("The sentence does not contain a space);
[./code]
String letter;
letter = new String(sentence.charAt(0));
letter = letter.toLowerCase();
// or
char letter;
letter = sentence.toLowercase().charAt(0); -
Gift card will not get off my ipad mini and can't do updates
maryfromedina wrote:
I would like to buy some music and transfer to my Ipod. There is no easy way to do it.
Yes, it is very easy.
Purchase the song then sync the iPod.
A couple of weeks ago I talked to a tech for 15 min and he got me on.I used to be able to bring up my music, purchase new songs, transfer to Ipod and share with my laptop. Can't do it anymore without calling support.
Why cant you? Do it the same way as when you are on the phone with support.
Do you get any messages? What are they?
When do you see these messages?
when downloading?
when syncing? -
I've tried rewplacing .plst files, reinstalling the 10.5 and running 10.5.8 combo updates, gone line by line thru user prefs comparing to my working laptop using the same software, but nothing works. What I have noticed is that on my working OS10.5.8 on my MacBookPro the Dock.plst file gets updated everytime I restart. Something is broken in the ability for my MACPRO tower to write to the .plst and .db files associated with screen settings such as what folders are left open at closedown and any changes to the dock. I completly reinstalled 10.5.4 OS from the cd saving my user info because I have a lot of music software on here that I seem to be losing through all this, but the reinstall did not fix this problem. It just took a long time to get everything back to 10.5.8. The .plst files are in there from last month or last week and the just don't update. I replaced them in a test from my working laptop and they make everything look llke the laptop dock but then when I change them they don't save. Where is the app that saves these changes to the dock and desktop? If I knew I could see if that script/app etc would look like my laptop. Line by line I've tried to compare in all system and library folders, cashes preferences, but I can't seem to find it. Anyone here deep enough into this software to help me. I would be so very grateful... very... P.S.the dock reverts to an old setting and the screen looks like it did when I shut down about 3 weeks ago. Nothing I do is saved on these parts of the mac. I've redone permissions etc...
steveno change....
I even went to the other user name I just set up where things work and put all the dock system etc and desktop .db & .plst files into the main user name where I'm having the problems and it opens upon restart looking like the other users settings, but when I make a change in views or dock or windows open on desktop they do not get saved when I restart. It's frozen as the one I put in there. I need to know what part op the OS writes to these .plst and .db settings so I can replace it or parts it needs to do this. It might be another part of the user Preferences as it only happens in my older user name. But that name has so many plug ins and apps tied to it, it would be insane to try to change all that...... maybe I can drag my older preference folder to a new user and see what happens..... -
It means that I am unable to read all the information being displayed,such as my email,I cannot log onto it with the password as it is off the screen where the whole page as moved to the right of the,it appears to stretched.
This issue can be caused by the Babylon Toolbar 1.1.8 extension
See:
*https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes -
My i pad hang on with information of icloud back up with informtion of "this ipad hasn't been backed up in three weeks. backups happen when this pad is plugged in, locked and connected to wifi" and doesn't close when press ok button and still hangon. I am not able to switched off also. How to remove popoup note and entering into ipad applications.
Hold down the sleep and home keys for about 20 seconds or so and see if it reboots.
-
how do I get data off my phone? when I plug phone into the wall and hold down the button i can get into photos and messages etc but when I plug into laptop it goes to recovery mode........therefore the data is not yet wiped? HELP! I got married last week on holidays and have not had a chance to save photos yet.
Hello there stidhambr15,
I was researching the issue you are having and recommend a couple of things. First it might be a good idea to reset the device following iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting found here http://support.apple.com/kb/ht1430
Resetting your device
Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears.
If that doesn't quite get the device going again, I recommend restoring the device.
iTunes: Restoring iOS software
http://support.apple.com/kb/ht1414
Might even be a good idea to turn off the phone, reseat the SIM card, and turn it back on.
iPhone and iPad: How to remove the SIM card
http://support.apple.com/kb/ht5163
iPhone 4 (GSM model)
iPhone 4S
Cheers,
Sterling
Maybe you are looking for
-
Hi All, I want to be able to create bilingual messages (English& Russian)on my Torch (SMS, emails etc) but there is no Russian in the list of additional input languages. Amongst supported languages there are Catala, Greek, Czech etc so I don't see wh
-
Hi, has anyone have the problem that you haven't done anything with you macbook pro but its operating system is running in dos environment?
-
Reg : internal table & Perform statement
hi all i have 3 internal tables , * in first internal table i have mark-1 ,* * in 2nd internal table i have mark-2 ,* * using "PERFORM" i have to add mark 1 & mark 2* * and i need to display the total in 3rd internal table.* *
-
I have a Mac os x 10.7.5, i can't download anything at all.
I have a Mac os x 10.7.5, i can't download anything. I deleted unused files, emptied trash. Restart, googled. Still, nothing works. I tried downloading Adobe Acrobat Reader free new version. Contacted Adobe, they can't help with free version apps. He
-
Rdesktop version and 2k8 Session Broker
Has anyone had success utilizing Sun Ray with Server 2k8 TS Session Broker load balancing. If not, what is everyone using to load balance TS connections? Thanks!