At my internship, I was recently tasked with automating backups for a 2003 server. The goal was to do it preferably for free, of course ;) I hadn't a need to create a batch file in years, but knew I could get it done. The first batch file uses ntbackup for regular data. The second one does a backup of SQL data by calling TSQL files (.sql) generated in MS SQL Server Management Studio. This allows the SQL server to not have to be shut down to do backups. The third one date-stamps and copies the backup files to other locations. Each batch file is scheduled to run using the built-in Task Scheduler. Free and fun!
LEKnowlton
Posts
-
Programming Question -
Array of textboxes - can't access data [SOLVED.. by self]Hmm for some reason it says not a statement?
public class frmSubnet_Calculator extends javax.swing.JFrame {
private JTextField\[\] arrJTxtFldIntegerOctets; /\*\* Creates new form frmSubnet\_Calculator \*/ public frmSubnet\_Calculator() { initComponents(); // Center program on screen: setLocationRelativeTo(null); arrJTxtFldIntegerOctets = {jTxtFldIntegerOctet1, // error message starts here jTxtFldIntegerOctet2, jTxtFldIntegerOctet3, jTxtFldIntegerOctet4, jTxtFldIntegerOctet5, jTxtFldIntegerOctet6, jTxtFldIntegerOctet7, jTxtFldIntegerOctet8 };
Nagy Vilmos wrote:
You could use the same line as you had befor:
public Class GuiForm extends JFrame {
// define the array as a member variable, uninitialised:
private JTextField[] arrJTxtFld;
public GuiForm() {
initComponents();
// now you can use the UI components
this.arrJTxtFld = {jTextField1, jTextField2, jTextField3};
}
} -
Array of textboxes - can't access data [SOLVED.. by self]And then it hit me! A blast from my C# past! All I had to do was just add the following code just under the initComponents(): arrJTxtFld[0] = jTextField1; arrJTxtFld[1] = jTextField2; arrJTxtFld[2] = jTextField3; Now if I could only automate those assignments in a loop! lol A thanks to Naerling for responding earlier this morning with the same solution. I'd figured it out right before going to bed last night.
-
Array of textboxes - can't access data [SOLVED.. by self]Hello All, I'm using Netbeans 7.01 and I'm trying to validate input in 2 textboxes by running a validation loop. So, I decided to create an Array of textboxes, using existing textboxes already placed on the form. When I try to access a value in the Array, a nullpointerexception is thrown. Here is part of my code:
// This is an event that is supposed to clear the contents
// of a third jTextField, if the first input box
// has a key typed in it:private void jTextField1KeyTyped(java.awt.event.KeyEvent evt)
{
// Clear previous result in jTextField3,
// if jTextField1 text is changed:arrJTxtFld[2].setText(""); // This is where the nullpointerexception occurs
}// This is the code for the JTextField array:
private JTextField[] arrJTxtFld = {jTextField1, jTextField2, jTextField3};
-
Input validation loop issue - JAVA [SOLVED]From what I've gleaned from searches on this: I'm thinking that instead of strictly using the mouse click event for each button that I can use the actionevent listener and set up a case logic structure to choose which action does what.
-
Input validation loop issue - JAVA [SOLVED]I totally agree! I let myself get hung up on not breaking the loop. Bad input should break the loop, since proper input is mandatory. I've pretty much just started learning java on my own, but had taken a C# course last semester, so I have a little bit of a leg up on it. For a linux class project, I'm going to make an IPV4 subnet calculator using the linux Netbeans IDE. So, I thought I'd make a simple GUI program in Netbeans to figure out the GUI mechanics. The program this code is from is a drastically simple calculator that adds two floats (if valid) and displays the result in a third textbox. Now, its just a matter of figuring out how to get mnemonics and keybinds to work for the Add, Clear and Exit buttons. The Netbeans IDE isn't all that clear on how to do that, so the digging for information continues :) Thanks for your time on this rather simple fix!
-
Input validation loop issue - JAVA [SOLVED]@Richard You know, I thought of that and that would be the easiest way out. I was hoping there was a way to keep the loop going, but, I guess I was in denial! lol ;) Thanks for your help!
-
Input validation loop issue - JAVA [SOLVED]@Richard Yes, I agree that using the formatting codes makes the code much more readable! As far as my code goes: Ah I understand what your saying about using the OR instead of AND, but I don't think I'm having a problem with that because each inputValidArray is negated using the exclamation. So, the loop will not be broken unless both are not false. I could have used: while (!(inputValidArray[0] && inputValidArray[1])) instead. I think my main issue is that I can't get the code to stop and allow the user to fix the input in jTextField1 after it determines the input is bad. I set the focus and highlight it, but the code continues on and looks at jTextField2 and does what it should. Then it comes back up and checks input one again, which is already 'bad' and basically creates a loop I have to manually break out of. Does that make sense? Thanks!
-
Input validation loop issue - JAVA [SOLVED]Oh, I didn't have the code highlighted first and it showed up at the top of my code. So, I copied the and put it at the end of my code (but forgot to delete it from the top). :doh: Should be all set now for review!
-
Input validation loop issue - JAVA [SOLVED]Edited, sorry, didn't know that the
was needed around the code. Thanks!
-
Input validation loop issue - JAVA [SOLVED]Hello All, I'm trying to validate two input text boxes and am running into a snag. I'm using a while loop that runs while either one of the inputs is 'false'. The problem is that it doesn't stop and allow for a user to correct the first input if its bad and goes on to check the next input. I could do this before when I just checked one input at time and called the validate method twice. Trying to do both in one method is proving to be a pain. Any ideas? Here's my validate method:
private boolean validateInput(String input1, String input2)
{Boolean\[\] inputValidArray = {false , false}; String\[\] inputArray = {input1, input2}; JTextField\[\] textFieldArray = {jTextField1, jTextField2}; float numberToValidate = 0; int counter = 0; String errorMessage = ""; while (!inputValidArray\[0\] || !inputValidArray\[1\]) { try { // Check for empty or null input if (!(inputArray\[counter\].isEmpty() || inputArray\[counter\] == null)) { numberToValidate = Float.valueOf(inputArray\[counter\]); inputValidArray\[counter\] = true; } else { errorMessage = "This field can not be left blank!\\n" + " Please enter a valid number!\\n" + " (example: 123.45 or -123.45)"; Create\_Error\_Message\_Dialog\_Box(errorMessage); textFieldArray\[counter\].requestFocusInWindow(); } } catch (NumberFormatException nfe) { errorMessage = inputArray\[counter\] + " is not a valid number!\\n" + "Please enter a valid number!\\n" + "(example: 123.45 or -123.45)"; Create\_Error\_Message\_Dialog\_Box(errorMessage); textFieldArray\[counter\].requestFocusInWindow(); textFieldArray\[counter\].selectAll(); } counter += 1; } return (inputValidArray\[0\] && inputValidArray\[1\]); }