Having trouble getting objects on panel
i am just attempting to build a simple gui frame and am having some trouble getting my labels to appear. here is what I have for the panel that the labels and buttons will be on. everything shows up no problem except clearButton and welcome2. Any suggestions would be greatly appreciated...thanks in advance
class CountClicks2Panel extends JPanel
constructs a count-clicks-1 panel instance
public CountClicks2Panel()
// button has not been clicked yet
this.numClicks = 0;
// create the labels and buttons for this panel
JLabel welcome = new JLabel("Button-Click Counter");
welcome.setForeground(Color.BLUE);
JLabel welcome2 = new JLabel("Jared Letendre");
welcome2.setForeground(Color.RED);
JButton clickMe = new JButton("Click Me");
clickMe.setForeground(Color.BLUE);
clickMe.setBackground(Color.RED);
JButton clearButton = new JButton("Clear Count");
clearButton.setForeground(Color.BLUE);
clearButton.setBackground(Color.RED);
showNumClicks = new JLabel("# of clicks: " +
this.numClicks);
// add labels and button to this panel
this.add(welcome);
this.add(clickMe);
this.add(showNumClicks);
this.add(welcome2);
this.add(clearButton);
// create button action (so clicks will be counted),
// and associate that action with clickMe button
CountClicks2Action countAction = new CountClicks2Action();
CountClicks2Action clearAction = new CountClicks2Action();
clearButton.addActionListener(clearAction);
clickMe.addActionListener(countAction);
} // end CountClicks2Panel
Sorry about that...i put it in code blocks originally but it didnt show when i previewed it...anyway here is the complete code. thanks for helping out
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
A GUI application with a button for which the number
of clicks is kept track of and displayed
@author Sharon Tuttle
@version 09-10-07
public class CountClicks2Test
creates a CountClicks1 frame
@param args not used here
public static void main(String args[])
CountClicks2Frame mainFrame = new CountClicks2Frame();
mainFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
mainFrame.setVisible(true);
A frame with a panel containing two labels and a button
class CountClicks2Frame extends JFrame
constructs a count-clicks-1 frame instance
public CountClicks2Frame()
this.setTitle("Button-click Counter");
this.setSize(this.DEFAULT_WIDTH, this.DEFAULT_HEIGHT);
// add count-clicks-1 panel to frame
CountClicks1Panel panel = new CountClicks1Panel();
this.add(panel);
// data fields
private final static int DEFAULT_WIDTH = 150;
private final static int DEFAULT_HEIGHT = 200;
A panel with two labels and a button, that displays how many times
the button has been clicked
class CountClicks2Panel extends JPanel
constructs a count-clicks-1 panel instance
public CountClicks2Panel()
// button has not been clicked yet
this.numClicks = 0;
// create the labels and buttons for this panel
JLabel welcome = new JLabel("Button-Click Counter");
welcome.setForeground(Color.BLUE);
JLabel welcome2 = new JLabel("Jared Letendre");
welcome2.setForeground(Color.RED);
JButton clickMe = new JButton("Click Me");
clickMe.setForeground(Color.BLUE);
clickMe.setBackground(Color.RED);
JButton clearButton = new JButton("Clear Count");
clearButton.setForeground(Color.BLUE);
clearButton.setBackground(Color.RED);
showNumClicks = new JLabel("# of clicks: " +
this.numClicks);
// add labels and button to this panel
this.add(welcome);
this.add(clickMe);
this.add(showNumClicks);
this.add(welcome2);
this.add(clearButton);
// create button action (so clicks will be counted),
// and associate that action with clickMe button
CountClicks2Action countAction = new CountClicks2Action();
CountClicks2Action clearAction = new CountClicks2Action();
clearButton.addActionListener(clearAction);
clickMe.addActionListener(countAction);
} // end CountClicks2Panel constructor
An action listener that counts the number of times the
clickMe button has been clicked
private class CountClicks2Action implements ActionListener
// default constructor will suffice, in this case
increases and displays the number of clicks of this
button
public void actionPerformed(ActionEvent event)
CountClicks2Panel.this.numClicks++;
CountClicks2Panel.this.showNumClicks.setText(
"# of clicks: "
+ CountClicks2Panel.this.numClicks);
public void actionPerformed2(ActionEvent event2)
CountClicks2Panel.this.numClicks = 0;
CountClicks2Panel.this.showNumClicks.setText(
"# of clicks: "
+ CountClicks2Panel.this.numClicks);
// data fields for CountClicks1Panel
private int numClicks;
private JLabel showNumClicks;
} // end of class CountClicks1Panel
Similar Messages
-
Having trouble getting a second panel to display
My current project in java involves creating 2 JFrames. One frame to accept information from the user, and another frame to display the answer. I can't get the 2nd from to work properly without a ton of errors. After trimming out some of the code for the 2nd jframe, I've managed to get everything to compile, but the 2nd frame is only displaying the last panel out of 4. I've tried fooling around with the code I cut out, but everything I add creates an error. Any help would be greatly appreciated.
import javax.swing.JFrame;
public class BMI
public static void main (String[] args)
JFrame frame = new JFrame ("Enter Data");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
BMIPanel panel = new BMIPanel();
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.Float;
public class BMIPanel extends JPanel
private JButton computebutton;
private JTextField nametext, feettext, inchestext, weighttext;
public BMIPanel()
computebutton = new JButton ("Compute");
computebutton.addActionListener (new BMIListiner());
nametext = new JTextField (20);
feettext = new JTextField ("Feet", 6);
inchestext = new JTextField ("Inches", 6);
weighttext = new JTextField ("Pounds", 6);
JPanel namepanel = new JPanel();
JPanel heightpanel = new JPanel();
JPanel weightpanel = new JPanel();
JPanel buttonPanel = new JPanel();
namepanel.add (new JLabel ("Your Name: "));
namepanel.add (nametext);
heightpanel.add (new JLabel ("Your Height: "));
heightpanel.add (feettext);
heightpanel.add (inchestext);
weightpanel.add (new JLabel ("Your Weight: "));
weightpanel.add (weighttext);
buttonPanel.add (computebutton);
setLayout (new BoxLayout (this , BoxLayout.Y_AXIS));
add(namepanel);
add(heightpanel);
add(weightpanel);
add(buttonPanel);
private class BMIListiner implements ActionListener
public void actionPerformed (ActionEvent event)
JFrame BMIframe = new JFrame ("Results");
BMIframe.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
float tempinches;
float BMIndex;
String namestring = nametext.getText();
String feetstring = feettext.getText();
String inchesstring = inchestext.getText();
String weightstring = weighttext.getText();
float feetfloat = Float.parseFloat (feetstring);
float inchesfloat = Float.parseFloat (inchesstring);
float weightfloat = Float.parseFloat (weightstring);
tempinches = feetfloat * 12 + inchesfloat;
BMIndex = (weightfloat/(tempinches * tempinches)) * 703;
String BMIstring = "" + BMIndex;
JPanel namepan = new JPanel();
JPanel heightpan = new JPanel();
JPanel weightpan = new JPanel();
JPanel BMIpan = new JPanel();
namepan.add (new JLabel ("Your Name: "));
namepan.add (new JLabel (namestring));
heightpan.add (new JLabel ("Your Height: "));
heightpan.add (new JLabel (feetstring));
heightpan.add (new JLabel (inchesstring));
weightpan.add (new JLabel ("Your Weight: "));
weightpan.add (new JLabel (weightstring));
BMIpan.add (new JLabel ("Your BMI: "));
BMIpan.add (new JLabel (BMIstring));
BMIframe.add(namepan);
BMIframe.add(heightpan);
BMIframe.add(weightpan);
BMIframe.add(BMIpan);
BMIframe.setVisible(true);
}I'm fairly sure this has something to do with the
frame.getContentPane().add(panel);
rame.pack();stuff, but after playing around with it for an hour I can't seem to get the thing to compile. I've tried putting the code in the main program and inside the action listener with no success.Yes, but you need to use a suitable LayoutManager for the JFrame too (for the JFrame's contentpane, to be more precise). Your code worked fine when I modified your actionPerformed method like so:
// Set the frame's LayoutManager:
BMIframe.setLayout( new GridLayout(4, 1) );
BMIframe.add(namepan);
BMIframe.add(heightpan);
BMIframe.add(weightpan);
BMIframe.add(BMIpan);
// Call pack on the frame to make it its preferred size
BMIframe.pack();
BMIframe.setVisible(true); -
I've got the labview vi written to read my IMU data from a serial port in COM1 and it displays onto the table on the front panel. I'm having trouble getting this data onto an excel spreadsheet. Any ideas? Right now my data will collect one reading instead of continuously reading my IMU which displays data in a continuous stream.
Thanks
Attachments:
Read_IMU_Drew.vi 21 KBHi
Your vi is in 2009 version, which i am unable to open in 8.6
However, if you want your data to be saved in excel sheet, here is the VI
Somil Gautam
Think Weird
Attachments:
save to excel.vi 12 KB -
TS1424 I am having trouble getting Itunes to open
I am having trouble getting ITUNES to work I have deleted itunes and everything associated with it and reinstalled and I still get the same errors,
The application has failed to start because of MSVCR80.DLL
INTUNES WAS NOT INSTALLED CORRECTLY ERROR 7
THIS APPLICATION FAILED TO START BECAUSE ICUDT49.DLL WAS NOT FOUNDGo to Control Panel > Add or Remove Programs (Win XP) or Programs and Features (later)
Remove all of these items in the following order:
iTunes
Apple Software Update
Apple Mobile Device Support (if this won't uninstall move on to the next item)
Bonjour
Apple Application Support
Reboot, download iTunes, then reinstall, either using an account with administrative rights, or right-clicking the downloaded installer and selecting Run as Administrator.
The uninstall and reinstall process will preserve your iTunes library and settings, but ideally you would back up the library and your other important personal documents and data on a regular basis. See this user tip for a suggested technique.
Please note:
Some users may need to follow all the steps in whichever of the following support documents applies to their system. These include some additional manual file and folder deletions not mentioned above.
HT1925: Removing and Reinstalling iTunes for Windows XP
HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8
tt2 -
SoundBlaster X-Fi Surround 5.1 - Having Trouble Getting all of my 5.1 to work
MSoundBlaster X-Fi Surround 5. - Having Trouble Getting all of my 5. to work?Hi Everyone,
This has been an on and off problem for me since I've purchased my X-Fi: I can only get certain speakers to work at a single time. As you know, in 5. there are the three /8 inch heads: green, black and orange. All of the heads, when plugged into the green slot (I am using the cable that converts the green head into the red and white inputs, not the green headphones input) on the X-Fi work. I take this to mean that all of the speakers do in fact work and that the problem lies within the device/drivers. I have looked high and low through windows and the creative control panels and changed all of the speaker settings to 5.. Maybe I am overlooking something.
I am using Windows 7 32-bit. I have tried both versions of the driver that are available via Creative's website.
Any help would greatly be appreciated.
Sincerely,
Dave@Re: SoundBlaster X-Fi Surround 5. & SPDIF - it's despairingA Ok - Problem fixed. Again I am using a XP 32bit, latest driver.
I have disabled all the features (cmss, 3d, etc) and used the provided creative player and powerdvd player. Both work FINALLY right. I can listen to .ac3 5. music track and the SPDIF as a pure passthrough is sending 5. output to my Bose receiver. Same for the DVD sound.
Note when I used the VLC player the SPDIF still did not work right ... but since it does with the creative player I am good with it.
Once you activate any of the feature then the sound if brought down to a 2.0 (stereo) sound.
In my driver I do not have an option to disable the analog output - I assume that is different then the Vista one.
One other question. I have tested the card with Shure SE530 headset and the output is TERRIBLE - does it work fine for you with headset? (I am planning to use it only as SPDIF so no biggy but I was surprised on the poor quality. Those headset are amplified and filtered so there could be some issue with that). -
I'm now having trouble getting mac mail to work on my mac. The mobile me account works great on iphone and ipad but it won't connect to my mail account. Password is correct. What else can I do? Using OS10.68
HI,
The Apple IDs from @mac.com and @me.com (Older MobileMe and more recent iCloud Names) are also Valid AIM Screen names.
Any other sort of Apple ID is not a Valid AIM Name.
A Google ID that is associated with Google Mail Account (And has "Talk" enable on your Google Settings) can be used in iChat as Jabber Name/ID. (Google Run Jabber server).
Jabber and AIM are different IM Services and it is not easy or straight forward to add Buddies from one Service to the Buddy List of another. (As A Starting point consider it "impossible")
iChat 4 and 5 have links to the registration page of @Mac.com here with a "Get an iChat Account" button in the add (Account) screen (You select @mac.com or MobileMe and then press the Button - Choosing AIM and then pressing the button used to lead to the AIM registration page but AIM moved their page).
Apple IDs can be any valid email (or an @mac.com or iCloud registration)
Therefore you could make a Google ID into an Apple ID.
However this will not be a valid AIM Screen Name the way @mac.com or MobileMe/iCloud ones are.
Valid AIM Screen Names in Table (pic)
7:46 PM Monday; December 5, 2011
Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
iMac 2.5Ghz 5i 2011 (Lion 10.7.2)
G4/1GhzDual MDD (Leopard 10.5.8)
MacBookPro 2Gb (Snow Leopard 10.6.8)
Mac OS X (10.6.8),
"Limit the Logs to the Bits above Binary Images." No, Seriously -
Hi, I am having trouble getting an album to download. I have tried it on both my iPhone and laptop through iTunes but neither works. I am wondering if it could be the size of the album stopping it downloading (212 Tracks) Any Ideas?
These alerts occur due to timeouts or conflicts trying to write a file during download.
If you encounter this issue while while downloading something from the iTunes Store:
Delete your iTunes Downloads folder, located in:
Mac OS X: ~/Music/iTunes/iTunes Media/Downloads Note: "iTunes Media" may appear as "iTunes Music. Also, the tilde (~) refers to your Home directory.
After locating your iTunes Downloads folder:
Quit iTunes.
Delete the Downloads folder on your computer.
Open iTunes.
Choose Store > Check for Available Downloads.
Enter your account name and password.
Also review this support aticle as it might be causing due to internet connection: http://support.apple.com/kb/ts1368
Hope this helps. -
I am having trouble getting my My Mac Book Pro 15" Retina to wake up with an Apple Bluetooth Keyboard and Mouse while Docked in a Hengedock vertical docking station. The Keyboard and mouse work great with the laptop lid open but when closed in the docking station the bluetooth signal does not seem to transmit. Is there a setting that can be changed to allow an Bluetooth keyboard and mouse to wake the computer while docked?
Please read this whole message before doing anything.
This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a Fusion Drive or a software RAID, you can’t do this. Ask for further instructions.
Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal startup may also be somewhat slow.
The login screen appears even if you usually login automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
Test while in safe mode. Same problem?
After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of the test. -
I have an older IPOD classic that I'm having trouble getting new purchases from library to IPOD. I use to have a IPOD icon in the source list on the left side of the screen. Now that is all gone. My purchases are coming up as recently purchased but can't figure out how to get them transferred to IPOD. I also can't find how to confirm setting is for manual not auto sync as the first computer I had blew up and am now using a different one. I haven't had any of these problems prior to the updates.
G'day Mate,
As an avid flight simmer I bought a new soundcard my previous was
an audigy 2 platinum ex with an external module I really liked but somehow all of a sudden I was getting a screech when using FS9 sor I opted to change to the present. Well stone the crows my soundcard was auto updated with new drivers and well you guessed it the soundcard did not show in the sound video controllers window No I have just joined this forum and it looks like3 you may have the answer for me . I am now going to do as you suggest and see what happens.
I shall return with the outcome of my dilemma.
Many thanks for your sound advice ( pardon the pun)
Pat
Ret'd Viet Vet -
Im having trouble getting my macbook pro to boot up after a fail safe boot, im getting as far as the grey screen with the apple loggo. so im trying to run a disk repair but is saying the disk is locked, how do i unlock disk??
Some clarification may help.
You say you cannot boot normally. It shows a gray screen with the Apple logo.
Did you say it will boot successfully in Safe Mode (boot, then hold down the Shift key)?
How did you boot the machine to run Disk Utility? (Which keyboard combinations)? -
I have been having trouble getting my email on my iPad2.
It started when I brought it to the US on vacation (I live in London and my email provider is Virgin Media). It worked once since I returned, but that is it.
I can send emails, but can't get them.
Any ideas, people?Hi Kharels
Just posted this reply to 2 others with same sort of question:
I have the same issue as i have my own email address and only want to use.
There are two ways around this annoying problem. The first is to set up your own domain email account alongside your iCloud one, and when you go to send each email tap on From and you get a choice of emails addresses to reply from... ie your own domain or the iCloud one. This is tedious though.
The other is to set up your iCloud email as normal, then create a new one altogether. Choose 'Other' when creating this new account. Then put for the incoming server mail.me.com, along with your user name and password. For the outgoing server put the server you want to use - ie your own domain one. This is therefore a hybrid account and does work.
Now switch off the email for iCloud (leaving on Calendar, Address Book etc). Switch on the email for your hybrid account (which of course is iCloud incoming as well).
Providing you have directed your own domain email address to your me.com one, you will find the iPhone should behave itself and you can use the folders etc and these will synch with your Mac ok.
Hope this work for you - let us know.
Simon -
Hi,
One of my user was unable to receive email from her desktop outlook, browser and her phone. On her outlook, the status of her exchange is disconnected. Then when she tried to access her OWA, this error prompted below "
"Something went wrong. We're having trouble getting to your mailbox right now. Please refresh the page or try again later. If the problem continues, please contact your helpdesk."
Her emails started coming in again after about 45minutes later. It happened twice today.
Anyone have the same symptoms as mind?Hi,
When user is disconnected to Exchange, please test outlook anywhere connectivity for this user.
Test Outlook Anywhere connectivity
https://technet.microsoft.com/en-us/library/ee633453(v=exchg.150).aspx
Please also check if there are any other events in application log.
Best Regards.
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
Lynn-Li
TechNet Community Support -
I am having trouble getting a numbers spreadsheet to hold different formats in the same column. A column with a date formatted heading will not convert to $ for the cells below. Any suggestions would help.
Hi Wayne,
Thank you for this response. I have tried this but when I start enterring $ amounts some, such as $6.00, go in OK others such as $4.00 appear as a date ie 4 Oct 12.
Kind regards
Paul -
I am having trouble getting my Lightroom 5.0 upgrade to accept my Lightroom 4.4 serial number. I recently installed Windows 8, 64 bit on a second solid state HD on my computer (had a virus problem for which I had to format C and reinstall everything). The new ss HD is drive C and my operating system and my programs are all installed there. All my documents and files are now stored on my original, reformatted drive, which is now drive D. I was using Windows 7, 64 bit. Could all this be the reason my serial number is not being recognized? PHH
Hi 48phh,
Yes Lightroom 5 takes the Serial Number of each previous version and you can do the Upgrade from any 1, 2 3, or 4 version of Lightroom,but somethig different for the Upgrade from the Mac App Store ... see how here: http://helpx.adobe.com/lightroom/kb/upgrade-mac-app-version-lightroom.html
you installed Windows 8 and installing only the operating system, but keeping all the app certainly and during the operation something can be lost, especially if you run Clean after installing the system by deleting the folder containing the old system, it's better to wait to do so.
However, no problem, because to do the 'Upgrade all you need is the old serial number and don't need Lightroom4 to be installed on your machine ...
more details here: http://blogs.adobe.com/lightroomjournal/2013/06/lightroom-5-hot-issues.html -
I'm having trouble getting music from itunes on computer to my iphone?
I'm having trouble getting music from itunes on my computer library to my iphone can someone please tell me what i'm doing wrong?
Hi ckwools,
Welcome to the Support Communities!
What is the specific issue? Are you getting an error message? The article below will provide some general information on syncing with iTunes:
iTunes 11 for Windows: Set up syncing for iPod, iPhone, or iPad
http://support.apple.com/kb/ph12313
Cheers,
- Judy
Maybe you are looking for
-
Bpel process invoking an ESB problem
Hi All, Im fairly new to bpel and i encountered the following problem. I am receiving an input, and transforming the data to a canonical model, i then send that canonical model data to an ESB to invoke another bpel process but when im invoking im get
-
Pop up window for a log-on no longer shows up with newest version. Please help
I have a singlesignon to a work site. A small pop-up window opens when I go to the site so I can log in. Worked great until I installed the latest version of Firefox. This particular site only works with Firefox as well. I contacted IT for the work s
-
Acrobat 9 Pro Extended and Adobe 3D Reviewer
Good day, I just try to download the trial of Acrobat 9 Extended and try to use the new Adobe 3d Reviewer on this computer but after I try 4 time I still never get any success. On another computer he installation process went all ok without problem,
-
Error when trying to sign documents
I started getting the following message when trying to sign documents:The Windows Cryptographic Service Provider reported an error: Key not valid for use in specified state. Error Code 2148073403 . Any help would be appreciated Thank you
-
Hello, Our GRCI analytics product is on OBIEE 10.1.3.3.2 and OBIEE 10.1.3.3.3. However we have following questions, that would help us in deciding the pricing options for our customers. - Are the corresponding OBI SE1 available out (OTN or SAC) for a