Tag Archives: text

How to register Spring @Configuration annotated class instead of applicationContext.xml file in web.xml?

Questions: I am using jsf and spring together in web application. I have configured datasource and session factory in one configuration class which uses annotations like @Configuration, @ComponentScan etc. I don’t have any applicationContext.xml file in my project as I am handling every entry of context xml in Configuration class. The test case works successfully… Read More »

Role/Purpose of ContextLoaderListener in Spring?

Questions: I am learning Spring Framework which is being used in my project. I found the ContextLoaderListener entry in my web.xml file. But could not figure out how exactly it helps a developer? In the official documentation of ContextLoaderListener it says it is to start WebApplicationContext. Regarding WebApplicationContext JavaDocs say: Interface to provide configuration for… Read More »

Java : JFormattedTextField saving numbers

Questions: In my application I want to input numbers (amounts) to a specific limit, and hence have used JFormattedTextField. Limit like “12345678.99” i.e. 8 digits before “.” and 2 after “.” or so on. This is my implementation code, but it doesn’t result as expected. startBalTxt.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat(“########.##”)))); startBalTxt.setText(resourceMap.getString(“startBalTxt.text”)); // NOI18N startBalTxt.setFont(Utility.getTextFont()); startBalTxt.setName(“startBalTxt”); //… Read More »

JTextPane formatting [closed]

Questions: I have a JTextPane where I want to add lines and depending on their content have them have a different formatting. Currently I have this StyleContext context = new StyleContext(); StyledDocument document = new DefaultStyledDocument(context); Style styleBold = context.getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setBold(styleBold, true); StyleConstants.setFontSize(styleBold, 18); Style styleNorm = context.getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setFontSize(styleNorm, 15); for (int i = 0;… Read More »

IText merge documents with acrofields

Questions: I currently have a PdfReader and a PdfStamper that I am filling out the acrofields with. I now have to copy another pdf to the end of that form I have been filling out and when I do I lose the acrofield on the new form I copy over. Here is the code. public… Read More »

JTextField limiting character amount input and accepting numeric only

Questions: here’s the code that i have on how to limit the character input length class JTextFieldLimit extends PlainDocument { private int limit; // optional uppercase conversion private boolean toUppercase = false; JTextFieldLimit(int limit) { super(); this.limit = limit; } JTextFieldLimit(int limit, boolean upper) { super(); this.limit = limit; toUppercase = upper; } @Override public… Read More »

Rotating a JTextField vertically

Questions: I’ve seen a number of questions that ask how to rotate a JLabel or image at an arbitrary angle. All I need to do is rotate my text field 90 degrees, but I haven’t found an easier way specifically for that angle. I thought I copied the answers correctly, but my text field is… Read More »

How can I add a JTextField to a JFrame's MenuBar?

Questions: I’ve been trying to overload JMenu and put in some custom code to support a JTextField but that isn’t going well. My main purpose here is to add a search field to the right of my menu items. So I have something like File, Edit, help on the left and then on the right… Read More »

How to UnFocus a JTextField

Questions: When my application loads, which is made using netbeans, the first JTextField is automatically focused, and in this JTextField, I have written “Enter your Username”, it will go away when the user clicks on this field, but when the application is loaded, this field is focused, means I can’t see “Enter your Username”, how… Read More »