From: <doc...@us...> - 2007-08-21 20:22:38
|
Revision: 158 http://openpcl.svn.sourceforge.net/openpcl/?rev=158&view=rev Author: documentsystems Date: 2007-08-21 13:22:41 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Howard Hoagland. Changed 5 classes that are for showing the drop down JLists when the user clicks toolbar buttons for Print, Change the Look, Window layout and selection, Help About and License. The code changes set the PosToolbarDropdownItemRenderer on the JLists that to changes the background color on JLabels in JLists by which one the mouse is hovering over, which was set in PosHoverColorMouseMotionAdapter that was added to the JLists, so the user has visual confirmation of which item in the drop down will be seleced if clicked there. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/panels/PosChangeTheLookList.java openpcl/src/com/openpcl/viewer/panels/PosHelpChoicesList.java openpcl/src/com/openpcl/viewer/panels/PosPrintChoicesList.java openpcl/src/com/openpcl/viewer/panels/PosWindowControlList.java openpcl/src/com/openpcl/viewer/util/PosPickAppLook.java Modified: openpcl/src/com/openpcl/viewer/panels/PosChangeTheLookList.java =================================================================== --- openpcl/src/com/openpcl/viewer/panels/PosChangeTheLookList.java 2007-08-21 20:14:39 UTC (rev 157) +++ openpcl/src/com/openpcl/viewer/panels/PosChangeTheLookList.java 2007-08-21 20:22:41 UTC (rev 158) @@ -5,13 +5,17 @@ import java.awt.Dimension; import javax.swing.BorderFactory; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; +import javax.swing.SwingConstants; import javax.swing.event.ListSelectionListener; +import com.openpcl.viewer.util.PosHoverColorMouseMotionAdapter; import com.openpcl.viewer.util.PosPickAppLook; +import com.openpcl.viewer.util.PosToolbarDropdownItemRenderer; public class PosChangeTheLookList extends JPanel { private static final long serialVersionUID = 1L; @@ -28,9 +32,11 @@ private void buildUI() { mLookJList = new JList(mPickAppLook.getLookChoicesArray()); + mLookJList.setCellRenderer(new PosToolbarDropdownItemRenderer()); mLookJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); if (mListSelectionListener != null) {mLookJList.addListSelectionListener(mListSelectionListener);} - + mLookJList.addMouseMotionListener(new PosHoverColorMouseMotionAdapter(mLookJList)); + mJScrollPane = new JScrollPane(mLookJList); mJScrollPane.setBorder(BorderFactory.createLineBorder(Color.BLUE)); mJScrollPane.setPreferredSize(new Dimension(240, 116)); // was (250,200) using JGoodies Looks @@ -41,5 +47,14 @@ } public int getSelectedIndex() {return mLookJList.getSelectedIndex();} - public void unSelectRows() { mLookJList.clearSelection(); } + + public void unSelectRows() { + mLookJList.clearSelection(); + int tSize = mLookJList.getModel().getSize(); + for (int i = 0; i < tSize; i++) { + // Set vertical alignment of the JLabel in the JList to Center because Top is a doing double duty trick for changing + // the hover over background color in the PosToolbarDropdownItemRenderer + ((JLabel)mLookJList.getModel().getElementAt((i))).setVerticalAlignment(SwingConstants.CENTER); + } + } } Modified: openpcl/src/com/openpcl/viewer/panels/PosHelpChoicesList.java =================================================================== --- openpcl/src/com/openpcl/viewer/panels/PosHelpChoicesList.java 2007-08-21 20:14:39 UTC (rev 157) +++ openpcl/src/com/openpcl/viewer/panels/PosHelpChoicesList.java 2007-08-21 20:22:41 UTC (rev 158) @@ -14,29 +14,29 @@ import javax.swing.SwingConstants; import javax.swing.event.ListSelectionListener; +import com.openpcl.viewer.util.PosHoverColorMouseMotionAdapter; +import com.openpcl.viewer.util.PosToolbarDropdownItemRenderer; + public class PosHelpChoicesList extends JPanel { private static final long serialVersionUID = 1L; protected JList mHelpChoicesJList = null; protected JScrollPane mJScrollPane = null; protected ListSelectionListener mListSelectionListener = null; - protected Vector<String> mChoicesStrings = new Vector<String>(2); protected Vector<JLabel> mChoicesVector = new Vector<JLabel>(2); public PosHelpChoicesList(ListSelectionListener pListSelectionListener, String pAppName) { mListSelectionListener = pListSelectionListener; - mChoicesStrings.add("Show License Info"); - mChoicesStrings.add("About " + pAppName); + mChoicesVector.add(new JLabel("Show License Info", SwingConstants.LEFT)); + mChoicesVector.add(new JLabel("About " + pAppName, SwingConstants.LEFT)); buildUI(); } private void buildUI() { - for (String tEachString : mChoicesStrings) { - mChoicesVector.add(new JLabel(tEachString, SwingConstants.LEFT)); - } - - mHelpChoicesJList = new JList(mChoicesStrings); + mHelpChoicesJList = new JList(mChoicesVector); + mHelpChoicesJList.setCellRenderer(new PosToolbarDropdownItemRenderer()); mHelpChoicesJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); if (mListSelectionListener != null) {mHelpChoicesJList.addListSelectionListener(mListSelectionListener);} + mHelpChoicesJList.addMouseMotionListener(new PosHoverColorMouseMotionAdapter(mHelpChoicesJList)); mJScrollPane = new JScrollPane(); mJScrollPane.setBorder(BorderFactory.createLineBorder(Color.BLUE)); @@ -57,13 +57,21 @@ int tHeightOfItem = ((JLabel)(mChoicesVector.elementAt(0))).getPreferredSize().height + 2; setPreferredSize(new Dimension((tBorderAdjustment + tWidestPixelWidth), - tBorderAdjustment + (mChoicesStrings.size() * tHeightOfItem))); + tBorderAdjustment + (mChoicesVector.size() * tHeightOfItem))); setLayout(new BorderLayout()); add(mJScrollPane, BorderLayout.CENTER); } public int getSelectedIndex() { return mHelpChoicesJList.getSelectedIndex(); } - public void unSelectRows() { mHelpChoicesJList.clearSelection(); } + public void unSelectRows() { + mHelpChoicesJList.clearSelection(); + int tSize = mHelpChoicesJList.getModel().getSize(); + for (int i = 0; i < tSize; i++) { + // Set vertical alignment of the JLabel in the JList to Center because Top is a doing double duty trick for changing + // the hover over background color in the PosToolbarDropdownItemRenderer + ((JLabel)mHelpChoicesJList.getModel().getElementAt((i))).setVerticalAlignment(SwingConstants.CENTER); + } + } } Modified: openpcl/src/com/openpcl/viewer/panels/PosPrintChoicesList.java =================================================================== --- openpcl/src/com/openpcl/viewer/panels/PosPrintChoicesList.java 2007-08-21 20:14:39 UTC (rev 157) +++ openpcl/src/com/openpcl/viewer/panels/PosPrintChoicesList.java 2007-08-21 20:22:41 UTC (rev 158) @@ -3,30 +3,42 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; +import java.util.Vector; import javax.swing.BorderFactory; +import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; +import javax.swing.SwingConstants; import javax.swing.event.ListSelectionListener; +import com.openpcl.viewer.util.PosHoverColorMouseMotionAdapter; +import com.openpcl.viewer.util.PosToolbarDropdownItemRenderer; + public class PosPrintChoicesList extends JPanel { private static final long serialVersionUID = 1L; protected JList mPrintChoicesJList = null; protected JScrollPane mJScrollPane = null; protected ListSelectionListener mListSelectionListener = null; - protected String[] mPrintChoices = {"Print All", "Print Selected", "Print Remaining", "Print Changed"}; + protected Vector<JLabel> mPrintChoicesVector = new Vector<JLabel> (4); public PosPrintChoicesList(ListSelectionListener pListSelectionListener) { mListSelectionListener = pListSelectionListener; + mPrintChoicesVector.add(new JLabel("Print All", SwingConstants.LEFT)); + mPrintChoicesVector.add(new JLabel("Print Selected", SwingConstants.LEFT)); + mPrintChoicesVector.add(new JLabel("Print Remaining", SwingConstants.LEFT)); + mPrintChoicesVector.add(new JLabel("Print Changed", SwingConstants.LEFT)); buildUI(); } private void buildUI() { - mPrintChoicesJList = new JList(mPrintChoices); + mPrintChoicesJList = new JList(mPrintChoicesVector); + mPrintChoicesJList.setCellRenderer(new PosToolbarDropdownItemRenderer()); mPrintChoicesJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - if (mListSelectionListener != null) {mPrintChoicesJList.addListSelectionListener(mListSelectionListener);} + if (mListSelectionListener != null) { mPrintChoicesJList.addListSelectionListener(mListSelectionListener); } + mPrintChoicesJList.addMouseMotionListener(new PosHoverColorMouseMotionAdapter(mPrintChoicesJList)); mJScrollPane = new JScrollPane(mPrintChoicesJList); mJScrollPane.setBorder(BorderFactory.createLineBorder(Color.BLUE)); @@ -38,5 +50,13 @@ } public int getSelectedIndex() { return mPrintChoicesJList.getSelectedIndex(); } - public void unSelectRows() { mPrintChoicesJList.clearSelection(); } + public void unSelectRows() { + mPrintChoicesJList.clearSelection(); + int tSize = mPrintChoicesJList.getModel().getSize(); + for (int i = 0; i < tSize; i++) { + // Set vertical alignment of the JLabel in the JList to Center because Top is a doing double duty trick for changing + // the hover over background color in the PosToolbarDropdownItemRenderer + ((JLabel)mPrintChoicesJList.getModel().getElementAt((i))).setVerticalAlignment(SwingConstants.CENTER); + } + } } Modified: openpcl/src/com/openpcl/viewer/panels/PosWindowControlList.java =================================================================== --- openpcl/src/com/openpcl/viewer/panels/PosWindowControlList.java 2007-08-21 20:14:39 UTC (rev 157) +++ openpcl/src/com/openpcl/viewer/panels/PosWindowControlList.java 2007-08-21 20:22:41 UTC (rev 158) @@ -15,6 +15,7 @@ import javax.swing.SwingConstants; import javax.swing.event.ListSelectionListener; +import com.openpcl.viewer.util.PosHoverColorMouseMotionAdapter; import com.openpcl.viewer.util.PosReadImageIcon; import com.openpcl.viewer.util.PosToolbarDropdownItemRenderer; @@ -50,6 +51,7 @@ mBaseVector.add(new JLabel("Tile Horizontal", mTileHorizontalIcon, SwingConstants.LEFT)); mBaseVector.add(new JLabel("Tile Vertical", mTileVerticalIcon, SwingConstants.LEFT)); mBaseVector.add(new JLabel("Cascade", mCascadeIcon, SwingConstants.LEFT)); + mBaseVector.add(new JLabel("<html>___________</html>", null, SwingConstants.LEFT)); mJScrollPane = new JScrollPane(); mJScrollPane.setBorder(BorderFactory.createLineBorder(Color.BLUE)); setLayout(new BorderLayout()); @@ -58,13 +60,21 @@ } public Object getSelectedValue() { return mWindowControlJList.getSelectedValue(); } - public void unSelectRows() { mWindowControlJList.clearSelection(); } + public void unSelectRows() { + mWindowControlJList.clearSelection(); + for (int i = 0; i < 4; i++) { + // Set vertical alignment of the JLabel in the JList to Center because Top is a doing double duty trick for changing + // the hover over background color in the PosToolbarDropdownItemRenderer + ((JLabel)mWindowControlJList.getModel().getElementAt((i))).setVerticalAlignment(SwingConstants.CENTER); + } + } + public void putViewsInWindowDropdown(Vector<JLabel> pVector, int pCurrentViewNumber) { if (pVector == null || pVector.size() < 1) { - mChoicesVector = new Vector<JLabel>(3); + mChoicesVector = new Vector<JLabel>(4); } else { - mChoicesVector = new Vector<JLabel>(pVector.size() + 3); + mChoicesVector = new Vector<JLabel>(pVector.size() + 4); } // Add the Tile Horizontal, Tile Vertical, Cascade @@ -76,7 +86,7 @@ if (pCurrentViewNumber == getViewNumberFromString(eachJLabel.getText())) { eachJLabel.setIcon(mWindowSelectedIcon); // This view is the currently selected one, so make it's icon be a check mark } else { - eachJLabel.setIcon(mWindowUnselectedIcon); // Not the currently selected view, so make its icon be a little dot + eachJLabel.setIcon(mWindowUnselectedIcon); // Not the currently selected view, so make its icon be the unselected window } // Add this JLabel to see on the screen in the Window control dropdown @@ -98,6 +108,7 @@ if (mListSelectionListener != null) {mWindowControlJList.addListSelectionListener(mListSelectionListener);} mWindowControlJList.setCellRenderer(new PosToolbarDropdownItemRenderer()); mWindowControlJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + mWindowControlJList.addMouseMotionListener(new PosHoverColorMouseMotionAdapter(mWindowControlJList)); // Put the JList in the JScrollPane mJScrollPane.setViewportView(mWindowControlJList); @@ -116,7 +127,7 @@ /** Parse the String that looks like "View# 1. filename.ext" to the int which is the view number */ public int getViewNumberClicked() { int tRowClicked = mWindowControlJList.getSelectedIndex(); - if ( tRowClicked > 2) { + if ( tRowClicked > 3) { JLabel tSelectedJLabel = (JLabel)mWindowControlJList.getModel().getElementAt(tRowClicked); if (tSelectedJLabel != null) { String tSelectedRowString = tSelectedJLabel.getText(); Modified: openpcl/src/com/openpcl/viewer/util/PosPickAppLook.java =================================================================== --- openpcl/src/com/openpcl/viewer/util/PosPickAppLook.java 2007-08-21 20:14:39 UTC (rev 157) +++ openpcl/src/com/openpcl/viewer/util/PosPickAppLook.java 2007-08-21 20:22:41 UTC (rev 158) @@ -1,5 +1,6 @@ package com.openpcl.viewer.util; +import javax.swing.JLabel; import javax.swing.LookAndFeel; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -12,7 +13,7 @@ import com.openpcl.viewer.OpenPCLViewer; /** - * JComboBox choices for the user to change the LookAndFeel at run time while using the UI + * Choices for the user to change the LookAndFeel at run time while using the UI * @author howard 9/14/06 */ public class PosPickAppLook { @@ -23,13 +24,13 @@ // and added the below in place of the JGoodies Looks ExperienceBlue() private DefaultMetalTheme mMetalNonOceanTheme = new DefaultMetalTheme(); - private String[] mLookChoicesArray = { - "Look: Client JVM Startup Default", - "Look: Client Native System", - "Look: Windows XP (SunJava)", - "Look: Windows Classic (SunJava)", - "Look: Metal OceanTheme (Javax)", - "Look: Metal Non OceanTheme (Javax)" + private JLabel[] mLookChoicesArray = { + new JLabel("Look: Client JVM Startup Default"), + new JLabel("Look: Client Native System"), + new JLabel("Look: Windows XP (SunJava)"), + new JLabel("Look: Windows Classic (SunJava)"), + new JLabel("Look: Metal OceanTheme (Javax)"), + new JLabel("Look: Metal Non OceanTheme (Javax)") }; /* JGoodies Looks Commented out 11/17/06 HowardH. @@ -94,7 +95,7 @@ mLookArray[5] = null; // was 9 using JGoodies Looks } - public String[] getLookChoicesArray() { return mLookChoicesArray; } + public JLabel[] getLookChoicesArray() { return mLookChoicesArray; } public LookAndFeel[] getLookArray() { return mLookArray; } public void changeLookListSelection(int pItemIndex) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |