Search Results

Search found 8 results on 1 pages for 'raptrex'.

Page 1/1 | 1 

  • How to call JDialog with Netbeans

    - by Raptrex
    Yesterday I asked this question: Is this possible to make as an option dialog? and I learned it could be made with JDialog. I'm using Netbeans GUI editor and made a button that will call my custom JDialog I designed in the GUI editor. The JDialog is called jDialog1. How do I call the jDialog1 with the button? private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

    Read the article

  • Java calendar getting weekdays not working

    - by Raptrex
    I am trying to get this to output all the weekdays (MON-FRI) between 5/16/2010 (a sunday) and 5/25/2010 (a tuesday). The correct output should be 17,18,19,20,21,24,25. However, the result im getting is 17,18,19,20,21,17,18,19. The other methods just split up the string the date is in import java.util.*; public class test { public static void main(String[] args) { String startTime = "5/16/2010 11:44 AM"; String endTime = "5/25/2010 12:00 PM"; GregorianCalendar startCal = new GregorianCalendar(); startCal.setLenient(true); String[] start = splitString(startTime); //this sets year, month day startCal.set(Integer.parseInt(start[2]),Integer.parseInt(start[0])-1,Integer.parseInt(start[1])); startCal.set(GregorianCalendar.HOUR, Integer.parseInt(start[3])); startCal.set(GregorianCalendar.MINUTE, Integer.parseInt(start[4])); if (start[5].equalsIgnoreCase("AM")) { startCal.set(GregorianCalendar.AM_PM, 0); } else { startCal.set(GregorianCalendar.AM_PM, 1); } GregorianCalendar endCal = new GregorianCalendar(); endCal.setLenient(true); String[] end = splitString(endTime); endCal.set(Integer.parseInt(end[2]),Integer.parseInt(end[0])-1,Integer.parseInt(end[1])); endCal.set(GregorianCalendar.HOUR, Integer.parseInt(end[3])); endCal.set(GregorianCalendar.MINUTE, Integer.parseInt(end[4])); if (end[5].equalsIgnoreCase("AM")) { endCal.set(GregorianCalendar.AM_PM, 0); } else { endCal.set(GregorianCalendar.AM_PM, 1); } for (int i = startCal.get(Calendar.DATE); i < endCal.get(Calendar.DATE); i++) { startCal.set(Calendar.DATE, i); startCal.set(Calendar.DAY_OF_WEEK, i); if (startCal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) { System.out.println("\t" + startCal.get(Calendar.DATE)); } } } private static String[] splitDate(String date) { String[] temp1 = date.split(" "); // split by space String[] temp2 = temp1[0].split("/"); // split by / //5/21/2010 10:00 AM return temp2; // return 5 21 2010 in one array } private static String[] splitTime(String date) { String[] temp1 = date.split(" "); // split by space String[] temp2 = temp1[1].split(":"); // split by : //5/21/2010 10:00 AM String[] temp3 = {temp2[0], temp2[1], temp1[2]}; return temp3; // return 10 00 AM in one array } private static String[] splitString(String date) { String[] temp1 = splitDate(date); String[] temp2 = splitTime(date); String[] temp3 = new String[6]; return dateFill(temp3, temp2[0], temp2[1], temp2[2], temp1[0], temp1[1], temp1[2]); } private static String[] dateFill(String[] date, String hours, String minutes, String ampm, String month, String day, String year) { date[0] = month; date[1] = day; date[2] = year; date[3] = hours; date[4] = minutes; date[5] = ampm; return date; } private String dateString(String[] date) { //return month+" "+day+", "+year+" "+hours+":"+minutes+" "+ampm //5/21/2010 10:00 AM return date[3]+"/"+date[4]+"/ "+date[5]+" "+date[0]+":"+date[1]+" "+date[2]; } }

    Read the article

  • How to call custom JDialog built with Netbeans GUI editor?

    - by Raptrex
    Yesterday I asked this question: Is this possible to make as an option dialog? and I learned it could be made with JDialog. I'm using Netbeans GUI editor and made a button that will call my custom JDialog I designed in the GUI editor. The JDialog is called jDialog1. How do I call the jDialog1 with the button? private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }

    Read the article

  • Value isnt being saved in the strings

    - by Raptrex
    I'm trying to make a class where I put a key and value into the put method which puts the key in the k string array and value into the v string array, however it is not being saved in the array when I do get or display. For example: put(dan,30) get(dan) returns null display returns null null 10 times. Anyone know whats wrong? public class Memory { final int INITIAL_CAPACITY = 10; String[] k = new String[INITIAL_CAPACITY]; String[] v = new String[INITIAL_CAPACITY]; int count = 0; public Memory() { count = 0; } public int size() { return count; } public void put(String key, String value) { int a = 0; boolean found = false; for (int i = 0; i < k.length; i++) { //System.out.println("key is " + key.equals(k[i])); if (key.equalsIgnoreCase(k[i])) { v[i] = value; found = true; } if (found) break; a++; } //System.out.println(a == k.length); if (a == k.length); { k[count] = key; v[count] = value; //System.out.println(k[count] + " " + v[count]); count++; //System.out.println(count); } } public String get(String key) { String output = "a"; for(int i = 0; i < k.length; i++) { if(!key.equalsIgnoreCase(k[i])) { output = null; } else { output = v[i]; return output; } } return output; } public void clear() { for (int i = 0; i < k.length; i++) { k[i] = null; v[i] = null; } count = 0; } public void display() { for (int i = 0; i < k.length; i++) { System.out.println(k[i] + " " + v[i]); } } }

    Read the article

  • Java calendar day_of_week not working

    - by Raptrex
    I have a for loop starting at startTime going up to endTime and I would like it to print out the date if it is either a monday, tuesday, wednesday, thursday, or friday. Currently, it is only printing out the endTime date. The other stuff splits the string, which you can ignore. Since 5/16/2010 is a sunday, it should print out 17,18,19,20,21, 24 and 25. However it only prints 25 import java.util.*; public class test { public static void main(String[] args) { String startTime = "5/16/2010 11:44 AM"; String endTime = "5/25/2010 12:00 PM"; GregorianCalendar startCal = new GregorianCalendar(); startCal.setLenient(true); String[] start = splitString(startTime); //this sets year, month day startCal.set(Integer.parseInt(start[2]),Integer.parseInt(start[0])-1,Integer.parseInt(start[1])); startCal.set(GregorianCalendar.HOUR, Integer.parseInt(start[3])); startCal.set(GregorianCalendar.MINUTE, Integer.parseInt(start[4])); if (start[5].equalsIgnoreCase("AM")) { startCal.set(GregorianCalendar.AM_PM, 0); } else { startCal.set(GregorianCalendar.AM_PM, 1); } GregorianCalendar endCal = new GregorianCalendar(); endCal.setLenient(true); String[] end = splitString(endTime); endCal.set(Integer.parseInt(end[2]),Integer.parseInt(end[0])-1,Integer.parseInt(end[1])); endCal.set(GregorianCalendar.HOUR, Integer.parseInt(end[3])); endCal.set(GregorianCalendar.MINUTE, Integer.parseInt(end[4])); if (end[5].equalsIgnoreCase("AM")) { endCal.set(GregorianCalendar.AM_PM, 0); } else { endCal.set(GregorianCalendar.AM_PM, 1); } for (int i = startCal.get(Calendar.DATE); i < endCal.get(Calendar.DATE); i++) { if (startCal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) { startCal.set(Calendar.DATE, i); System.out.println(startCal.get(Calendar.DATE)); } } } private static String[] splitDate(String date) { String[] temp1 = date.split(" "); // split by space String[] temp2 = temp1[0].split("/"); // split by / //5/21/2010 10:00 AM return temp2; // return 5 21 2010 in one array } private static String[] splitTime(String date) { String[] temp1 = date.split(" "); // split by space String[] temp2 = temp1[1].split(":"); // split by : //5/21/2010 10:00 AM String[] temp3 = {temp2[0], temp2[1], temp1[2]}; return temp3; // return 10 00 AM in one array } private static String[] splitString(String date) { String[] temp1 = splitDate(date); String[] temp2 = splitTime(date); String[] temp3 = new String[6]; return dateFill(temp3, temp2[0], temp2[1], temp2[2], temp1[0], temp1[1], temp1[2]); } private static String[] dateFill(String[] date, String hours, String minutes, String ampm, String month, String day, String year) { date[0] = month; date[1] = day; date[2] = year; date[3] = hours; date[4] = minutes; date[5] = ampm; return date; } private String dateString(String[] date) { //return month+" "+day+", "+year+" "+hours+":"+minutes+" "+ampm //5/21/2010 10:00 AM return date[3]+"/"+date[4]+"/ "+date[5]+" "+date[0]+":"+date[1]+" "+date[2]; } }

    Read the article

1