JRadioButtons - how do i know which one has been clicked?!
hey all,
im working on a simple gui to implement a ticket office system. im a bit of a newbie to using GUIs and im fed up of trawling through the api's in search of answers and im on the home run... so here's my q...
i have a gui class for doing a search for tickets. i have a controller in a seperate actionListener class for this gui. i have three radio buttons for searching for three different things and then there's a search jbutton to start the search.
how do i know what radio button the user has selected when they click search? i need to be able to know this from the controller, not in the gui itself.
thanks a mil!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TicketOffice_Demo extends JFrame {
public TicketOffice_Demo() {
initComponents();
private void initComponents() {
ticketsGroup = new ButtonGroup();
toolbar = new JToolBar();
startSearch = new JButton();
typeA = new JRadioButton();
typeB = new JRadioButton();
typeC = new JRadioButton();
scrollpane = new JScrollPane();
textarea = new JTextArea();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setTitle("Ticket Office Demo");
toolbar.setFloatable(false);
startSearch.setText("Start Search");
startSearch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
startSearchActionPerformed(evt);
toolbar.add(startSearch);
ticketsGroup.add(typeA);
typeA.setSelected(true);
typeA.setText("\"A\" Tickets");
typeA.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
typeAItemStateChanged(evt);
toolbar.add(typeA);
ticketsGroup.add(typeB);
typeB.setText("\"B\" Tickets");
typeB.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
typeAItemStateChanged(evt);
toolbar.add(typeB);
ticketsGroup.add(typeC);
typeC.setText("\"C\" Tickets");
typeC.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
typeAItemStateChanged(evt);
toolbar.add(typeC);
getContentPane().add(toolbar, BorderLayout.NORTH);
textarea.setBackground(new Color(255, 255, 204));
textarea.setEditable(false);
scrollpane.setViewportView(textarea);
getContentPane().add(scrollpane, BorderLayout.CENTER);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
private void startSearchActionPerformed(ActionEvent evt) {
Controller cont = new Controller(ticketType);
textarea.append("Controller searches for ticket type '"+cont.getTicketType()+"'\n");
private void typeAItemStateChanged(ItemEvent evt) {
if(typeA.isSelected()){
ticketType = "A";
}else if(typeB.isSelected()){
ticketType = "B";
}else if(typeC.isSelected()){
ticketType = "C";
public static void main(String args[]) {
new TicketOffice_Demo().setVisible(true);
private JButton startSearch;
private JRadioButton typeA;
private JRadioButton typeB;
private JRadioButton typeC;
private JScrollPane scrollpane;
private JTextArea textarea;
private JToolBar toolbar;
private ButtonGroup ticketsGroup;
private String ticketType ="A";
class Controller {
Controller(String ticketType){
this.ticketType = ticketType;
public String getTicketType(){
return ticketType;
private String ticketType;
}
Similar Messages
-
Dynamic h:commandLinks : how do I know which one has been clicked?
Imagine I have something like:
<h:dataTable etc etc>
<h:column>
<h:outputText etc etc />
</h:column>
<h:column>
<h:commandLink action="#{BeanName.removeEntry}" />
</h:column>
</h:dataTable>
<h:inputText etc etc><h:commandLink action="#{BeanName.addEntry}" />
so that when I add Entries, they get seen on the dataTable above..
THe addEntry code is easy to do, it's only a ArrayList.add() method call but what about the removeEntry? I don't know how to figure out which 'remove' commandLink was clicked.If you have a datamodel in yo
ur datatable, then you can do something like this:
getModel().getRowData()
This returns the selected row.
From here it's with you..... -
How do I know which block has been changed in Master/Detail
Hi,
I have master detail blocks. How do I know which block has been changed?
I used :SYSTEM.FORM_STATUS. It only gave me "Changed" or "Query". but didn't tell me which block has been changed in MASTER or DETAIL.I believe if :system.form_status != 'QUERY' you'll need to loop through through the blocks checking :system.block_status to see who changed. Of course you'd have to go_block() before checking the status.
-
How do I know which workflow has been activated for my SHC in SRM
Hi Experts ,
Can anyone tell me where to find which workflow has been activated to my Shopping cart in the SRM. so that it creates a PO in the backend
To create a PO in the back end it should have a WF actiavted.
do we can have only always one WF activated or can we have multiple WFs depending on the conditions for one scenario
Please suggest me
Regards
Sairam.Cross-Application Basic Settings u2192 SAP Business Workflow u2192 Perform Task-Specific Cusomizing
SAP u2192 SRM u2192 SRM-EBP u2192 SRM-EBP-WFL
- WS10000060 (Automatic approval)
- WS10000129 (One-step approval)
- WS10000031 (Two-step approval)
- WS10000276 (Approval single-level over limit)
- WS14000044 (Completion by purchaser)
- WS14000109 (Approval n-step over value limit)
- WS14500015 (Item approval)
- WS14000045 (Delete shopping cart after application error)
- WS10000202 (Transfer purchase requisition)
- WS10000215 (Resubmission of shopping cart by administrator)
You need to check Event linkage is either Activated or Deactivated aor these above work flow . I fit is activated it shows green light.
Muthu
Edited by: muthuraman on Jul 29, 2008 2:38 PM -
How can i determin which tab has been clicked??
hi there
how do i determine which one of the tabs in a tabbedPane has been clicked? do i add ActionListener to the tabbedPane or its sub JPanel?I import them all, it finallly compiled, but I am not sure if they are ok. here is the codes
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
TabbedPane = new JTabbedPane();
TabbedPane.addTab("Easy", easyTab);
TabbedPane.addChangeListener(new ChangeListener()
public void stateChanged( ChangeEvent ce )
Object source = ce.getSource();
if (source == "Easy")
currentTab = "easy";
does it look all right to you? -
So I am new to Muse, and my Adobe Cloud has 2 different programs from Muse... how do I know which one is the newer better version?
One Must program (Muse CC 2014.2) has a black background when working on it... it looks like other Adobe programs such as Photoshop.
The other one is light color (Muse CC) very similar to the black color Muse on functions.....
One of the difference I notice is that the light color Muse has a few widgets in the library, while the black background Muse seems to have an empty library
So... why are there 2 different Muse programs in my Adobe Cloud?Hi
The latest version of Muse is 2014.2, so you need to uninstall another version of Muse manually.
regarding the items in Library, you can add items in your library manually, as shown in this article
Adobe Muse Help | Organizing and reusing design elements using Library panel
Please let me know if you have any other query. -
I recently deleted many duplicate files. In the midst of it my Itunes songs are not in Itunes. They are in two different folders. One under 'Music' in my ID. And two under a MyMusic file in Documents. How do I know which one to import?
Thanks, this is not an ideal answer but probably the most sensible one in my case.
I will try it unless someone has a better suggestion, but I'll wait a bit as it will take me a few days anyway (I had actually tried to create a new smaller playlist or download by album, but at this stage the music app is not letting me queue a list of songs for download - I think I will have to disable and re-enable iTunes match which will probably delete all the songs).
I have to say I am not very impressed with Apple here - having an online backup of all your data and beeing able to restore it to a new device easily was a strong selling point of iCloud. For music, they are Definitly not delivering at the stage. -
If I have two or more iTunes Libraries on one computer, how do I know which one is opening when I click on the iTunes icon on my desktop?
You cannot.
When you sync to a new library, it will erase the current content.
Use your backup copy of the old computer to copy everything to the new one. -
can you have multiple Apple TV's in the same house and network? If so how do you know which one to pick from your Idevice?
Yes, there are even defaults for naming them, such as LivingRoom, Bedroom, etc, or you can even enter your own name with the remote for each AppleTV.
-
Hi I wonder if I live in Bangkok and like to have my own website whshah old I use as hosting website? so many of them and how do I know which one is a good one thank you
It doesn't really matter which country your hosting service is located in so long as they offer 24/7 tech support in your chosen language. Telephone support is usually free of charge to you.
Some info about the essential features to look for...
http://www.iwebformusicians.com/iWeb/Website-Hosting.html
"I may receive some form of compensation, financial or otherwise, from my recommendation or link." -
Difference between photoshop cc and photoshop cc 2014 how do i know which one I am using?
difference between photoshop cc and photoshop cc 2014 how do i know which one I am using?
Hi Petereas,
Both are different version of Photoshop application.
In Photoshop CC 2014 there are several new feature introduced than CC.
Please refer the following page on whats new in Photoshop 2014.
Photoshop Help | New features summary
When you go to Help>About Photoshop then Photoshop 2014 shows version 2014.0.0 Release.
Hope this helps.
Thanks and Regards,
Sumit Singh -
How do you actually know where a Spotlight file is? I mean all well and good Spotlight identifies it but I want to know which file has been identified and where it is......
To know where the Spotlight file is, highlight it in Spotlight and hold the Command key, so you will see its location at the bottom of the window
-
My Mac Mini serial # is C0******JD0. The internal power supply burned. How do I know which one to buy? A1347?
<Edited by Host>Also, this company may be able to help you identify the item from their database and your serial number.
http://www.powerbookmedic.com -
HT201365 How do I know which one of my app ids have locked this device?
How do I know which one of my app ids have locked this device?
I have 4 differnt iCloud account in my business and recently I tried to reset one of my six iPhones...is there a way to find out which app id was used on my device to lock it?Try to Login to all your iCloud Account one by one and then from Find My iPhone device list you will find all your devices which is associated with that Apple Id. If you have all your other iPhones with you and in working condition and connected to Internet then try to play a sound on that device from Find My iPhone to make sure it is not that device which is Locked after Restore and the other option is Remove all your Device from your Account in iCloud.com Do not select the option of Erase or Lost Mode and once you removed all your devices from All your Apple iCloud Account Restart that iPhone once and this time you should not be asked for any Apple Id or Password to unlock your Device.
-
How to find out which GR has been invoiced?
Hello,
I am working on one scenario in which I am making a sales order through which automatic Purchase order is getting generated. I am doing a MIGO(GR) for lesser quantity on this PO. lets say I am creating 4 GRs of 10 quantity for a PO of 50. Now, I am making direct invoice for this through VF01 with reference to sales order. An invoice of 40 will be created.
Now, I am doing creating one more GR of 10 for the rest of the amount. I have 5 GR's now.
How can I get to know which GR has been invoiced (table relation) and which is yet to be invoiced?Amrish,
RSEG is the "Document Item: Incoming Invoice" table. In this table, Look for the field LFBNR , LFGJA, LFPOS.
LFBNR - Refernced GR Number
LFGJA - Year
LFPOS - Ref Doc Item
Hope this helps
Vinodh Balakrishnan
Maybe you are looking for
-
The following letters will not print on my wireless keyboard: q,w,e,r,t,y,u,i,o. All the other keys are fine.
-
Procedure entry point sqlite3_wal_checkpoint message
'Procedure entry point sqlite3_wal_checkpoint could not be located in SQlite3.dll' what does this mean?
-
Buttons have facebook messages
Hello. Mozilla Firefox users, I am one who loves u too. There is an annoyance, but in mozilla. Up the time passed since the new message system. message processing part of the buttons does not delete messages. other web browsers do not have this probl
-
How to scale it up without having it pixelated
Hi! I was working on a project and I did a very silly mistake with the measurements. The mistake: Lets say that instead of doing 5 cm I did 5 mm What I did: Scale the entire art by 1,000% Result: Looks perfect on the screen and it is the accurate siz
-
BPC Ver 10.1 Netweaver User Guide
I am having trouble finding a user guide for BPC Ver 10.1 Netweaver (Classic or Unified). I am preparing "admin" training materials and can not find answers to some basic application admin type activities like what special characters are allowed in