package net.bunnie.jgm; // import things for window import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.ColorUIResource; import javax.swing.text.*; import net.bunnie.*; // java -Dhhtp.proxyHost=192.168.5.1 -classpath .;Z:\java\files\oalnf\oalnf.jar EntryGUI // August 1 public class EntryGUIAdd extends JFrame implements ActionListener { String command; String[] titles = {"Morning", "Afternoon", "Evening"}; String[] time = {"Detect Time", "Set Time"}; String[] weekdays = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; String[] monthDays = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"}; String[] hour = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; String[] minutes = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"}; String[] seconds = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"}; String[] ampm = {"a.m.", "p.m."}; String superString = "JGreymatter"; JLabel header; JLabel top; JLabel top2; JLabel thisWillBe; JLabel bottom; JLabel copyLabel; JLabel blank1; JLabel blank2; JLabel blank3; JPanel all; JPanel borderP; JPanel timePanel; JPanel top3Panel; JPanel draftPanel; JPanel copyPanel; JPanel rbPanel; JPanel topTextP; JTextArea entryMain; JTextArea entryMore; JTextField year; JButton addButton; JButton draftButton; JButton backToMain; JRadioButton continueButton; JRadioButton finishButton; ButtonGroup draftBG; JComboBox titlesCB; JComboBox timeCB; JComboBox insertCB; JComboBox weekdaysCB; JComboBox monthsCB; JComboBox monthDaysCB; JComboBox hourCB; JComboBox minutesCB; JComboBox secondsCB; JComboBox ampmCB; JScrollPane mainJSP; JScrollPane moreJSP; JPopupMenu popup; JMenuItem menuItem; JMenuItem menuCopy; JMenuItem menuCut; JMenuItem menuAll; TitledBorder headerBorder; GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); Font smallFont = new Font("Tahoma", Font.PLAIN, 13); Font smallFont2 = new Font("Tahoma", Font.PLAIN, 9); Font bigFont = new Font("Tahoma", Font.PLAIN, 36); Color blueish = new Color(100, 150, 230); Color blueishBG = new Color(217, 234, 255); String[] mostRecent; int mostRecentN = 0; String headerText = "JGreymatter"; String firstLabel = "Add An Entry"; String thisEntryWillBe = "Entry number: "; String firstLabel2 = "Main: "; String secondLabel = "More: "; String copyright = "©2003 Bunnie Network"; int leapYear = 0; int getListing = 0; String getLS = ""; Calendar jgmTime; JComboBox whichBoxIsIt; String toInsert = ""; int carStart = 0; int carFin = 0; String mouseRightClick = ""; public void setCurrentTime() { jgmTime = Calendar.getInstance(TimeZone.getTimeZone("America/New_York"), Locale.US); weekdaysCB.setSelectedItem(weekdays[jgmTime.get(Calendar.DAY_OF_WEEK) - 1]); monthsCB.setSelectedItem(months[jgmTime.get(Calendar.MONTH)]); monthDaysCB.setSelectedItem("" + jgmTime.get(Calendar.DAY_OF_MONTH)); minutesCB.setSelectedItem("" + jgmTime.get(Calendar.MINUTE)); secondsCB.setSelectedItem("" + jgmTime.get(Calendar.SECOND)); year.setText("" + jgmTime.get(Calendar.YEAR)); if (jgmTime.get(Calendar.HOUR_OF_DAY) >= 18) { titlesCB.setSelectedItem("Evening"); hourCB.setSelectedItem("" + (jgmTime.get(Calendar.HOUR))); ampmCB.setSelectedItem("p.m."); } else if (jgmTime.get(Calendar.HOUR_OF_DAY) >= 12) { titlesCB.setSelectedItem("Afternoon"); if (jgmTime.get(Calendar.HOUR_OF_DAY) == 12) { hourCB.setSelectedItem("12"); } else { hourCB.setSelectedItem("" + (jgmTime.get(Calendar.HOUR))); } ampmCB.setSelectedItem("p.m."); } else { titlesCB.setSelectedItem("Morning"); if (jgmTime.get(Calendar.HOUR_OF_DAY) == 0) { hourCB.setSelectedItem("12"); } else { hourCB.setSelectedItem("" + (jgmTime.get(Calendar.HOUR))); } ampmCB.setSelectedItem("a.m."); } } public int currentEntryNumber () { mostRecent = ToFileArray.toFileArrayF("http://bunnie.net/blog/past/java.php?get=recent"); mostRecent[0] = Regex.replace("\n", "", mostRecent[0]); int mostRecentN = Integer.parseInt(mostRecent[0]) + 1; return mostRecentN; } public void canBeAnOption() { if (entryMain.getSelectedText() == null) { menuCopy.setEnabled(false); menuCut.setEnabled(false); } else { menuCopy.setEnabled(true); menuCut.setEnabled(true); } if (entryMain.getText().equals("")) { menuAll.setEnabled(false); } else { menuAll.setEnabled(true); } //if (entrymain.getText().equals(entryMain.paste() } public EntryGUIAdd() { super("JGreymatter"); Container c = getContentPane(); c.setBackground(Color.white); c.setLayout(new FlowLayout(FlowLayout.CENTER, 3, 3)); headerBorder = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(blueish), superString, TitledBorder.LEFT, TitledBorder.TOP, smallFont, blueish); all = new JPanel(); all.setBackground(Color.white); all.setBorder(BorderFactory.createLineBorder(Color.white, 5)); all.setLayout(gbl); borderP = new JPanel(); borderP.setBackground(Color.white); borderP.setBorder(headerBorder); timePanel = new JPanel(); timePanel.setBackground(Color.white); timePanel.setLayout(new GridLayout(2, 4)); top3Panel = new JPanel(); top3Panel.setBackground(Color.white); top3Panel.setLayout(new GridLayout(1, 3)); draftPanel = new JPanel(); draftPanel.setBackground(Color.white); draftPanel.setLayout(new GridLayout(1, 2)); copyPanel = new JPanel(); copyPanel.setBackground(Color.white); copyPanel.setLayout(new GridLayout(1, 3)); rbPanel = new JPanel(); rbPanel.setBackground(Color.white); rbPanel.setLayout(new GridLayout(1, 2)); topTextP = new JPanel(); topTextP.setBackground(Color.white); topTextP.setLayout(new GridLayout(2, 1)); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1; gbc.weighty = 0; gbc.gridx = 0; gbc.ipadx = 0; gbc.ipady = 0; mostRecentN = currentEntryNumber(); thisEntryWillBe += ToFileArray.entryFormat(mostRecentN); header = new JLabel(headerText, JLabel.CENTER); header.setFont(bigFont); header.setForeground(blueish); top = new JLabel(firstLabel, JLabel.CENTER); top.setFont(smallFont); top.setForeground(blueish); top2 = new JLabel(firstLabel2, JLabel.LEFT); top2.setFont(smallFont); top2.setForeground(blueish); thisWillBe = new JLabel(thisEntryWillBe, JLabel.CENTER); thisWillBe.setFont(smallFont); thisWillBe.setForeground(blueish); blank1 = new JLabel(" ", JLabel.CENTER); blank1.setForeground(Color.white); blank2 = new JLabel(" ", JLabel.CENTER); blank2.setForeground(Color.white); blank2.setFont(new Font("Tahoma", Font.PLAIN, 4)); blank3 = new JLabel(" ", JLabel.CENTER); blank3.setForeground(Color.white); blank3.setFont(new Font("Tahoma", Font.PLAIN, 4)); bottom = new JLabel(secondLabel, JLabel.LEFT); bottom.setFont(smallFont); bottom.setForeground(blueish); copyLabel = new JLabel(copyright, JLabel.RIGHT); copyLabel.setFont(smallFont); copyLabel.setForeground(blueish); UIManager.put("ScrollBar.foreground", new ColorUIResource(blueish)); UIManager.put("ScrollBar.background", new ColorUIResource(Color.white)); UIManager.put("ScrollBar.highlight", new ColorUIResource(new Color(204, 204, 204))); UIManager.put("ScrollBar.shadow", new ColorUIResource(Color.white)); UIManager.put("ScrollBar.thumb", new ColorUIResource(blueish)); UIManager.put("ScrollBar.thumbShadow", new ColorUIResource(Color.black)); UIManager.put("ScrollBar.thumbHighlight", new ColorUIResource(Color.white)); UIManager.put("ScrollBar.track", new ColorUIResource(Color.white)); //UIManager.put("RadioButton.select", new ColorUIResource(blueish)); //UIManager.put("RadioButtonMenuItem.selectionBackground", new ColorUIResource(blueish)); //UIManager.put("PopupMenu.background", new ColorUIResource(blueish)); UIManager.put("MenuItem.background", new ColorUIResource(Color.white)); UIManager.put("MenuItem.selectionBackground", new ColorUIResource(Color.white)); UIManager.put("MenuItem.foreground", new ColorUIResource(blueish)); UIManager.put("MenuItem.selectionForeground", new ColorUIResource(Color.black)); UIManager.put("MenuItem.font", smallFont); UIManager.put("RadioButton.focus", new ColorUIResource(Color.white)); UIManager.put("MenuItem.border", BorderFactory.createLineBorder(Color.white)); //UIManager.put("PopupMenuUI", new BasicPopupMenuUI()); //UIManager.put("MenuUI", "javax.swing.plaf.basic.BasicMenuUI"); UIManager.put("MenuItemUI", "javax.swing.plaf.basic.BasicMenuItemUI"); UIManager.put("MenuItem.acceleratorSelectionForeground", new ColorUIResource(Color.black)); UIManager.put("MenuItem.acceleratorForeground", new ColorUIResource(blueish)); //UIManager.put("RadioButtonUI", "javax.swing.plaf.metal.MetalRadioButtonUI"); Caret care = new DefaultCaret(); care.setBlinkRate(500); Caret careMain = new DefaultCaret(); careMain.setBlinkRate(500); Caret careMore = new DefaultCaret(); careMore.setBlinkRate(500); JGMCellRenderer myRenderer = new JGMCellRenderer(); entryMain = new JTextArea(1, 15); entryMain.setBackground(Color.white); entryMain.setBorder(BorderFactory.createLineBorder(Color.white, 5)); entryMain.setCaret(careMain); entryMain.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); entryMain.setFont(smallFont); entryMain.setForeground(blueish); entryMain.setLineWrap(true); entryMain.setSelectedTextColor(blueish); entryMain.setSelectionColor(blueishBG); entryMain.setWrapStyleWord(true); mainJSP = new JScrollPane(entryMain); mainJSP.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); mainJSP.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); entryMain.addKeyListener(new KeyListener() { public void keyTyped (KeyEvent ev) { } public void keyReleased (KeyEvent ev) { } public void keyPressed (KeyEvent ev) { if ((ev.getModifiers() & InputEvent.CTRL_MASK) > 0) { if (ev.getKeyCode() == KeyEvent.VK_C) { entryMain.copy(); } if (ev.getKeyCode() == KeyEvent.VK_X) { entryMain.cut(); } if (ev.getKeyCode() == KeyEvent.VK_V) { entryMain.paste(); } if (ev.getKeyCode() == KeyEvent.VK_A) { entryMain.selectAll(); } } } }); entryMore = new JTextArea(1, 15); entryMore.setBackground(Color.white); entryMore.setBorder(BorderFactory.createLineBorder(Color.white, 5)); entryMore.setCaret(careMore); entryMore.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); entryMore.setFont(smallFont); entryMore.setForeground(blueish); entryMore.setLineWrap(true); entryMore.setSelectedTextColor(blueish); entryMore.setSelectionColor(blueishBG); entryMore.setWrapStyleWord(true); moreJSP = new JScrollPane(entryMore); moreJSP.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); moreJSP.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); year = new JTextField("2003", 4); year.setBackground(Color.white); year.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 3))); year.setCaret(care); year.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); year.setFont(smallFont2); year.setForeground(blueish); year.setSelectedTextColor(blueish); year.setSelectionColor(blueishBG); popup = new JPopupMenu(); menuCopy = new JMenuItem("Copy"); menuCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); menuCopy.addActionListener(this); popup.add(menuCopy); menuCut = new JMenuItem("Cut"); menuCut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); menuCut.addActionListener(this); popup.add(menuCut); menuItem = new JMenuItem("Paste"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem); menuAll = new JMenuItem("Select All"); menuAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); menuAll.addActionListener(this); canBeAnOption(); popup.add(menuAll); popup.addSeparator(); menuItem = new JMenuItem("Dull Entry"); menuItem.addActionListener(this); popup.add(menuItem); menuItem = new JMenuItem("Entry Reference"); menuItem.addActionListener(this); popup.add(menuItem); menuItem = new JMenuItem("Image HTML"); menuItem.addActionListener(this); popup.add(menuItem); popup.setLabel("Main entry text options"); popup.setBorder(new CompoundBorder(BorderFactory.createBevelBorder(0, Color.white, blueish, Color.white, new Color(99, 101, 111)), BorderFactory.createLineBorder(Color.white, 2))); entryMain.addMouseListener(new MouseAdapter() { public void mouseReleased (MouseEvent e) { if (e.isPopupTrigger()) { canBeAnOption(); entryMain.grabFocus(); popup.show(e.getComponent(), e.getX(), e.getY()); } } }); titlesCB = new JComboBox(titles); titlesCB.setBackground(Color.white); titlesCB.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 2))); titlesCB.setFont(smallFont); titlesCB.setForeground(blueish); titlesCB.setRenderer(myRenderer); timeCB = new JComboBox(time); timeCB.setBackground(Color.white); timeCB.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 2))); timeCB.setFont(smallFont); timeCB.setForeground(blueish); timeCB.setRenderer(myRenderer); timeCB.addActionListener(this); /*insertCB = new JComboBox(insert); insertCB.setBackground(Color.white); insertCB.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 2))); insertCB.setFont(smallFont); insertCB.setForeground(blueish); insertCB.setRenderer(myRenderer); insertCB.addActionListener(this);*/ weekdaysCB = new JComboBox(weekdays); weekdaysCB.setBackground(Color.white); weekdaysCB.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 2))); weekdaysCB.setFont(smallFont2); weekdaysCB.setForeground(blueish); weekdaysCB.setRenderer(myRenderer); monthsCB = new JComboBox(months); monthsCB.setBackground(Color.white); monthsCB.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 2))); monthsCB.setFont(smallFont2); monthsCB.setForeground(blueish); monthsCB.setRenderer(myRenderer); monthsCB.addActionListener(this); monthDaysCB = new JComboBox(monthDays); monthDaysCB.setBackground(Color.white); monthDaysCB.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 2))); monthDaysCB.setFont(smallFont2); monthDaysCB.setForeground(blueish); monthDaysCB.setRenderer(myRenderer); hourCB = new JComboBox(hour); hourCB.setBackground(Color.white); hourCB.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 2))); hourCB.setFont(smallFont2); hourCB.setForeground(blueish); hourCB.setRenderer(myRenderer); minutesCB = new JComboBox(minutes); minutesCB.setBackground(Color.white); minutesCB.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 2))); minutesCB.setFont(smallFont2); minutesCB.setForeground(blueish); minutesCB.setRenderer(myRenderer); secondsCB = new JComboBox(seconds); secondsCB.setBackground(Color.white); secondsCB.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 2))); secondsCB.setFont(smallFont2); secondsCB.setForeground(blueish); secondsCB.setRenderer(myRenderer); ampmCB = new JComboBox(ampm); ampmCB.setBackground(Color.white); ampmCB.setBorder(new CompoundBorder(BorderFactory.createLineBorder(blueish), BorderFactory.createLineBorder(Color.white, 2))); ampmCB.setFont(smallFont2); ampmCB.setForeground(blueish); ampmCB.setRenderer(myRenderer); addButton = new JButton("Add this entry"); addButton.setBackground(Color.white); addButton.setBorder(new CompoundBorder(BorderFactory.createLineBorder(Color.white, 3), new CompoundBorder(BorderFactory.createBevelBorder(0, Color.white, blueish, Color.white, new Color(99, 101, 111)), BorderFactory.createLineBorder(Color.white, 3)))); //addButton.setBorder(UIManager.getBorder(new JButton())); addButton.setFont(smallFont); addButton.setForeground(blueish); draftButton = new JButton("Draft it"); draftButton.setBackground(Color.white); draftButton.setBorder(new CompoundBorder(BorderFactory.createLineBorder(Color.white, 3), new CompoundBorder(BorderFactory.createBevelBorder(0, Color.white, blueish, Color.white, new Color(99, 101, 111)), BorderFactory.createLineBorder(Color.white, 3)))); draftButton.setFont(smallFont); draftButton.setForeground(blueish); backToMain = new JButton("Main"); backToMain.setBackground(Color.white); backToMain.setBorder(new CompoundBorder(BorderFactory.createLineBorder(Color.white, 3), new CompoundBorder(BorderFactory.createBevelBorder(0, Color.white, blueish, Color.white, new Color(99, 101, 111)), BorderFactory.createLineBorder(Color.white, 3)))); backToMain.setFont(smallFont); backToMain.setForeground(blueish); continueButton = new JRadioButton(" Continue", true); continueButton.setBackground(Color.white); continueButton.setFont(smallFont); continueButton.setForeground(blueish); finishButton = new JRadioButton(" Finish"); finishButton.setBackground(Color.white); finishButton.setFont(smallFont); finishButton.setForeground(blueish); draftBG = new ButtonGroup(); draftBG.add(continueButton); draftBG.add(finishButton); setCurrentTime(); rbPanel.add(continueButton); rbPanel.add(finishButton); timePanel.add(weekdaysCB); timePanel.add(monthsCB); timePanel.add(monthDaysCB); timePanel.add(year); timePanel.add(hourCB); timePanel.add(minutesCB); timePanel.add(secondsCB); timePanel.add(ampmCB); top3Panel.add(timeCB); top3Panel.add(thisWillBe); top3Panel.add(titlesCB); //top3Panel.add(insertCB); draftPanel.add(rbPanel); draftPanel.add(draftButton); copyPanel.add(backToMain); copyPanel.add(blank1); copyPanel.add(copyLabel); //topTextP.add(top); //topTextP.add(thisWillBe); gbc.gridy = 0; gbl.setConstraints(header, gbc); all.add(header); gbc.gridy = 1; gbc.ipady = 15; gbl.setConstraints(top, gbc); all.add(top); gbc.gridy = 2; gbc.ipady = 0; gbl.setConstraints(top3Panel, gbc); all.add(top3Panel); gbc.gridy = 3; gbl.setConstraints(blank2, gbc); all.add(blank2); gbc.gridy = 4; gbl.setConstraints(timePanel, gbc); all.add(timePanel); gbc.gridy = 5; gbc.ipady = 10; gbl.setConstraints(top2, gbc); all.add(top2); gbc.gridy = 6; gbc.ipady = 150; gbl.setConstraints(mainJSP, gbc); all.add(mainJSP); gbc.gridy = 7; gbc.ipady = 10; gbl.setConstraints(bottom, gbc); all.add(bottom); gbc.gridy = 8; gbc.ipady = 80; gbl.setConstraints(moreJSP, gbc); all.add(moreJSP); gbc.gridy = 9; gbc.ipady = 0; gbl.setConstraints(draftPanel, gbc); all.add(draftPanel); gbc.gridy = 10; gbl.setConstraints(addButton, gbc); all.add(addButton); gbc.gridy = 11; gbc.gridheight = GridBagConstraints.REMAINDER; gbl.setConstraints(copyPanel, gbc); all.add(copyPanel); borderP.add(all); c.add(borderP); } public void actionPerformed (ActionEvent e) { command = e.getActionCommand(); try { whichBoxIsIt = (JComboBox) e.getSource(); command = (String) whichBoxIsIt.getSelectedItem(); if (command.equals("Detect Time")) { setCurrentTime(); } if (command.equals("Dull Entry")) { toInsert = "<-- begin of my dull entry -->\nDull entry text goes here.\n<-- end of my dull entry -->\n\n"; entryMain.replaceSelection(toInsert); // entryMain.insert(toInsert, entryMain.getCaretPosition()); } if (command.equals("Entry Reference")) { toInsert = "entry number "; entryMain.insert(toInsert, entryMain.getCaretPosition()); } if (command.equals("Image HTML")) { toInsert = "\"\"\n\n"; entryMain.insert(toInsert, entryMain.getCaretPosition()); } getLS = (String) monthDaysCB.getItemAt(monthDaysCB.getItemCount() - 1); getListing = Integer.parseInt(getLS); if (command.equals("January") || command.equals("March") || command.equals("May") || command.equals("July") || command.equals("August") || command.equals("October") || command.equals("December")) { if (getListing != 31) { if (getListing != 30) { if (getListing != 29) { if (getListing != 28) { monthDaysCB.addItem("28"); } monthDaysCB.addItem("29"); } monthDaysCB.addItem("30"); } monthDaysCB.addItem("31"); } } if (command.equals("September") || command.equals("April") || command.equals("June") || command.equals("November")) { if (getListing != 30) { if (getListing > 30) { monthDaysCB.removeItemAt(getListing - 1); } else { if (getListing != 29) { if (getListing != 28) { monthDaysCB.addItem("28"); } monthDaysCB.addItem("29"); } monthDaysCB.addItem("30"); } } } if (command.equals("February")) { try { leapYear = Integer.parseInt(year.getText()); if ((leapYear % 4 == 0) && ((leapYear % 100 != 0) || ((leapYear % 100 == 0) && (leapYear % 400 != 0)))) { if (getListing != 29) { if (getListing > 29) { while (Integer.parseInt((String) (monthDaysCB.getItemAt(monthDaysCB.getItemCount() - 1))) > 29) { monthDaysCB.removeItemAt(monthDaysCB.getItemCount() - 1); } } else { monthDaysCB.addItem("29"); } } } else { if (getListing != 28) { while (Integer.parseInt((String) (monthDaysCB.getItemAt(monthDaysCB.getItemCount() - 1))) > 28) { monthDaysCB.removeItemAt(monthDaysCB.getItemCount() - 1); } } } } catch (NumberFormatException nfexxx) { if (getListing != 28) { while (Integer.parseInt((String) (monthDaysCB.getItemAt(monthDaysCB.getItemCount() - 1))) > 28) { monthDaysCB.removeItemAt(monthDaysCB.getItemCount() - 1); } } } } } catch (ClassCastException cce) { if (command.equals("Copy")) { entryMain.copy(); } if (command.equals("Cut")) { entryMain.cut(); } if (command.equals("Paste")) { carStart = entryMain.getCaretPosition(); entryMain.paste(); carFin = entryMain.getCaretPosition(); entryMain.grabFocus(); entryMain.select(carStart, carFin); } if (command.equals("Select All")) { entryMain.selectAll(); } if (command.equals("Dull Entry")) { toInsert = "<-- begin of my dull entry -->\nDull entry text goes here.\n<-- end of my dull entry -->\n\n"; carStart = entryMain.getCaretPosition(); // entryMain.insert(toInsert, carStart); entryMain.replaceSelection(toInsert); carFin = entryMain.getCaretPosition(); entryMain.grabFocus(); entryMain.select(carStart, carFin); } if (command.equals("Entry Reference")) { toInsert = "entry number "; carStart = entryMain.getCaretPosition(); entryMain.insert(toInsert, carStart); carFin = entryMain.getCaretPosition(); entryMain.grabFocus(); entryMain.select(carStart, carFin); } if (command.equals("Image HTML")) { toInsert = "\"\"\n\n"; carStart = entryMain.getCaretPosition(); entryMain.insert(toInsert, carStart); carFin = entryMain.getCaretPosition(); entryMain.grabFocus(); entryMain.select(carStart, carFin); } } } /*public void keyPressed (KeyEvent ev) { boolean ctrlDown = false; if ((ev.getModifiers() & InputEvent.CTRL_MASK) > 0) { ctrlDown = true; } if (ctrlDown == true) { if (ev.getKeyCode() == KeyEvent.VK_C) { entryMain.copy(); } if (ev.getKeyCode() == KeyEvent.VK_X) { entryMain.cut(); } if (ev.getKeyCode() == KeyEvent.VK_V) { entryMain.paste(); } if (ev.getKeyCode() == KeyEvent.VK_A) { entryMain.selectAll(); } } }*/ // swing listener and window public static void main (String[] args) { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); } catch (Exception e) { } EntryGUIAdd displayEntry = new EntryGUIAdd(); JCloseListener clickMe = new JCloseListener(); displayEntry.addWindowListener(clickMe); displayEntry.setSize(480, 680); displayEntry.setVisible(true); } } /*class editLAF extends MotifLookAndFeel { public void initComponentDefaults(UIDefaults table) { Object[] defaults = {"RadioButton.select", new ColorUIResource(blueish)}; } }*/ // window listener class JCloseListener extends WindowAdapter { public void windowClosing (WindowEvent ev) { System.exit(0); } } class JGMCellRenderer extends JLabel implements ListCellRenderer { Color blueish = new Color(100, 150, 230); Color blueishBG = new Color(217, 234, 255); Font smallFont2 = new Font("Tahoma", Font.PLAIN, 9); JSeparator separator = new JSeparator(); public JGMCellRenderer() { setOpaque(true); setBorder(BorderFactory.createLineBorder(Color.white)); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value.toString() == "SEPARATOR") { return separator; } setText(value.toString()); setBackground(isSelected ? blueishBG : Color.white); setForeground(blueish); setFont(smallFont2); return this; } }