diff --git a/SNHUTravel/TextAndIcon.class b/SNHUTravel/TextAndIcon.class new file mode 100644 index 0000000..8520471 Binary files /dev/null and b/SNHUTravel/TextAndIcon.class differ diff --git a/SNHUTravel/TextAndIconListCellRenderer.class b/SNHUTravel/TextAndIconListCellRenderer.class new file mode 100644 index 0000000..e8d1834 Binary files /dev/null and b/SNHUTravel/TextAndIconListCellRenderer.class differ diff --git a/SNHUTravel/TopDestinationList.jar b/SNHUTravel/TopDestinationList.jar new file mode 100644 index 0000000..50f3b1f Binary files /dev/null and b/SNHUTravel/TopDestinationList.jar differ diff --git a/SNHUTravel/TopDestinationListFrame.class b/SNHUTravel/TopDestinationListFrame.class new file mode 100644 index 0000000..0dd7c5b Binary files /dev/null and b/SNHUTravel/TopDestinationListFrame.class differ diff --git a/SNHUTravel/TopFiveDestinationList$1.class b/SNHUTravel/TopFiveDestinationList$1.class new file mode 100644 index 0000000..c95874b Binary files /dev/null and b/SNHUTravel/TopFiveDestinationList$1.class differ diff --git a/SNHUTravel/TopFiveDestinationList.class b/SNHUTravel/TopFiveDestinationList.class new file mode 100644 index 0000000..9b38f85 Binary files /dev/null and b/SNHUTravel/TopFiveDestinationList.class differ diff --git a/SNHUTravel/bin/TextAndIcon.class b/SNHUTravel/bin/TextAndIcon.class new file mode 100644 index 0000000..e5bb758 Binary files /dev/null and b/SNHUTravel/bin/TextAndIcon.class differ diff --git a/SNHUTravel/bin/TextAndIconListCellRenderer.class b/SNHUTravel/bin/TextAndIconListCellRenderer.class new file mode 100644 index 0000000..08f600c Binary files /dev/null and b/SNHUTravel/bin/TextAndIconListCellRenderer.class differ diff --git a/SNHUTravel/bin/TopDestinationListFrame.class b/SNHUTravel/bin/TopDestinationListFrame.class new file mode 100644 index 0000000..6f5b631 Binary files /dev/null and b/SNHUTravel/bin/TopDestinationListFrame.class differ diff --git a/SNHUTravel/bin/TopFiveDestinationList$1.class b/SNHUTravel/bin/TopFiveDestinationList$1.class new file mode 100644 index 0000000..3598f33 Binary files /dev/null and b/SNHUTravel/bin/TopFiveDestinationList$1.class differ diff --git a/SNHUTravel/bin/TopFiveDestinationList.class b/SNHUTravel/bin/TopFiveDestinationList.class new file mode 100644 index 0000000..9b38f85 Binary files /dev/null and b/SNHUTravel/bin/TopFiveDestinationList.class differ diff --git a/SNHUTravel/bin/resources/glacier.jpg b/SNHUTravel/bin/resources/glacier.jpg new file mode 100644 index 0000000..374b51e Binary files /dev/null and b/SNHUTravel/bin/resources/glacier.jpg differ diff --git a/SNHUTravel/bin/resources/grandcanyon.jpg b/SNHUTravel/bin/resources/grandcanyon.jpg new file mode 100644 index 0000000..55fc661 Binary files /dev/null and b/SNHUTravel/bin/resources/grandcanyon.jpg differ diff --git a/SNHUTravel/bin/resources/honolulu.jpg b/SNHUTravel/bin/resources/honolulu.jpg new file mode 100644 index 0000000..be40ad4 Binary files /dev/null and b/SNHUTravel/bin/resources/honolulu.jpg differ diff --git a/SNHUTravel/bin/resources/maui.jpg b/SNHUTravel/bin/resources/maui.jpg new file mode 100644 index 0000000..862b63e Binary files /dev/null and b/SNHUTravel/bin/resources/maui.jpg differ diff --git a/SNHUTravel/bin/resources/yellowstone.jpg b/SNHUTravel/bin/resources/yellowstone.jpg new file mode 100644 index 0000000..bbe0ce3 Binary files /dev/null and b/SNHUTravel/bin/resources/yellowstone.jpg differ diff --git a/SNHUTravel/src/TopFiveDestinationList.java b/SNHUTravel/src/TopFiveDestinationList.java new file mode 100644 index 0000000..d8492cc --- /dev/null +++ b/SNHUTravel/src/TopFiveDestinationList.java @@ -0,0 +1,170 @@ +import java.awt.*; +import javax.swing.*; +import javax.swing.border.*; + +public class TopFiveDestinationList { + public static void main(String[] args) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + TopDestinationListFrame topDestinationListFrame = new TopDestinationListFrame(); + topDestinationListFrame.setTitle("Top 5 Destination List"); + topDestinationListFrame.setVisible(true); + } + }); + } +} + + +class TopDestinationListFrame extends JFrame { + private DefaultListModel listModel; + + public TopDestinationListFrame() { + super("Top Five Destination List"); + + + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + setSize(900, 750); + + listModel = new DefaultListModel(); + + // show the top 5 destinations with a short description and a picture + // image dimensions 193 x 145 + // last modified 2023/05/21 + + // File:Mountain Goat at Hidden Lake.jpg. (2022, March 17). Wikimedia Commons. Retrieved 17:57, May 21, 2023 from https://commons.wikimedia.org/w/index.php?title=File:Mountain_Goat_at_Hidden_Lake.jpg&oldid=640186430. + // Resized and renamed to glacier.jpg + addDestinationNameAndPicture("1. Glacier National Park - All of Nature under the Big Sky", new ImageIcon(getClass().getResource("/resources/glacier.jpg"))); + + // File:Keanae Road to Hana. Maui. (11106935413).jpg. (2023, May 8). Wikimedia Commons. Retrieved 17:58, May 21, 2023 from https://commons.wikimedia.org/w/index.php?title=File:Keanae_Road_to_Hana._Maui._(11106935413).jpg&oldid=760888382. + // Resized and renamed to maui.jpg + addDestinationNameAndPicture("2. Maui - Paradise in the Pacific", new ImageIcon(getClass().getResource("/resources/maui.jpg"))); + + // File:Grand Canyon Hopi Point with rainbow 2013.jpg. (2023, April 11). Wikimedia Commons. Retrieved 17:59, May 21, 2023 from https://commons.wikimedia.org/w/index.php?title=File:Grand_Canyon_Hopi_Point_with_rainbow_2013.jpg&oldid=749321666. + // Resized and renamed to grandcanyon.jpg + addDestinationNameAndPicture("3. Grand Canyon National Park - Natural Wonder of the World", new ImageIcon(getClass().getResource("/resources/grandcanyon.jpg"))); + + // File:Sand Island Beach, Oahu, Hawaii.jpg. (2022, March 27). Wikimedia Commons. Retrieved 17:59, May 21, 2023 from https://commons.wikimedia.org/w/index.php?title=File:Sand_Island_Beach,_Oahu,_Hawaii.jpg&oldid=644361941. + // Resized and renamed to honolulu.jpg + addDestinationNameAndPicture("4. Oahu - Tropical Bliss and Cultural Delights", new ImageIcon(getClass().getResource("/resources/honolulu.jpg"))); + + // File:Yellowstone national park waterfall.jpg. (2022, May 26). Wikimedia Commons. Retrieved 18:00, May 21, 2023 from https://commons.wikimedia.org/w/index.php?title=File:Yellowstone_national_park_waterfall.jpg&oldid=659127234. + // Resized and renamed to yellowstone.jpg + addDestinationNameAndPicture("5. Yellowstone National Park - Geothermal Marvel and Wildlife Haven", new ImageIcon(getClass().getResource("/resources/yellowstone.jpg"))); + + JList list = new JList(listModel); + JScrollPane scrollPane = new JScrollPane(list); + + // reduce padding from 2 to 1 for better looking pictures + TextAndIconListCellRenderer renderer = new TextAndIconListCellRenderer(1); + + list.setCellRenderer(renderer); + + // add developer attribution; added 2023/05/21 + JLabel nameLabel = new JLabel("Developer: Cody Cook"); + getContentPane().add(nameLabel, BorderLayout.NORTH); + + // show scrollPane + getContentPane().add(scrollPane, BorderLayout.CENTER); + + // change scrollPane colors; added 2023/05/21 + scrollPane.getVerticalScrollBar().setBackground(Color.BLUE); + } + + private void addDestinationNameAndPicture(String text, Icon icon) { + TextAndIcon tai = new TextAndIcon(text, icon); + listModel.addElement(tai); + } +} + + +class TextAndIcon { + private String text; + private Icon icon; + + public TextAndIcon(String text, Icon icon) { + this.text = text; + this.icon = icon; + } + + public String getText() { + return text; + } + + public Icon getIcon() { + return icon; + } + + public void setText(String text) { + this.text = text; + } + + public void setIcon(Icon icon) { + this.icon = icon; + } +} + + +class TextAndIconListCellRenderer extends JLabel implements ListCellRenderer { + private static final Border NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); + + private Border insideBorder; + + public TextAndIconListCellRenderer() { + this(0, 0, 0, 0); + } + + public TextAndIconListCellRenderer(int padding) { + this(padding, padding, padding, padding); + } + + public TextAndIconListCellRenderer(int topPadding, int rightPadding, int bottomPadding, int leftPadding) { + insideBorder = BorderFactory.createEmptyBorder(topPadding, leftPadding, bottomPadding, rightPadding); + setOpaque(true); + } + + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean hasFocus) { + // The object from the combo box model MUST be a TextAndIcon. + TextAndIcon tai = (TextAndIcon) value; + + // Sets text and icon on 'this' JLabel. + setText(tai.getText()); + setIcon(tai.getIcon()); + + // Adjust color scheme. Set unselected option to gray to make image pop more. On selection, darken text. + if (isSelected) { + setBackground(list.getSelectionBackground()); + setForeground(Color.BLACK); + } else { + setBackground(list.getBackground()); + setForeground(Color.GRAY); + } + + Border outsideBorder; + + if (hasFocus) { + outsideBorder = UIManager.getBorder("List.focusCellHighlightBorder"); + } else { + outsideBorder = NO_FOCUS_BORDER; + } + + setBorder(BorderFactory.createCompoundBorder(outsideBorder, insideBorder)); + setComponentOrientation(list.getComponentOrientation()); + setEnabled(list.isEnabled()); + setFont(list.getFont()); + + return this; + } + + // The following methods are overridden to be empty for performance + // reasons. If you want to understand better why, please read: + // + // http://java.sun.com/javase/6/docs/api/javax/swing/DefaultListCellRenderer.html#override + + public void validate() {} + public void invalidate() {} + public void repaint() {} + public void revalidate() {} + public void repaint(long tm, int x, int y, int width, int height) {} + public void repaint(Rectangle r) {} +} \ No newline at end of file diff --git a/SNHUTravel/src/resources/glacier.jpg b/SNHUTravel/src/resources/glacier.jpg new file mode 100644 index 0000000..374b51e Binary files /dev/null and b/SNHUTravel/src/resources/glacier.jpg differ diff --git a/SNHUTravel/src/resources/grandcanyon.jpg b/SNHUTravel/src/resources/grandcanyon.jpg new file mode 100644 index 0000000..55fc661 Binary files /dev/null and b/SNHUTravel/src/resources/grandcanyon.jpg differ diff --git a/SNHUTravel/src/resources/honolulu.jpg b/SNHUTravel/src/resources/honolulu.jpg new file mode 100644 index 0000000..be40ad4 Binary files /dev/null and b/SNHUTravel/src/resources/honolulu.jpg differ diff --git a/SNHUTravel/src/resources/maui.jpg b/SNHUTravel/src/resources/maui.jpg new file mode 100644 index 0000000..862b63e Binary files /dev/null and b/SNHUTravel/src/resources/maui.jpg differ diff --git a/SNHUTravel/src/resources/yellowstone.jpg b/SNHUTravel/src/resources/yellowstone.jpg new file mode 100644 index 0000000..bbe0ce3 Binary files /dev/null and b/SNHUTravel/src/resources/yellowstone.jpg differ diff --git a/Slide Show/SlideShow.jar b/Slide Show/SlideShow.jar new file mode 100644 index 0000000..3fe3ac3 Binary files /dev/null and b/Slide Show/SlideShow.jar differ diff --git a/Slide Show/SlideShow.zip b/Slide Show/SlideShow.zip new file mode 100644 index 0000000..f16110a Binary files /dev/null and b/Slide Show/SlideShow.zip differ diff --git a/Slide Show/SlideShow/META-INF/MANIFEST.MF b/Slide Show/SlideShow/META-INF/MANIFEST.MF new file mode 100644 index 0000000..44b7142 --- /dev/null +++ b/Slide Show/SlideShow/META-INF/MANIFEST.MF @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Main-Class: SlideShow +Class-Path: . + diff --git a/Slide Show/SlideShow/SlideShow$1.class b/Slide Show/SlideShow/SlideShow$1.class new file mode 100644 index 0000000..5a1fce4 Binary files /dev/null and b/Slide Show/SlideShow/SlideShow$1.class differ diff --git a/Slide Show/SlideShow/SlideShow$2.class b/Slide Show/SlideShow/SlideShow$2.class new file mode 100644 index 0000000..068d49d Binary files /dev/null and b/Slide Show/SlideShow/SlideShow$2.class differ diff --git a/Slide Show/SlideShow/SlideShow$3.class b/Slide Show/SlideShow/SlideShow$3.class new file mode 100644 index 0000000..f262e2a Binary files /dev/null and b/Slide Show/SlideShow/SlideShow$3.class differ diff --git a/Slide Show/SlideShow/SlideShow.class b/Slide Show/SlideShow/SlideShow.class new file mode 100644 index 0000000..6322e7f Binary files /dev/null and b/Slide Show/SlideShow/SlideShow.class differ diff --git a/Slide Show/SlideShow/resources/Trip1.jpg b/Slide Show/SlideShow/resources/Trip1.jpg new file mode 100644 index 0000000..0074e1d Binary files /dev/null and b/Slide Show/SlideShow/resources/Trip1.jpg differ diff --git a/Slide Show/SlideShow/resources/Trip2.jpg b/Slide Show/SlideShow/resources/Trip2.jpg new file mode 100644 index 0000000..9f7e714 Binary files /dev/null and b/Slide Show/SlideShow/resources/Trip2.jpg differ diff --git a/Slide Show/SlideShow/resources/Trip3.jpg b/Slide Show/SlideShow/resources/Trip3.jpg new file mode 100644 index 0000000..07dd3d4 Binary files /dev/null and b/Slide Show/SlideShow/resources/Trip3.jpg differ diff --git a/Slide Show/SlideShow/resources/Trip4.jpg b/Slide Show/SlideShow/resources/Trip4.jpg new file mode 100644 index 0000000..b81b9d3 Binary files /dev/null and b/Slide Show/SlideShow/resources/Trip4.jpg differ diff --git a/Slide Show/SlideShow/resources/Trip5.jpg b/Slide Show/SlideShow/resources/Trip5.jpg new file mode 100644 index 0000000..3ef67ca Binary files /dev/null and b/Slide Show/SlideShow/resources/Trip5.jpg differ diff --git a/Slide Show/bin/SlideShow$1.class b/Slide Show/bin/SlideShow$1.class new file mode 100644 index 0000000..5a1fce4 Binary files /dev/null and b/Slide Show/bin/SlideShow$1.class differ diff --git a/Slide Show/bin/SlideShow$2.class b/Slide Show/bin/SlideShow$2.class new file mode 100644 index 0000000..068d49d Binary files /dev/null and b/Slide Show/bin/SlideShow$2.class differ diff --git a/Slide Show/bin/SlideShow$3.class b/Slide Show/bin/SlideShow$3.class new file mode 100644 index 0000000..f262e2a Binary files /dev/null and b/Slide Show/bin/SlideShow$3.class differ diff --git a/Slide Show/bin/SlideShow.class b/Slide Show/bin/SlideShow.class new file mode 100644 index 0000000..6322e7f Binary files /dev/null and b/Slide Show/bin/SlideShow.class differ diff --git a/Slide Show/bin/resources/Trip1.jpg b/Slide Show/bin/resources/Trip1.jpg new file mode 100644 index 0000000..0074e1d Binary files /dev/null and b/Slide Show/bin/resources/Trip1.jpg differ diff --git a/Slide Show/bin/resources/Trip2.jpg b/Slide Show/bin/resources/Trip2.jpg new file mode 100644 index 0000000..9f7e714 Binary files /dev/null and b/Slide Show/bin/resources/Trip2.jpg differ diff --git a/Slide Show/bin/resources/Trip3.jpg b/Slide Show/bin/resources/Trip3.jpg new file mode 100644 index 0000000..07dd3d4 Binary files /dev/null and b/Slide Show/bin/resources/Trip3.jpg differ diff --git a/Slide Show/bin/resources/Trip4.jpg b/Slide Show/bin/resources/Trip4.jpg new file mode 100644 index 0000000..b81b9d3 Binary files /dev/null and b/Slide Show/bin/resources/Trip4.jpg differ diff --git a/Slide Show/bin/resources/Trip5.jpg b/Slide Show/bin/resources/Trip5.jpg new file mode 100644 index 0000000..3ef67ca Binary files /dev/null and b/Slide Show/bin/resources/Trip5.jpg differ diff --git a/Slide Show/src/SlideShow.java b/Slide Show/src/SlideShow.java new file mode 100644 index 0000000..dbc387b --- /dev/null +++ b/Slide Show/src/SlideShow.java @@ -0,0 +1,185 @@ +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.HeadlessException; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import java.awt.Color; + +public class SlideShow extends JFrame { + + /** Edits by Cody Cook on June 3, 2023 + * CS-250 + */ + + private static final long serialVersionUID = 1L; + //Declare Variables + private JPanel slidePane; + private JPanel textPane; + private JPanel buttonPane; + private CardLayout card; + private CardLayout cardText; + private JButton btnPrev; + private JButton btnNext; + private JLabel lblSlide; + private JLabel lblTextArea; + + /** + * Create the application. + */ + public SlideShow() throws HeadlessException { + initComponent(); + } + + /** + * Initialize the contents of the frame. + */ + private void initComponent() { + //Initialize variables to empty objects + card = new CardLayout(); + cardText = new CardLayout(); + slidePane = new JPanel(); + textPane = new JPanel(); + textPane.setBackground(Color.BLUE); + textPane.setBounds(5, 470, 790, 50); + textPane.setVisible(true); + buttonPane = new JPanel(); + btnPrev = new JButton(); + btnNext = new JButton(); + lblSlide = new JLabel(); + lblTextArea = new JLabel(); + + //Setup frame attributes + setSize(800, 600); + setLocationRelativeTo(null); + setTitle("Top 5 Detox/Wellness SlideShow"); // 2023/06/03: Update Title to reflex Detox/Wellness + getContentPane().setLayout(new BorderLayout(10, 50)); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + //Setting the layouts for the panels + slidePane.setLayout(card); + textPane.setLayout(cardText); + + //logic to add each of the slides and text + for (int i = 1; i <= 5; i++) { + lblSlide = new JLabel(); + lblTextArea = new JLabel(); + lblSlide.setText(getResizeIcon(i)); + lblTextArea.setText(getTextDescription(i)); + slidePane.add(lblSlide, "card" + i); + textPane.add(lblTextArea, "cardText" + i); + } + + getContentPane().add(slidePane, BorderLayout.CENTER); + getContentPane().add(textPane, BorderLayout.SOUTH); + + buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 10)); + + btnPrev.setText("Previous"); + btnPrev.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + goPrevious(); + } + }); + buttonPane.add(btnPrev); + + btnNext.setText("Next"); + btnNext.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + goNext(); + } + }); + buttonPane.add(btnNext); + + getContentPane().add(buttonPane, BorderLayout.SOUTH); + } + + /** + * Previous Button Functionality + */ + private void goPrevious() { + card.previous(slidePane); + cardText.previous(textPane); + } + + /** + * Next Button Functionality + */ + private void goNext() { + card.next(slidePane); + cardText.next(textPane); + } + + /** + * Method to get the images + */ + private String getResizeIcon(int i) { + String image = ""; + // 2023/06/03: Removed TestImageX.jpg from resources. + if (i==1){ + // 2023/06/03: Update TestImage1.jpg to Trip1.jpg; picture collected from https://www.yourgolftravel.com/le-blanc-spa-resort-los-cabos on 6/3; creative commons + image = "