0% found this document useful (0 votes)
8 views

Source Code Java

Uploaded by

Elly Apriliani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Source Code Java

Uploaded by

Elly Apriliani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Nama :

NIM :

No Source Code Java UI UX Design


1 import javax.swing.*;
import java.awt.*;

public class MyHoliday extends JFrame {


public MyHoliday() {
setLayout(new BorderLayout());

// Logo
ImageIcon logo = new ImageIcon("logo.png");
JLabel logoLabel = new JLabel(logo);
logoLabel.setHorizontalAlignment(JLabel.CENTER);
add(logoLabel, BorderLayout.CENTER);

// Judul
JLabel title = new JLabel("My Holiday");
title.setFont(new Font("Arial", Font.BOLD, 24));
title.setHorizontalAlignment(JLabel.CENTER);
add(title, BorderLayout.NORTH);

// Tulisan
JLabel text = new JLabel("Liburan Santai No Worries");
text.setFont(new Font("Arial", Font.PLAIN, 18));
text.setHorizontalAlignment(JLabel.CENTER);
add(text, BorderLayout.SOUTH);

setSize(400, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}

public static void main(String[] args) {


new MyHoliday();
}
}
2. import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MyHoliday extends JFrame {


private JTextField locationField;
private JComboBox<String> languageComboBox;
private JButton nextButton;

public MyHoliday() {
setLayout(new FlowLayout());

JLabel locationLabel = new JLabel("Lokasi:");


locationField = new JTextField(10);
add(locationLabel);
add(locationField);

String[] languages = {"English", "Indonesia", "Malaysia"};


languageComboBox = new JComboBox<>(languages);
add(new JLabel("Bahasa:"));
add(languageComboBox);

nextButton = new JButton("Lanjutkan");


nextButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String location = locationField.getText();
String language = (String)
languageComboBox.getSelectedItem();
// Proses lanjutan berdasarkan lokasi dan bahasa
}
});
add(nextButton);

setSize(300, 150);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}

public static void main(String[] args) {


new MyHoliday();
}
}
3. import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;

public class MyHolidayLogin extends JFrame {


private JTextField emailField;
private JPasswordField passwordField;
private JButton loginButton;

public MyHolidayLogin() {
setLayout(new FlowLayout());

JLabel emailLabel = new JLabel("Email:");


emailField = new JTextField(10);
add(emailLabel);
add(emailField);

JLabel passwordLabel = new JLabel("Password:");


passwordField = new JPasswordField(10);
add(passwordLabel);
add(passwordField);

loginButton = new JButton("Login");


loginButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String email = emailField.getText();
String password = new
String(passwordField.getPassword());
// Proses login ke database
try {
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/myh
oliday", "username", "password");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT *
FROM users WHERE email = '" + email + "' AND password = '"
+ password + "'");
if (rs.next()) {
// Login berhasil, tampilkan halaman utama
new MyHolidayMain();
} else {
// Login gagal, tampilkan pesan error

JOptionPane.showMessageDialog(MyHolidayLogin.this,
"Invalid email or password");
}
conn.close();
} catch (SQLException ex) {
// Handle SQL exception
}
}
});
add(loginButton);

setSize(300, 150);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}

public static void main(String[] args) {


new MyHolidayLogin();
}
}
4. import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MyHoliday extends JFrame {


private JTextField nameField;
private JTextField emailField;
private JTextField passwordField;
private JTextField dobField;

public MyHoliday() {
setLayout(new FlowLayout());

JLabel nameLabel = new JLabel("Name:");


nameField = new JTextField(10);
add(nameLabel);
add(nameField);

JLabel emailLabel = new JLabel("Email:");


emailField = new JTextField(10);
add(emailLabel);
add(emailField);

JLabel passwordLabel = new JLabel("Password:");


passwordField = new JTextField(10);
add(passwordLabel);
add(passwordField);

JLabel dobLabel = new JLabel("Date of Birth:");


dobField = new JTextField(10);
add(dobLabel);
add(dobField);

JButton signUpButton = new JButton("Sign Up");


signUpButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name = nameField.getText();
String email = emailField.getText();
String password = passwordField.getText();
String dob = dobField.getText();
// Proses sign up dan simpan data ke database
}
});
add(signUpButton);

setSize(300, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}

public static void main(String[] args) {


new MyHoliday();
}
}

5. import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class MyHoliday extends JFrame {


private JTextField emailField;
private JButton sendButton;

public MyHoliday() {
setLayout(new FlowLayout());

JLabel emailLabel = new JLabel("Email:");


emailField = new JTextField(10);
add(emailLabel);
add(emailField);

sendButton = new JButton("Send");


sendButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String email = emailField.getText();
// Proses lupa password
JOptionPane.showMessageDialog(MyHoliday.this,
"Password reset email sent to " + email);
}
});
add(sendButton);

setSize(300, 100);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
new MyHoliday();
}
}
6. import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MyHoliday extends JFrame {


private JLabel welcomeLabel;
private JLabel categoryLabel;
private JLabel popularDestinationLabel;
private JLabel recommendationLabel;

public MyHoliday() {
setLayout(new FlowLayout());

welcomeLabel = new JLabel("Welcome to My Holiday!");


add(welcomeLabel);

categoryLabel = new JLabel("Categories:");


add(categoryLabel);

String[] categories = {"Beach", "City", "Nature",


"Adventure"};
JComboBox<String> categoryComboBox = new
JComboBox<>(categories);
add(categoryComboBox);

popularDestinationLabel = new JLabel("Popular


Destinations:");
add(popularDestinationLabel);

String[] popularDestinations = {"Bali", "Tokyo", "Paris",


"New York"};
JComboBox<String> popularDestinationComboBox = new
JComboBox<>(popularDestinations);
add(popularDestinationComboBox);

recommendationLabel = new JLabel("Recommendations:");


add(recommendationLabel);

JButton recommendButton = new JButton("Recommend");


recommendButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
String category = (String)
categoryComboBox.getSelectedItem();
String popularDestination = (String)
popularDestinationComboBox.getSelectedItem();
// Proses rekomendasi berdasarkan kategori dan
destinasi populer
}
});
add(recommendButton);

setSize(300, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}

public static void main(String[] args) {


new MyHoliday();
}
}
7. import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MyHoliday extends JFrame {


private JFrame frame;
private JPanel panel;
private JLabel nameLabel;
private JLabel priceLabel;
private JLabel descriptionLabel;
private JLabel ratingLabel;
private JButton viewButton;

public MyHoliday() {
frame = new JFrame("My Holiday");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

panel = new JPanel();


panel.setLayout(new GridLayout(6, 2));

nameLabel = new JLabel("Hotel Name:");


priceLabel = new JLabel("Price:");
descriptionLabel = new JLabel("Description:");
ratingLabel = new JLabel("Rating:");
viewButton = new JButton("View Detail");

panel.add(new JLabel());
panel.add(nameLabel);
panel.add(new JLabel());
panel.add(priceLabel);
panel.add(new JLabel());
panel.add(descriptionLabel);
panel.add(new JLabel());
panel.add(ratingLabel);
panel.add(new JLabel());
panel.add(viewButton);

frame.add(panel);
frame.setSize(300, 200);
frame.setVisible(true);
}

public static void main(String[] args) {


new MyHoliday();
}
}
8. import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MyHoliday extends JFrame {


private JLabel title;
private JLabel hotelName;
private JLabel hotelDescription;
private JLabel hotelRating;
private JLabel hotelPrice;
private JLabel hotelLocation;
private JLabel hotelImage;
private JLabel roomImages[];
private JButton bookButton;

public MyHoliday() {
setLayout(new FlowLayout());

title = new JLabel("About Our Hotel");


title.setFont(new Font("Arial", Font.BOLD, 24));
add(title);

hotelName = new JLabel("Hotel Name: My Holiday");


hotelName.setFont(new Font("Arial", Font.BOLD, 18));
add(hotelName);

hotelDescription = new JLabel("Description: A luxurious


hotel with comfortable rooms and excellent service.");
hotelDescription.setFont(new Font("Arial", Font.PLAIN,
14));
add(hotelDescription);

hotelRating = new JLabel("Rating: 4.5/5");


hotelRating.setFont(new Font("Arial", Font.BOLD, 14));
add(hotelRating);

hotelPrice = new JLabel("Price: $100 per night");


hotelPrice.setFont(new Font("Arial", Font.BOLD, 14));
add(hotelPrice);

hotelLocation = new JLabel("Location: 123 Main St,


Anytown, USA");
hotelLocation.setFont(new Font("Arial", Font.BOLD, 14));
add(hotelLocation);

hotelImage = new JLabel(new ImageIcon("hotel.jpg"));


hotelImage.setFont(new Font("Arial", Font.BOLD, 14));
add(hotelImage);

roomImages = new JLabel[5];


for (int i = 0; i < roomImages.length; i++) {
roomImages[i] = new JLabel(new ImageIcon("room" + (i
+ 1) + ".jpg"));
add(roomImages[i]);
}

bookButton = new JButton("Book Now");


bookButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Proses booking hotel
}
});
add
9. import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MyHoliday extends JFrame {


private JLabel profileLabel;
private JLabel nameLabel;
private JLabel emailLabel;
private JButton modeButton;
private JButton changePasswordButton;
private JButton languageButton;
private JButton informationButton;

public MyHoliday() {
setLayout(new FlowLayout());

profileLabel = new JLabel(new ImageIcon("profile.jpg"));


add(profileLabel);

nameLabel = new JLabel("Name: John Doe");


add(nameLabel);

emailLabel = new JLabel("Email:


john.doe@example.com");
add(emailLabel);

modeButton = new JButton("Mode: Malam");


modeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Proses mode malam
}
});
add(modeButton);

changePasswordButton = new JButton("Change


Password");
changePasswordButton.addActionListener(new
ActionListener() {
public void actionPerformed(ActionEvent e) {
// Proses ganti password
}
});
add(changePasswordButton);

languageButton = new JButton("Language: English");


languageButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Proses ganti bahasa
}
});
add(languageButton);

informationButton = new JButton("About App");


informationButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
// Proses informasi tentang aplikasi
}
});
add(informationButton);

JButton termsButton = new JButton("Terms &


Conditions");
termsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Proses ketentuan dan syarat
}
});
add(termsButton);

JButton privacyButton = new JButton("Privacy Policy");


privacyButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Proses kebijakan privasi
}
});
add(privacyButton);

JButton shareButton = new JButton("Share App");


shareButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Proses berbagi aplikasi
}
});
add(shareButton);

setSize(400, 300);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}

public static void main(String[] args) {


new MyHoliday();
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy