Button keeps being disabled even though a specified it to be enabled
I've tried placing the enabling code in different areas, but nothing has worked.
btn_Receipt.setEnabled(true);
btn_Reset.setEnabled(true);
txtA_ProofOfPurchase.setEnabled(true);
double deposit = Double.parseDouble(JOptionPane.showInputDialog("Please specify the amount of money that you would like to withdraw (in Rands)"));
String name = "Nia Sanderson";
String action ="Deposit";
txtA_ProofOfPurchase.setText
("******************************* \nNedbank Online Banking " +
"\nCustomers Name: " + name +
"\nAction: " + action +
"\nDeposit Amount: R " + deposit +
"\n*******************************"
);
I expect the output to result in the two buttons and text area being enabled
Related
I have a Spring Boot v1.5.14.RELEASE app., Using Spring Initializer, JPA, embedded Tomcat and following the RESTful API architecture principes. I have created this test
#Test
public void createCustomerChain() throws Exception {
this.mockMvc.perform(post("/customer/createCustomer")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content("{\n" +
" \"subSegment\":\"25\",\n" +
" \"legalLanguage\":\"NL\",\n" +
" \"isRestrictel\":true,\n" +
" \"isCommunicationLanguageForAllAccount\":true,\n" +
" \"isAntiMarketing\":true,\n" +
" \"hotelChain\":{\n" +
" \"legalForm\":\"09\",\n" +
" \"foundationDate\":\"2001-12-17T09:30:47Z\",\n" +
" \"tradingName\":\"COMPANY NAME\",\n" +
" \"printName\":\"TEST PRINT\",\n" +
" \"naceCode\":\"16230\",\n" +
" \"vatNumber\":\"41223334343\", \n" +
" \"countryVatCode\":\"IN\",\n" +
" \"isSubjectToVAT\":true,\n" +
" \"sectorCode\":\"85\",\n" +
" \"legalAddress\": {\n" +
" \"mainkey\":2088512,\n" +
" \"subkey\":3256\n" +
" }\n" +
" },\n" +
" \"isVATNumberOnBill\":true,\n" +
" \"communicationLanguage\":\"EN\"\n" +
"}"))
.andExpect(status().isOk())
.andDo(document("customer-create-request-Chain",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
responseFields(
fieldWithPath("billingAccountId").description("The billing account id of the newly created customer"),
fieldWithPath("paymentAgreementId").description("The Payment Agreement Id of the newly created customer"),
fieldWithPath("customerId").description("The id of the new created customer"),
fieldWithPath("isNewlyCreated").description("Set to `true` when the customer is newly created")),
requestFields(
fieldWithPath("subSegment").description("Market subsegment"),
fieldWithPath("legalLanguage").description("Legal language"),
fieldWithPath("isAntiMarketing").description("If true, customer does not want to have any marketing contact"),
fieldWithPath("isRestrictel").description("Indicates that the customer is on the orange list. Do not disclose information to other companies for commercial purposes."),
fieldWithPath("hotelChain.legalAddress.mainkey").description("LAM mainkey of the address. If the mainkey and the subkey is given the rest of the address information is not needed."),
fieldWithPath("hotelChain.legalAddress.subkey").description("LAM subkey of the address"),
fieldWithPath("hotelChain.legalForm").description("Legal form"),
fieldWithPath("hotelChain.foundationDate").description("Date of the foundation of a company(mandatory field for 'Chain' customer type)"),
fieldWithPath("hotelChain.vatNumber").description("Enterprise or VAT number"),
fieldWithPath("hotelChain.countryVatCode").description("ISO2 country code of the VAT number"),
fieldWithPath("isVATNumberOnBill").description("Indicates if the VAT number will be shown on the bill"),
fieldWithPath("hotelChain.isSubjectToVAT").description("Indicates if the enterprise number is a real VAT or not"),
fieldWithPath("hotelChain.sectorCode").description("Subtitle Description. Additional information relating to the customer. Name-Value pairs"),
fieldWithPath("hotelChain.tradingName").description("Trading name"),
fieldWithPath("hotelChain.printName").description("Print name of the customer"),
fieldWithPath("hotelChain.naceCode").description("Nace code"),
fieldWithPath("communicationLanguage").description("Communication language"),
fieldWithPath("isCommunicationLanguageForAllAccount")
.description("If true, commercial language of all BGC billing accounts receive the value defined at customer level and users not allowed to change commercial language of any billing account"))));
}
and this is the result of running the test:
org.springframework.restdocs.snippet.SnippetException: Fields with the following paths were not found in the payload: [customerId]
and removing the customerId from fieldWithPath test passed successfully but, I wonder why I don't have the same error for such a field like billingAccountId
This is due to customerId field could be null or absent in some cases. You can use optional for it:
fieldWithPath("customerId").description("Description").optional()
To find a more precise reason, please, post the code of the createCustomer() method.
I have a GUI related question. I am attempting to use create a GUI using a JOptionsPane as well as JPanel, JText and JLabel. Now that I have accomplished building my GUI and getting the tag to work my next goal is to create a table around the formatted text of my GUI, I will post my code below to illustrate:
String css = "<span style='font-size:10; color: white; background-color:black'>";
String batchCss = "<span style='font-size: 20'>";
String cssBorder = "<span style='border:1px dotted red'>";
String endSpanCss = "</span>"; String table = "
<table border=4>"; String endTable = "</table>"; String text = "
<html>" + table + css + batchCss + "1 of 2" +endSpanCss+ endSpanCss + endTable + "
<br>Entry Detail:" + "
<br>11111111111111111111111111+ "
<br>
<br>Please type 1-21 to apply a reason code and addenda record to the entry detail." + "
<br>Please type 'h' and press any button to open the help screen." + "
<br>
<br>
<br>Reason Codes" + "
<br>R01 - Insufficient Funds" + "
<br>R02 - Account Closed" + "
<br>R03 - No Account" + "
<br>R04 - Invalid Account Number" + "
<br>R05 - Unauthorized Debit to Consumer Account" + "
<br>R06 - Returned per ODFI Request" + "
<br>R07 - Auth Revoked by Customer" + "
<br>R08 - Payment Stopped" + "
<br>R09 - Uncollected Funds" + "
<br>R10 - Customer Advises Not Authorized" + "
<br>R11 - Check Truncation Entry Return" + "
<br>R12 - Branch Sold to Another DFI" + "
<br>R13 - Invalid ACH Routing Number" + "
<br>R14 - Represenative Payee Deceased or Unable to Continue" + "
<br>R15 - Beneficiary or Account Holder Deceased" + "
<br>R16 - Account Frozen" + "
<br>R17 - File Record Edit Criteria" + "
<br>R18 - Improper Effective Entry Date" + "
<br>R19 - Account Field Error" + "
<br>R20 - Non-Transaction Amount" + "
<br>R21 - Invalid Company Information" + "
<br>R22 - Invalid Individual ID Number";
Someone yesterday got me started with the CSS which works, but now I need to figure out how to put some type of table around the whole thing so I can organize this text-heavy dialog. I have tried to use a CSS tag like <span style='border:1px dottec red'> as you can see from my variables, but this had no effect.
When I add the standard HTML table tag outside the CSS it works however my CSS no longer works (as you can see if you test the program). Removing the table border will again allow the CSS to work.
How can I get the span style='border' to work, or how can I get the table border to work with the CSS?
EDITED:
Here is additionally runnable code as requested.
package nacha;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Testing4
{
public static void main(String args[]){
String css = "<span style='font-size:10; color: white; background-color:black'; border:>";
String batchCss = "<span style='font-size: 20'>";
String endSpanCss = "</span>";
String table = "<table border=4>";
String endTable = "</table>";
String mainCss = "<span style='font-size:12; color: red'>";
String header1Css = "<span style = 'font-size:15; font-weight:bold;text-decoration:underline;border:1px dotted red'>";
String text1Css = "<span style = 'font-size:12; font-style:italic'>";
String text = "<html>" +
css + batchCss + "1 of 2"+endSpanCss+endSpanCss+ endSpanCss +
"<br><br><br>"+header1Css+"Entry Detail:"+endSpanCss +
"<br>"+mainCss+"111111111111111111111"+endSpanCss+
"<br><br><br>"+text1Css+"Please type 1-21 to apply a reason code and addenda record to the entry detail." +
"<br>Please type 'h' and press the next entry button to open the help screen."+endSpanCss +
"<br><br><br>"+header1Css+"Reason Codes"+ endSpanCss +
"<br>"+table+"R01 - Insufficient Funds" +
"<br>R02 - Account Closed" +
"<br>R03 - No Account" +
"<br>R04 - Invalid Account Number" +
"<br>R05 - Unauthorized Debit to Consumer Account" +
"<br>R06 - Returned per ODFI Request" +
"<br>R07 - Auth Revoked by Customer" +
"<br>R08 - Payment Stopped" +
"<br>R09 - Uncollected Funds" +
"<br>R10 - Customer Advises Not Authorized" +
"<br>R11 - Check Truncation Entry Return" +
"<br>R12 - Branch Sold to Another DFI" +
"<br>R13 - Invalid ACH Routing Number" +
"<br>R14 - Represenative Payee Deceased or Unable to Continue" +
"<br>R15 - Beneficiary or Account Holder Deceased" +
"<br>R16 - Account Frozen" +
"<br>R17 - File Record Edit Criteria" +
"<br>R18 - Improper Effective Entry Date" +
"<br>R19 - Account Field Error" +
"<br>R20 - Non-Transaction Amount" +
"<br>R21 - Invalid Company Information" +
"<br>R22 - Invalid Individual ID Number"+endTable;
//Below code creates the GUI for the return builder portion of the program.
Object[] options1 = {"Next Entry","Next Batch","Finished"};//Changes the default buttons.
BorderLayout border = new BorderLayout();
JPanel panel = new JPanel();
panel.setLayout(border);
panel.add(new JLabel(text),BorderLayout.NORTH);//Adds the label to the top of the panel.
JTextField textField = new JTextField(10);
panel.add(textField,BorderLayout.SOUTH);//Adds a user-input text area to the bottom of the panel.
int result = JOptionPane.showOptionDialog(null, panel, "Return Builder", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options1, JOptionPane.YES_OPTION);
}
}
You will find the line giving me trouble is:
String header1Css = "<span style = 'font-size:15; font-weight:bold;text-decoration:underline;border:1px dotted red'>";
I have set that line to have a 1 px dotted red border. That format string is called here:
"<br><br><br>"+header1Css+"Entry Detail:"+endSpanCss +
And the result is the "Entry Detail:" line is formatted correctly for everything except the border.
Solved.
What I was trying to accomplish is not currently possible as the border is not used for rendering.
Source:
http://docs.oracle.com/javase/8/docs/api/javax/swing/text/html/CSS.html
Thanks Sva.MU for assisting with this.
I have a tool what uses Perforce. When it merge a branch back to the parent, mark the project branch with checkout a text file, and submit it unchanged. This tool also use that text file, for read the actual build number. My problem is, a "/n" appeared in the text, and because it have to contain just numbers, it's a big problem.
Have anyone met this problem, or this can't caused by P4C?
Maybe important, I don't use P4JAVA here.
Please note that I'm debugging right now, and I'm not sure the problem is here, but at the moment this seems the most probable.
//<path> is a legit path, I just shortened the code here
commandSync = "p4 -d " + getPerforceRoot() + " sync " + selectedDataBean.getP4Path() + "<path>/BuildNum.txt";
CommandResultBean syncCommandResult = commandExecuter.runAndGetResults(commandSync);
//command executer that runs the command string in cmd
commandMark = "p4 -d " + getPerforceRoot() + " edit -c " + changelistNumber + " " + selectedDataBean.getP4Path() + "<path>/BuildNum.txt";
CommandResultBean markCommandResult = commandExecuter.runAndGetResults(commandMark);
commandSubmit = "p4 -d " + getPerforceRoot() + " submit -f submitunchanged -c " + changelistNumber;
CommandResultBean submitCommandResult = commandExecuter.runAndGetResults(commandSubmit);
String messageValue[] = {userNameFull, programName, url, url, newPass, programSupportEmail, programSupportEmail, programSupportPhone, signature, programWebsite};
//String subject = MessageUtil.getMessage("mail.ResetPasswordSubject", locale);
//String message = MessageUtil.getDynamicMessage("mail.UserMailForgotPassword", messageValue, locale);;
//mail.ResetPasswordSubject = Password Reset Request
String subject = "Password Reset Request";
String message = "Dear {0}"
+ ",<br/>"
+ "Greetings from the {1} Team."
+ "<br/><br/>"
+ "Your password has been reset."
+ "<br/><br/>"
+ "To access your account, "
+ "please click on the following link:<br/>"
+ "<a href={2}>{3}</a>"
+ "<br/>"
+ "or copy the link and paste it in your browser's address bar."
+ "<br/><br/>"
+ "Your temporarily reset password will expire in 7 days "
+ "and you will be asked to change it on your first login."
+ "<br/>Login to your account using the following details:"
//+ "<br/><br/>Password:{4}"
//+ "<br/><br/>Password:"+newPass+""
here i have to enter the link for reset password in place of this "Password:"+newPass+"" please help me
Follow the below steps to avoid brute force attack in security perspective.
Create 32 char alphanumeric string as sessionid which will be valid till 7days (in your case)
Create code 8/12 char conformation code
Put reset link with sessionid in query param and conf code in email.
When user clicks on link, get him to insert conf code on ui.
Validate session id and conf code
All are valid, then show him his username and ask for new password and confirm password.
I have the following problem. I need to get an UI properties:
UIManager.getString("OptionPane.okButtonText")
that returns the string "OK", and it works. However, if I iterate through the UIDefaults keyset, I never get the key "OptionPane.okButtonText". Does anyone know why it happens? I get the UIDefaults in three different way (UIManager.getDefaults(), UIManager.getLookAndFeel().getDefaults() and UIManager.getLookAndFeelDefaults()), but no one of these work.
Edit: I also find this list of properties of the class JFileChooser, that contains some properties that do not appear int the UIDefaults keyset. The problem is: how programmatically get all this properties?
Edit: Example of code:
UIDefaults defaults = UIManager.getDefaults();
String thekey = "OptionPane.okButtonText";
System.out.println(thekey + ": " + UIManager.getString(thekey));
for (Enumeration e = defaults.keys(); e.hasMoreElements();) {
Object key = e.nextElement();
System.out.println(key + ": " + defaults.get(key));
}
this code return print these properties. The key "OptionPane.okButtonText" dont appear in the output.
This could be a problem with resourceBundles: the optionPane (as well as f.i. fileChooser and other) text properties are loaded from localized bundles. They are (used to be, not entirely sure if that's still the case) internal classes under com.sun.swing.internal.plaf. Maybe something's going wrong there ...
here's the snippet that worksforme:
String ok = "OptionPane.okButtonText";
String text = "";
text += " LAF: " + UIManager.getLookAndFeelDefaults().get(ok);
text += " lookup: " + UIManager.get(ok);
text += " default: " + UIManager.getDefaults().get(ok);
System.out.println(text);
// output, whereever I add that:
LAF: OK lookup: OK default: OK
independent of which LAF is currently installed. My system is win/vista, my default locale de
Edit: just to clarify - the localized resources are not necessarily direct entries in the keys()/entrySet(), these are methods in Hashtable which are not overridden in UIDefaults. So while the lookup as in my snippet should always work querying the enums is wrong - the entries are not there but in some cached maps which are fed by resourceBundles.
Edit2: added the def of ok (thought that would be ... obvious after talking for several hours about that key :-)
Edit3: for further experiments, we should probably lookup a value which differs more than "OK" across Locales, f.i. cancelButtonText
Edit 4 (the very last before a major break, promised :-) - as to "how-to find all localized values" is not possible without resorting to dirty means (aka: implementation details). The only way I can think of is to look into the resourceBundles which are - assumedly - loaded, like
import com.sun.swing.internal.plaf.basic.resources.basic;
String cancel = "OptionPane.cancelButtonText";
ListResourceBundle bundle = new basic();
for (String key : bundle.keySet()) {
if(cancel.equals(key)) {
System.out.println(key
+ ": " + bundle.getString(key));
}
}
It appears that OptionPane.okButtonText is a feature unique to Aqua available in all L&Fs, as shown using this approach that includes localized values not seen when iterating over the entrySet().
import javax.swing.UIDefaults;
import javax.swing.UIManager;
/** #see https://stackoverflow.com/questions/5729306 */
public class OptionPaneDefaults {
public static void main(String[] args) throws Exception {
UIManager.LookAndFeelInfo[] lfa =
UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo lf : lfa) {
UIManager.setLookAndFeel(lf.getClassName());
UIDefaults uid = UIManager.getLookAndFeelDefaults();
System.out.println("***"
+ " " + lf.getName()
+ " " + lf.getClassName()
+ " " + uid.size() + " entries");
String ok = "OptionPane.okButtonText";
String text = "";
text += " LAF: " + UIManager.getLookAndFeelDefaults().get(ok);
text += " lookup: " + UIManager.get(ok);
text += " default: " + UIManager.getDefaults().get(ok);
System.out.println(text);
}
}
}
Console, Mac OS X:
*** Metal javax.swing.plaf.metal.MetalLookAndFeel 636 entries
LAF: OK lookup: OK default: OK
*** Nimbus com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel 1054 entries
LAF: OK lookup: OK default: OK
*** CDE/Motif com.sun.java.swing.plaf.motif.MotifLookAndFeel 550 entries
LAF: OK lookup: OK default: OK
*** Mac OS X com.apple.laf.AquaLookAndFeel 711 entries
LAF: OK lookup: OK default: OK
Console, Windows 7:
*** Metal javax.swing.plaf.metal.MetalLookAndFeel 636 entries
LAF: OK lookup: OK default: OK
*** Nimbus com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel 1049 entries
LAF: OK lookup: OK default: OK
*** CDE/Motif com.sun.java.swing.plaf.motif.MotifLookAndFeel 550 entries
LAF: OK lookup: OK default: OK
*** Windows com.sun.java.swing.plaf.windows.WindowsLookAndFeel 637 entries
LAF: OK lookup: OK default: OK
*** Windows Classic com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel 637 entries
LAF: OK lookup: OK default: OK