How to set the default selected option as NO_OPTION in a JoptionPane
This is just an example program to create the same scenario in the project.When clicked on OK button, it will pop up a JOptionPane confirm dialog with YES-NO buttons.I want to set the default selected button as NO button. In the below program, the keyboard focus is set on NO button, but in the look and feel the selection is still YES button. Can anyone suggest a solution to make both the focus on NO button?
public class Test extends JPanel implements ActionListener{
Test() {
JButton btn = new JButton("OK");
this.add(btn);
btn.addActionListener(this);
public void actionPerformed(ActionEvent e) {
Object[] o = {"Yes", "No"};
JOptionPane p = new JOptionPane("Are u sure?",JOptionPane.QUESTION_MESSAGE,JOptionPane.YES_OPTION,null,o,null);
//p.setWantsInput(false);
p.setInitialSelectionValue(o[1]);
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
} catch (UnsupportedLookAndFeelException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
//p.setFocusCycleRoot(false);
p.setInitialValue(o[1]);
//p.getRootPane().getDefaultButton().requestFocusInWindow();
UIManager.put("Button.defaultButtonFollowsFocus", Boolean.FALSE);
p.createDialog(this, "").setVisible(true);
if(p.getValue() == o[0]) {
System.out.println("yes");
}else if(p.getValue() == o[1]) {
System.out.println("no");
//p.setWantsInput(true);
//p.showConfirmDialog(this, "Are u sure?");
//p.setInitialSelectionValue(new Integer(JOptionPane.NO_OPTION));
public static void main(String[] args) {
Test t = new Test();
JFrame f = new JFrame();
f.getContentPane().add(t);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(500, 500);
f.setVisible(true);
}
not sure what you're trying to do, but try this
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Test extends JPanel implements ActionListener
Test()
JButton btn = new JButton("OK");
this.add(btn);
btn.addActionListener(this);
public void actionPerformed(ActionEvent e)
Object[] o = {"Yes", "No"};
int value = JOptionPane.showOptionDialog(null,"Are u sure?","",-1,-1,null,o,o[1]);
if(value == 0) System.out.println("yes");
else if(value == 1) System.out.println("no");
public static void main(String[] args)
UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
Test t = new Test();
JFrame f = new JFrame();
f.getContentPane().add(t);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(500, 500);
f.setVisible(true);
}
Similar Messages
-
How to set the default selection to "Select All" in a Multi valued parameter in SSRS 2008?
Hello Everyone,
How to set the default selection to "Select All" in a Multi valued parameter in SSRS 2008?
Regards
Gautam S
RegardsYou need to specify "Default Values" in the report parameter property. Choose similar option used in the "Available Values" option, this will allow the parameter to check "Select All".
Regards, RSingh -
How to set the parameter selection *optional* for each subreport?
Hi,
I am using Crystal Reprots 11.
I create 10 subreports, and each subreport contains a Parameters Field.
The 10 subreports are put in 10 footer sections in increasing order, i.e. subreport1, subreport2, subreport3, ..., subreport10.
When I use "Print Preview" to take a look at the whole report, CR prompts a "Edit Values" window for selecting parameter values for all 10 subreports.
For example, if I only select parameter values for subreport1 and click "OK", 9 error messages on the "Edit Values" window come out above the selection list box of every other subreports (i.e. subreport2 ~ subreport10) showing that: 'The value is not valid'.
Sometimes, I just want to review some specific subreports but not all.
How should I do to set the parameter selection optional (not mandatory) for each subreport?
Thank you in adavance.
Edited by: Holdup on Feb 17, 2012 3:44 PMHi,
Here's how you can make the prompts optional (Assuming you're using CR 2008 or higher):
1) Go into each subreport
2) You should see the parameter in the Field Explorer. Right-click the name and select Edit > Look for an option called 'Optional Prompt'. Set it to true
3) If you have a record selection in the subreport, then you need to modify the selection formula to something like this:
if not(hasvalue({?Parameter_Name})) then True else = {?Parameter_Name}
Hope this helps!
-Abhilash -
Urgent!How to set the default selected date for an OAMessageDateFieldBean
Hi,
There is messagetextinput on the page.the dataType is Date.
if I do not input anything on this messagetextinput ,when I click on the date icon,the default selected date is today.
But I want to set the default selected date base on another messagechoice.
Is that possible?
binghao.Sumit/Binghao,
When u set deafult date in the OAMessageDateFieldBean, the OAInlineDatePickerBean (which are referring as datepicker popup windows), takes the default value from OAMessageDateFieldBean.
If you explore OAMessageDateFieldBean in framework, u will find its nothing but a onClick js event is called on the imageicon attached with messagetextinput bean(in case the type is Date) and OAInlineDatePickerBean is opened in a modal js window.
So, here is code for setting default value both in both in OAMessageDateFieldBean and OAInlineDatePickerBean :
OAMessageDateFieldBean dateField = (OAMessageDateFieldBean)webBean.findIndexedChildRecursive(<item id>);
dateField.setValue(pageContext,new Date(100, 06, 04)/* 4th July 2000*/);
One more important thing, here Date class is java.sql.Date.I hope i am clear.
--Mukul -
How to set the default selection screen
I modified screen using screen-input = 0.
then how to set the screen-input = 1.
that is how to make that field input enable.
if use the statement screen-input = 1 directly it is giving 2 fields to enter valueIn the PBO / AT SELECTION-SCREEN OUPUT
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = <your FIELD>. " Fields by name
* IF SCREEN-GROUP1 = <your group of fields>. " Fields with MODIF ID
IF <test>.
screen-input = 1. " For input enable
ELSE.
screen-input = 0. " For input disable
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
Regards -
How to set the default selection in treetable
Hi,
Now I'm using jdeveloper 10.1.3.3, and using af:treeTable and af:tableSelectOne to represent a treetable and let the user select specific row by clicking the radio button in front of each row. I want to programmatically set a specified row to be selected by default when the page is loaded, I didn't find a way to implement this function.
Anyone has ideas?
Thanks in advance.Hi Karen,
What is the type of data you are feeding to the drop down ? Is it a standard fixed list of items or a query ? From what i see you would be using a query as the dataprovider for the dropdown. In such a case, in your query, restrict Plant with value 7700 in the default values section of the query. This should do the trick that when you run the template, the dropdown would show 7700 by default.
Hope this helps.
Regards
Snehith. -
How to set the default selection in a WAD dropdown
Hi All
We are on BW 3.5 I have the following dropdown box in a WAD template. Our users want by default when the query starts only to display Plant = 7700.
Please can you kindly share ideas how I can do this.
<object>
<param name="OWNER" value="SAP_BW"/>
<param name="CMD" value="GET_ITEM"/>
<param name="NAME" value="DROPDOWNBOX_2"/>
<param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_FILTER_DDOWN"/>
<param name="DATA_PROVIDER" value="DP_1"/>
<param name="BORDER_STYLE" value="BORDER"/>
<param name="WIDTH" value="200"/>
<param name="CAPTION" value="Plant"/>
<param name="IOBJNM" value="0PLANT"/>
<param name="BOOKED_VALUES" value="Q"/>
<param name="SHOW_LABEL" value=""/>
ITEM: DROPDOWNBOX_2
</object>
Thanks
KarenHi Karen,
What is the type of data you are feeding to the drop down ? Is it a standard fixed list of items or a query ? From what i see you would be using a query as the dataprovider for the dropdown. In such a case, in your query, restrict Plant with value 7700 in the default values section of the query. This should do the trick that when you run the template, the dropdown would show 7700 by default.
Hope this helps.
Regards
Snehith. -
How to set the Default values for Info Objects in Data Selection of InfoPac
Hi All,
Flat file Extracion:
How to set the Default values for Info Objects in Data Selection Tab for Info Package
ex: Fiscal Year Variant Info Object having values 'K4' 'Y2' etc in Flat file
Initially default value(not constant) for this info Object value should be 'K4' in Info Package
If I set data selection value for this info object K4 it will retreive records with this selection only? how to handle
Rgds,
CVHi,
suppose as your ex. if you are having fiscalyear variant in the dataselection tab then specify K4 in the from column, again the ficalyearvariant row and click on insert duplicate row at the bottom . you will get another row . In that enter Y2 in the from column. now you can extract K4, y2 values .
haritha -
"I would like to know how to set the default view for the columns that are shown in iTunes. Every time I open it, I have to either go to the options, or right-click to get the pop-up options, and delete "rating" and add "composer." I'd really like to just do it once and be done with it." Somewhere I read you could do this by clicking on the Music icon under LIBRARY then arramge the columns. Trouble is, I can't find a Musi Folder or icon in my user library.
Any help would be appreiated. OSX 10.9.2 iTunes version 11.1.5 Thanks!!! CW!From the iTunes menu bar try View>Show View Options. Make sure what you want to see is checked and what you don't is unchecked. You can do this (may need to do this) for any playlists, your main Library, etc.
Good luck
srb -
How to get the default selection color from JTable
Hi, there,
I have a question for how to get the default selection color from JTable. I am currently implementing the customized table cell renderer, but I do want to set the selection color in the table exactly the same of default table cell renderer. The JTable.getSelectionBackgroup() did not works for me, it returned dark blue which made the text in the table unreadable. Anyone know how to get the window's default selection color?
Thanks,
-JennyThe windows default selection color is dark blue. Try selecting any text on this page. The difference is that the text gets changed to a white font so you can actually see the text.
If you don't like the default colors that Java uses then use the UIManager to change the defaults. The following program shows all the properties controlled by the UIManager:
http://www.discoverteenergy.com/files/ShowUIDefaults.java
Any of the properties can be changed for the entire application by using:
UIManager.put( "propertyName", value ); -
How to set the default context value for flexfield in OAFramework pages
Hi,
I have a page which contains a contexxt value field i.e Flexfields
To select the context value we have to select the value from drop down
So Here we want to display the context value immediately when the page is called
How to set the default valu in this case
Regards,
KrishnaYou can set the Attribute category view attribute to the Flexfield context value and call prepareforRendering in the flex bean. Check the dev guide for details.
Regards
Sumit -
How to set the default value in dashboard prompt?
Hi there,
In my Dashboard prompt I'm getting values like:
Mar 2010
Apr 2010
May 2010
Jun 2010
How to set the default value to the current month (Jun 2010). I don't want to use "specific value". I want to use the "SQL Result" for populating the default value.
Appreciate your helphi,
you can create a Repository variable current_month with the expression as
select to_char(trunc(sysdate),'Mon')from dual
and use this in the prompt "Default to" Server variable and use this repository variable.
hope this helps.
cheers,
vineeth -
How to set the default settment rule for the same kind project.
hi experts:
the project of the same kind of the project profile have the same settment rule to one account (G/L).
how to set the default settment rule for the project of this kind of the project profile.
regardsHi,
You need to define the settlement profile and allocation structure.
next you need to define the Strategy for settlement rule.
navigation-PS> costs> automatic and periodic allocations> settlement> Settlement rule for WBS
--> Define strategy for settlement rule.
Select the strategy and click on settings. in that new entries, check the Acc Assg element, enter Settlement profile and mention accass category as reposnsible cost center.
Save this transaction.
Now create a project assgin responsible costcenter for the WBS element in the project buider and save the transaction.
Now run CJB2 transaction for the project, settlement rule will generated automatically.
even you can configure the same for profitability segment.
Rgds
Sudhir Reddy -
SRM 4.0- How to set the default values for product type (01) only for SC
The radio button Service should not be visible.
Also for search help (e.g. search for internal products) where a search should only be possible for product type 01 (goods). The system should not display the product type and internally always search for goods only.
How to set the default values for product type (01) only for SC
We needs to use Search help BBPH_PRODUCT which having parameter PRODUCT_TYPE
Here we can set defalut value 01 but it is not correct one since same search help is using several places.
We need to limit the search help results only for SC.
Kindly help out me ASAP.The easiest way to set defautl values is to edit the batch class.
Goto the characteiristic and go to update values.
In here you probably have something like 0 - 100 as a spec range.
On the next line enter the default value within this range. At the end of the line, click in the box in the column labelled "D". This indicates the defautl value for the characteristic.
If you need to you can do this in the material classification view as well.
Just to be clear, these values will only show up in the batch record. You can not have defautl values in resutls recording screens.
FF -
How to set the default text in an input box or a label to be a predefine, multiline text
how to set the default text in an input box or a label to be a predefine, multiline text. In other words how to break the line in the code of a text box.
thank youThere are a couple of ways of doing this:
If you're editing on the canvas, press Shift + Enter.
If you're working in Express View (see lower right hand corner of Project Siena), you'll need to copy a hard return from another app such as Notepad.
I believe a better implementation of hard returns are in the list of requested functionality that you can find here:
https://social.technet.microsoft.com/Forums/en-US/2e1f9446-56b2-419a-9c17-7037d2cd6146/from-the-community-overview-of-requested-additional-functionality?forum=projectsiena
Thor
Maybe you are looking for
-
How can i create an apple id without credit card
How to create an apple id without credit card
-
_
-
Auto viewer gallerys not working, please help??
Hi please look at www.websitedesignportugal.com/townhouse2 if you look at the top right there is 2 button for external gallery and internal. these link to a auto viewer galleries. when i preview in dreamweaver it works but when i upload the site it d
-
Download link custom action for video files
Hi, I have a requirement for adding a custom action called "DOWNLOAD A COPY" in search results hover panel on click of which will download copy for the user. I am able to implement this for pdf, excel and word files but not for generic and video file
-
Schedule for Outlook 2011 calendar sync?
Hi Has anyone seen a schedule for Outlook 2011 to sync calendars with iPhone? If you were thinking of getting the version of Office for MAC that has Outlook 2011 you might want to hold off for while. It seems Microsoft left it that bit out... thanks