Initial upload

Upload my classwork to Github.
This commit is contained in:
didyouexpectthat 2023-06-17 15:15:27 -07:00 committed by GitHub
parent bdcb07b91c
commit 7d37fcb1d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 359 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

View file

@ -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) {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
Slide Show/SlideShow.jar Normal file

Binary file not shown.

BIN
Slide Show/SlideShow.zip Normal file

Binary file not shown.

View file

@ -0,0 +1,4 @@
Manifest-Version: 1.0
Main-Class: SlideShow
Class-Path: .

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 KiB

View file

@ -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 = "<html><body><img width= '800' height='500' src='" + getClass().getResource("/resources/Trip1.jpg") + "'</body></html>";
} else if (i==2){
// 2023/06/03: Update TestImage2.jpg to Trip2.jpg; picture collected from https://www.flickr.com/photos/alainamcbride/6210337494 on 6/3; creative commons license
image = "<html><body><img width= '800' height='500' src='" + getClass().getResource("/resources/Trip2.jpg") + "'</body></html>";
} else if (i==3){
// 2023/06/03: Update TestImage3.jpg to Trip3.jpg; picture collected from https://www.flickr.com/photos/percygermany/32626529922 on 6/3; creative commons license
image = "<html><body><img width= '800' height='500' src='" + getClass().getResource("/resources/Trip3.jpg") + "'</body></html>";
} else if (i==4){
// 2023/06/03: Update TestImage4.jpg to Trip4.jpg; picture collected from https://www.12fly.com.my/lifestyle/en/cleanse-detox-retreats-at-revi%CC%84vo%CC%84-wellness-resort/ on 6/3; creative commons license
image = "<html><body><img width= '800' height='500' src='" + getClass().getResource("/resources/Trip4.jpg") + "'</body></html>";
} else if (i==5){
// 2023/06/03: Update TestImage5.jpg to Trip5.jpg; picture collected from https://www.yourgolftravel.com/barcelo-bavaro-beach-resort on 6/3; creative commons license
image = "<html><body><img width= '800' height='500' src='" + getClass().getResource("/resources/Trip5.jpg") + "'</body></html>";
}
return image;
}
/**
* Method to get the text values
*/
private String getTextDescription(int i) {
String text = "";
if (i==1){
// 2023/06/03: Adjusted #1 to focus on detox/wellness travel
text = "<html><body><font size='5'>#1 Los Cabos Spa Getaway</font><br>Rejuvenate your mind and body at a luxurious wellness spa located in the heart of Los Cabos.</body></html>";
} else if (i==2){
// 2023/06/03: Adjusted #2 to focus on detox/wellness travel; copy tag usage from #1 for description
text = "<html><body><font size='5'>#2 Yoga in Yosemite</font><br>Embark on a serene journey practicing Yoga surrounded by the tranquil beauty of Yosemite.</body></html>";
} else if (i==3){
// 2023/06/03: Adjusted #3 to focus on detox/wellness travel; copy tag usage from #1 for description
text = "<html><body><font size='5'>#3 Berlin Body</font><br>Experience holistic healing and body detox programs in the vibrant city of Berlin.</body></html>";
} else if (i==4){
// 2023/06/03: Adjusted #4 to focus on detox/wellness travel; copy tag usage from #1 for description
text = "<html><body><font size='5'>#4 Peru Purification</font><br>Embark on a purification journey with traditional Incan healing rituals amidst the majestic Andes.</body></html>";
} else if (i==5){
// 2023/06/03: Adjusted #5 to focus on detox/wellness travel; copy tag usage from #1 for description
text = "<html><body><font size='5'>#5 Detox in the Dominican Republic</font><br>Immerse yourself in peaceful coastal retreats offering detox programs in the charming Dominican Republic.</body></html>";
}
return text;
}
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
SlideShow ss = new SlideShow();
ss.setVisible(true);
}
});
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 KiB