Snippets Collections
function main() {
  // Settings
  var campaignName = "Campaign Name";
  var significantOverlapChange = 0.1; // 10% change triggers an alert
  var lookbackPeriod = "LAST_30_DAYS";
  var recipientEmail = "your_email@example.com";

  // Get Auction Insights Data
  var report = AdsApp.report(
    "SELECT Domain, ImpressionShare " +
    "FROM AUCTION_INSIGHTS " +
    "WHERE CampaignName = '" + campaignName + "' " +
    "DURING " + lookbackPeriod);

  var rows = report.rows();
  var competitorData = {};

  // Store Impression Share Data
  while (rows.hasNext()) {
    var row = rows.next();
    competitorData[row['Domain']] = row['ImpressionShare'];
  }

  // Compare with Current Data (Simplified)
  var currentCampaign = AdsApp.campaigns().withCondition("Name = '" + campaignName + "'").get().next();
  var competitors = currentCampaign.targeting().auctionInsights().get().results();

  competitors.forEach(function(competitor) {
    var domain = competitor.getDomain();
    var currentImpressionShare = competitor.getStats().getImpressionShare();

    if (domain in competitorData) {
      var previousImpressionShare = competitorData[domain];
      var change = Math.abs(currentImpressionShare - previousImpressionShare);

      if (change >= significantOverlapChange) {
        // Send an alert - Customize this part
        var subject = "Competitor Alert: " + domain;
        var body = "Impression share for " + domain + " has changed significantly in campaign: " + campaignName;
        MailApp.sendEmail(recipientEmail, subject, body);
      }
    }
  });
}
function main() {
  // Settings
  var campaignName = "Campaign Name";
  var metricsToTrack = ["Clicks", "Conversions", "Cost"]; 
  var changeThreshold = 0.2; // 20% increase or decrease
  var comparisonPeriod = "LAST_7_DAYS"; // Timeframe for comparison
  var recipientEmail = "your_email@example.com";

  // Get the campaign
  var campaign = AdsApp.campaigns().withCondition("Name = '" + campaignName + "'").get().next();

  // Fetch performance data for the current and previous periods
  var currentStats = campaign.getStatsFor("TODAY");
  var previousStats = campaign.getStatsFor("PREVIOUS_" + comparisonPeriod); 

  // Analyze each metric
  for (var i = 0; i < metricsToTrack.length; i++) {
    var metric = metricsToTrack[i];
    var currentValue = currentStats.get(metric);
    var previousValue = previousStats.get(metric);

    var changePercentage = (currentValue - previousValue) / previousValue;

    // Send alert if the change is significant
    if (Math.abs(changePercentage) >= changeThreshold) {
      var direction = changePercentage > 0 ? "increased" : "decreased";
      var subject = "Performance Alert: " + campaignName;
      var body = metric + " has " + direction + " by " + (changePercentage * 100).toFixed(0) + "% compared to the previous " + comparisonPeriod.toLowerCase() + ".";
      MailApp.sendEmail(recipientEmail, subject, body);
    }
  }
}
function main() {
  // Threshold Settings
  var campaignBudgetThreshold = 0.8; // Alert when 80% of the budget is spent
  var sendEmailAlerts = true; // Set to false to disable emails
  var recipientEmail = "your_email@example.com";

  // Get all active campaigns
  var campaignIterator = AdsApp.campaigns()
      .withCondition("Status = ENABLED")
      .get();

  while (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    var campaignName = campaign.getName();
    var budget = campaign.getBudget().getAmount();
    var spendToDate = campaign.getStatsFor("TODAY").getCost();

    var spentPercentage = spendToDate / budget;

    if (spentPercentage >= campaignBudgetThreshold && sendEmailAlerts) {
      var subject = "Budget Alert: " + campaignName;
      var body = "Campaign " + campaignName + " has spent " + (spentPercentage * 100).toFixed(0) + "% of its budget.";
      MailApp.sendEmail(recipientEmail, subject, body);
    }
  }
}
function main() {
  // Campaign Selection
  var campaignName = "Campaign Name"; 

  // Ad Rotation Strategy (Choose one and adjust)
  var rotationStrategy = {
    // 1. Rotate Evenly: Give all ads equal chance
    // "ROTATE_EVENLY" 
    
    // 2. Optimize for Clicks: Show higher-performing ads more often 
    // "OPTIMIZE_FOR_CLICKS"

    // 3. Optimize for Conversions: Prioritize ads driving conversions
    // "OPTIMIZE_FOR_CONVERSIONS" 

    // 4. Rotate Indefinitely: Don't automatically select an ad 
    "ROTATE_INDEFINITELY" 
  }

  // Get the specified campaign
  var campaign = AdsApp.campaigns().withCondition("Name = '" + campaignName + "'").get().next();

   // Set the ad rotation type
  var adRotationType = campaign.getAdRotationType();

  // Apply only if rotation settings need to be changed
  if (adRotationType != rotationStrategy) {
    campaign.setAdRotationType(rotationStrategy); 
  }
}
function main() {
  // Settings
  var campaignName = "Campaign Name"; 
  var negativeKeywordListName = "Auto-Generated Negatives";
  var dateRange = "LAST_30_DAYS";

  // Find or create the negative keyword list
  var negativeKeywordList = AdsApp.negativeKeywordLists().withCondition("Name = '" + negativeKeywordListName + "'").get().next();
  if (!negativeKeywordList) {
    negativeKeywordList = AdsApp.newNegativeKeywordListBuilder()
      .withName(negativeKeywordListName)
      .build()
      .getResult();
  }

  // Get search query data 
  var queryReport = AdsApp.searchQueryPerformanceReport()
      .forCampaign(campaignName)
      .withCondition("Status = ENABLED") // Focus on active keywords
      .during(dateRange);

  var queryRows = queryReport.rows();
  while (queryRows.hasNext()) {
    var queryRow = queryRows.next();
    var searchQuery = queryRow.getQuery();
    var impressions = queryRow.getImpressions();
    var clicks = queryRow.getClicks();
    var cost = queryRow.getCost();

    // Add query as a negative keyword if it meets your criteria 
    // Example: High impressions, low CTR, high cost
    if (impressions > 100 && clicks == 0 && cost > 10) {
      negativeKeywordList.addNegativeKeyword(searchQuery);
    } 
  }

  // Apply the negative keyword list to the campaign
  var campaign = AdsApp.campaigns().withCondition("Name = '" + campaignName + "'").get().next();
  campaign.addNegativeKeywordList(negativeKeywordList);
}
import React, { useState } from 'react';

function ContactForm() {
    const [state, setState] = useState({
        name: '',
        email: '',
        message: ''
    });

    const handleChange = (e) => {
        const { name, value } = e.target;
        setState(prevState => ({
            ...prevState,
            [name]: value
        }));
    };

    const handleSubmit = (e) => {
        e.preventDefault();
        // Replace YOUR_FORM_ID with the actual ID provided by Formspree
        const formAction = 'https://formspree.io/f/YOUR_FORM_ID';
        fetch(formAction, {
            method: 'POST',
            body: JSON.stringify(state),
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json'
            },
        })
        .then(response => {
            if (response.ok) {
                alert('Message sent successfully.');
                setState({
                    name: '',
                    email: '',
                    message: ''
                });
            } else {
                alert('There was a problem with your submission. Please try again.');
            }
        })
        .catch(error => {
            console.error('Error:', error);
            alert('An error occurred. Please try again later.');
        });
    };

    return (
        <form onSubmit={handleSubmit}>
            <label htmlFor="name">Name:</label>
            <input
                type="text"
                id="name"
                name="name"
                value={state.name}
                onChange={handleChange}
                required
            />

            <label htmlFor="email">Email:</label>
            <input
                type="email"
                id="email"
                name="email"
                value={state.email}
                onChange={handleChange}
                required
            />

            <label htmlFor="message">Message:</label>
            <textarea
                id="message"
                name="message"
                value={state.message}
                onChange={handleChange}
                required
            ></textarea>

            <button type="submit">Send</button>
        </form>
    );
}

export default ContactForm;
function main() {
  // Settings
  var campaignName = "Campaign Name"; 
  var negativeKeywordListName = "Auto-Generated Negatives";
  var dateRange = "LAST_30_DAYS";

  // Find or create the negative keyword list
  var negativeKeywordList = AdsApp.negativeKeywordLists().withCondition("Name = '" + negativeKeywordListName + "'").get().next();
  if (!negativeKeywordList) {
    negativeKeywordList = AdsApp.newNegativeKeywordListBuilder()
      .withName(negativeKeywordListName)
      .build()
      .getResult();
  }

  // Get search query data 
  var queryReport = AdsApp.searchQueryPerformanceReport()
      .forCampaign(campaignName)
      .withCondition("Status = ENABLED") // Focus on active keywords
      .during(dateRange);

  var queryRows = queryReport.rows();
  while (queryRows.hasNext()) {
    var queryRow = queryRows.next();
    var searchQuery = queryRow.getQuery();
    var impressions = queryRow.getImpressions();
    var clicks = queryRow.getClicks();
    var cost = queryRow.getCost();

    // Add query as a negative keyword if it meets your criteria 
    // Example: High impressions, low CTR, high cost
    if (impressions > 100 && clicks == 0 && cost > 10) {
      negativeKeywordList.addNegativeKeyword(searchQuery);
    } 
  }

  // Apply the negative keyword list to the campaign
  var campaign = AdsApp.campaigns().withCondition("Name = '" + campaignName + "'").get().next();
  campaign.addNegativeKeywordList(negativeKeywordList);
}
function main() {
  // 1. Data Source: Google Sheet
  var spreadsheetUrl = "https://docs.google.com/spreadsheets/d/..."; // Replace with your spreadsheet URL
  var dataSheet = SpreadsheetApp.openByUrl(spreadsheetUrl).getSheetByName("CampaignData");

  // 2. Campaign Template Settings
  var campaignNameTemplate = "Dynamic Campaign - {Product Category}";
  var budget = 100; // Daily budget
  // ... other desired campaign settings ...

  // 3. Iterate through Spreadsheet Data 
  var dataRange = dataSheet.getDataRange().getValues(); 
  dataRange.shift(); // Remove header row

  for (var i = 0; i < dataRange.length; i++) {
    var productCategory = dataRange[i][0]; 
    // ... extract other data from the row ...

    // 4. Create New Campaign (Simplified)
    var campaignBuilder = AdsApp.newCampaignBuilder();
    var campaign = campaignBuilder
      .withName(campaignNameTemplate.replace("{Product Category}", productCategory))
      .withBudget({ amount: budget, currencyCode: "USD" })
      .build()
      .getResult(); 

    // 5. (Optional) Create Ad Groups, Keywords, Ads based on Spreadsheet Data
  }
}
function main() {
  // Define your schedule
  var dayOfWeek = "MONDAY"; 
  var startTime = "00:00"; // Midnight
  var endTime = "06:00";  // 6 AM

  // Campaign Selection 
  var campaignName = "Weekend Campaign";

  // Get the current day of the week and time (adjust the timezone if needed)
  var timeZone = "America/Los_Angeles";  
  var date = new Date();
  var currentDayOfWeek = Utilities.formatDate(date, "EEEE", timeZone);
  var currentTime = Utilities.formatDate(date, "HH:mm", timeZone);

  // Pause or enable the campaign based on the schedule
  var campaign = AdsApp.campaigns().withCondition("Name = '" + campaignName + "'").get().next();

  if (currentDayOfWeek == dayOfWeek && currentTime >= startTime && currentTime <= endTime) {
    campaign.pause();
  } else {
    campaign.enable();
  }
}
function main() {
  // Get your OpenWeatherMap API key (Sign up for a free account)
  var apiKey = "YOUR_API_KEY"; 

  // Target location (City or Zip Code)
  var targetLocation = "Los Angeles, CA"; 

  // Campaign Selection 
  var campaignName = "Summer Campaign"; 

  // Bid adjustments based on temperature
  var temperatureRanges = {
    "below_70": -0.1,   // Decrease bid by 10% if below 70°F
    "70_to_85": 0.0,    // No change between 70°F and 85°F 
    "above_85": 0.2     // Increase bid by 20% if above 85°F
  };

  // Fetch current weather data
  var weatherUrl = "https://api.openweathermap.org/data/2.5/weather?q=" + targetLocation + "&appid=" + apiKey + "&units=imperial";
  var weatherResponse = UrlFetchApp.fetch(weatherUrl);
  var weatherData = JSON.parse(weatherResponse.getContentText());

  // Extract temperature from the data
  var currentTemperature = weatherData.main.temp;

  // Determine the appropriate bid modifier
  var bidModifier;
  for (var range in temperatureRanges) {
    if (currentTemperature >= range.split("_")[1]) {
      bidModifier = temperatureRanges[range];
      break;
    }
  }

  // Apply the bid modifier at the campaign level
  var campaign = AdsApp.campaigns().withCondition("Name = '" + campaignName + "'").get().next();
  campaign.setBidModifier(1 + bidModifier); 
}
function main() {
  // Performance Thresholds
  var maxCPA = 50;  // Your maximum acceptable cost per acquisition
  var minClicks = 50; // Minimum clicks for reliable data

  // Timeframe: Analyze recent performance
  var dateRange = "LAST_30_DAYS"; 

  // Campaign Selection 
  var campaignName = "Campaign Name";

  // Get all the keywords in the specified campaign
  var keywordIterator = AdsApp.campaigns()
      .withCondition("Name = '" + campaignName + "'")
      .get()
      .keywords();

  while (keywordIterator.hasNext()) {
    var keyword = keywordIterator.next();

    // Gather keyword performance data
    var stats = keyword.getStatsFor(dateRange);
    var conversions = stats.getConversions();
    var cost = stats.getCost();
    var clicks = stats.getClicks();
    var currentCPA = cost / conversions;

    // Pause keywords if they exceed max CPA and have sufficient data
    if (currentCPA > maxCPA && clicks >= minClicks) {
      keyword.pause();
    }
  }
}
function main() {
  // Target Locations (Adjust this list!)
  var targetLocations = [
    "California", 
    "New York", 
    "Texas"
  ];

  // Bid Adjustments (Positive = Increase, Negative = Decrease)
  var locationBidModifiers = {
    "California": 0.20,  // Increase bids by 20% in California
    "New York": 0.10,    // Increase bids by 10% in New York
    "Texas": -0.15       // Decrease bids by 15% in Texas
  };

  // Campaign Selection 
  var campaignName = "Campaign Name"; 

  // Get all the location criteria within the specified campaign
  var locationIterator = AdsApp.campaigns()
      .withCondition("Name = '" + campaignName + "'")
      .get()
      .targeting().locations();

 while (locationIterator.hasNext()) {
    var location = locationIterator.next();
    var locationName = location.getName(); 

    // Check if the location is in our target list
    if (targetLocations.indexOf(locationName) !== -1) {
      var bidModifier = locationBidModifiers[locationName];

      // Set the bid modifier only if it exists
      if (bidModifier) {
        location.setBidModifier(1 + bidModifier); 
      }
    }
  }
}
function main() {
  // Performance Metrics
  var targetCPA = 30; // Your desired cost per acquisition
  var minConversions = 10; // Minimum conversions for reliable data

  // Timeframe: Analyze recent performance with flexibility
  var dateRange = "LAST_30_DAYS"; 

  // Campaign Selection 
  var campaignName = "Campaign Name"; 

  // Get relevant keywords
  var keywordIterator = AdsApp.campaigns()
      .withCondition("Name = '" + campaignName + "'")
      .get()
      .keywords();

  while (keywordIterator.hasNext()) {
    var keyword = keywordIterator.next();

    // Gather keyword performance data
    var stats = keyword.getStatsFor(dateRange);
    var conversions = stats.getConversions();
    var cost = stats.getCost();
    var currentCPA = cost / conversions;

    // Apply Bid Adjustments Only If Data is Sufficient 
    if (conversions >= minConversions) {
      if (currentCPA > targetCPA) {
        // Decrease bid if CPA is higher than target
        var newBid = keyword.getMaxCpc() * 0.9; // Example: Reduce by 10%
        keyword.setMaxCpc(newBid);
      } else if (currentCPA < targetCPA) {
        // Increase bid if CPA is lower than target
        var newBid = keyword.getMaxCpc() * 1.1; // Example: Increase by 10%
        keyword.setMaxCpc(newBid);
      }
    } 
  }
}
function main() {
  // Set your timezone for accurate time-based adjustments 
  var timeZone = "America/Los_Angeles";  

  // Get the current hour in your specified timezone
  var currentHour = Utilities.formatDate(new Date(), "HH", timeZone);

  // Define your campaign name (replace with your actual campaign)
  var campaignName = "Campaign Name"; 

  // Get all the keywords in the specified campaign
  var keywordIterator = AdsApp.campaigns()
      .withCondition("Name = '" + campaignName + "'")
      .get()
      .keywords();

  while (keywordIterator.hasNext()) {
    var keyword = keywordIterator.next();

    // Example: Increase bids by 20% during peak hours (9 AM to 5 PM)
    if (currentHour >= 9 && currentHour <= 17) {
      keyword.setBidModifier(1.2);  // Increase bid by 20%
    } else {
      keyword.setBidModifier(1.0);  // Reset bid to normal
    }
  }
}

# Makefile

SRC := $(wildcard *.cpp) $(wildcard *.cc) $(wildcard *.c)
OBJ := $(SRC:.cpp=.o) $(SRC:.cc=.o) $(SRC:.c=.o)
TARGET := my_program

CXX := /opt/homebrew/opt/ccache/libexec/g++
CXXFLAGS := -fdiagnostics-color=always -g -Wall -std=c++20

$(TARGET): $(OBJ)
    $(CXX) $(CXXFLAGS) -o $@ $^

clean:
    rm -f $(OBJ) $(TARGET)
* _Formula:_ (Gains from SEO - Cost of SEO) / Cost of SEO  
 * _Example:_ If increased organic search traffic generates an additional $2000 in revenue, and you spent $1000 on SEO tools and content creation, your ROI is 100%.

* _Action Steps:_
    * Track revenue attributed to organic search.
 * _Formula:_ (Time spent on social media * Hourly salary) / Number of conversions through social media 
 * _Example:_ Your social media efforts resulted in 10 new e-book sales. If you spent 20 hours on social media, with an hourly rate of $30, your social cost per conversion is $60.

 * _Action Steps:_
      * Analyze if this cost is sustainable given the value of each conversion.
      * Explore ways to streamline your social media tasks.
      * Focus on platforms that yield the best results.
* _Tools:_ Ahrefs, SEMrush, Moz, and others provide advanced position tracking. 
* _Example:_ You track keywords like "mindfulness tips," "meditation for beginners," and notice your average position improving over time. This indicates your SEO efforts are paying off.  
*  _Formula_ (Number of times a keyword appears / Total words on page) * 100 
*  _Example:_ If you want to rank for "vegan cake recipes", including that phrase a few times naturally is helpful.  Repeating it excessively becomes unnatural and hurts your chances of ranking well.

*  _Action Steps:_
      *  Focus on creating valuable, informative content first.
      *  Use keyword research tools to identify related terms and phrases (e.g., "eggless cake recipes," "dairy-free frosting").
 *  _Formula:_ (Conversions / Total Visitors) * 100
 * _Example:_  Despite good traffic, your e-book has a low conversion rate on its landing page. This could mean:
       *  Your call-to-action isn't clear or persuasive enough.
       * The landing page doesn't address visitor concerns or build enough trust.
       *  There are too many distractions or form fields on the page.

 * _Action Steps:_
       * Use strong verbs and clear language in your calls-to-action.
       * Highlight the benefits for the visitor.
       * Test different landing page designs and reduce clutter. 
* _Formula:_ (Single page visits / Total sessions) * 100
 * _Example:_ Your "best homemade pasta recipes" page has a high bounce rate. This might mean:
       *  People expect quick, simple recipes, but your content is too complex. 
       * Your images are slow to load, frustrating visitors.
       *  Internal links to related recipes are missing.

 * _Action Steps:_ 
        * Use tools like Google PageSpeed Insights to check load times. 
        * Clearly format your content with headings and short paragraphs.
        * Add internal links to keep visitors engaged on your website.
* _Formula:_ (Clicks / Impressions) * 100
 * _Example:_ You see that your blog post ranks well for "easy baking recipes," but its CTR is low. This indicates a potential problem with your title or meta description. 

 * _Action Steps:_ 
      * Experiment with power words (e.g., "Effortless," "Delicious")
      * Include numbers or a question in your title.
      * Ensure your meta description provides a clear, enticing preview of the content.
https://copenhagenbikes.dk/administrator/index.php

https://copenhagenbikes.dk/administrator/
import javax.swing.*;
import javax.swing.border.Border;

import java.awt.*;
class panelx extends JFrame{

    panelx(){
        setTitle("JPANEL CREATION");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(null);
        //setting the bounds for the JFrame
        setBounds(100,100,645,470);
        Border br = BorderFactory.createLineBorder(Color.black);
        Container c=getContentPane();
        //Creating a JPanel for the JFrame
        JPanel panel=new JPanel();
        JPanel panel2=new JPanel();
        JPanel panel3=new JPanel();
        JPanel panel4=new JPanel();
        //setting the panel layout as null
        panel.setLayout(null);
        panel2.setLayout(null);
        panel3.setLayout(null);
        panel4.setLayout(null);

        //adding a label element to the panel
        JLabel label=new JLabel("Panel 1");
        JLabel label2=new JLabel("Panel 2");
        JLabel label3=new JLabel("Panel 3");
        JLabel label4=new JLabel("Panel 4");

        label.setBounds(120,50,200,50);
        label2.setBounds(120,50,200,50);
        label3.setBounds(120,50,200,50);
        label4.setBounds(120,50,200,50);
        panel.add(label);
        panel2.add(label2);
        panel3.add(label3);
        panel4.add(label4);

        // changing the background color of the panel to yellow

        //Panel 1
        panel.setBackground(Color.yellow);
        panel.setBounds(10,10,300,200);

        //Panel 2
        panel2.setBackground(Color.red);
        panel2.setBounds(320,10,300,200);

        //Panel 3
        panel3.setBackground(Color.green);
        panel3.setBounds(10,220,300,200);

        //Panel 4
        panel4.setBackground(Color.cyan);
        panel4.setBounds(320,220,300,200);
        

        // Panel border
        panel.setBorder(br);
        panel2.setBorder(br);
        panel3.setBorder(br);
        panel4.setBorder(br);
        
        //adding the panel to the Container of the JFrame
        c.add(panel);
        c.add(panel2);
        c.add(panel3);
        c.add(panel4);
       

        setVisible(true);
    }
    public static void main(String[] args) {
        new panelx();
    }

}
/**
 * Format a given date object to YYYY-MM-DD format.
 * 
 * @param {Date} date The date object to be formatted.
 * @returns {string} The formatted date in YYYY-MM-DD format.
 */
function formatDateToYYYYMMDD(date) {
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0');
    const day = String(date.getDate()).padStart(2, '0');
    const formattedDate = `${year}-${month}-${day}`;
    return formattedDate;
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class InitialProject
{   JFrame frame;
	public InitialProject()
	{   frame = new JFrame("MENU");
	     
		frame.setSize(800, 500);
		
		frame.setLayout(new BorderLayout());
		frame.add(new JButton("CVR RESTAURANT"), BorderLayout.NORTH);
		JPanel panel = new JPanel();
		panel.add(new JButton("CONFIRM"));
		panel.add(new JButton("RESET"));
        panel.add(new JButton("EXIT"));
		
		frame.add(panel, BorderLayout.SOUTH);
		
		//frame.add(new JLabel("Border Layout West"), BorderLayout.WEST);
      //  frame.add(new JTextField(20), BorderLayout.NORTH);
        frame.add(new JTextField(30), BorderLayout.WEST);
		frame.add(new JTextField(30), BorderLayout.EAST);
		frame.add(new JButton(""), BorderLayout.CENTER);
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{
		new BorderLayoutDemo();
	}
}
KeyEventDemo.java

import java.awt.*;
import java.awt.event.*;

public class KeyEventDemo extends Frame implements KeyListener
{
	private String msg = "";
	private String state = "";
	
	public KeyEventDemo(){}
	
	public void keyPressed(KeyEvent ke)
	{  state = "Key Down";
	   repaint();
	}
	
	public void keyReleased(KeyEvent ke)
	{  state = "Key Up";
	   repaint();
	}
	
	public void keyTyped(KeyEvent ke)
	{  msg += ke.getKeyChar();
	   repaint();
	}
	
	public void paint(Graphics g)
	{  g.drawString(msg, 20, 100);
	   g.drawString(state, 20, 50);
	}
	
	public static void main(String[] args)
	{  KeyEventDemo f = new KeyEventDemo();
	   f.setSize(600, 400);
	   f.setFont(new Font("Dialog", Font.BOLD, 24));
	   f.setTitle("Key Event Demo");
	   
	   f.addKeyListener(f);
	   
	   f.addWindowListener(new WindowAdapter(){
		   public void windowClosing(WindowEvent we)
		   {  System.exit(0); }
	   });
	   f.setVisible(true);
	}	
}




MouseEventDemo.java

import java.awt.*;
import java.awt.event.*;

public class MouseEventDemo extends Frame implements MouseListener, MouseMotionListener
{
	private String msg = "";
	private int x = 0;
	private int y = 0;
	
	public MouseEventDemo(){}
	
	public void mouseClicked(MouseEvent me)
	{  x = y = 100;
	   msg = msg + " Mouse Clicked ";
	   repaint();
	}
	
	public void mouseEntered(MouseEvent me)
	{  x = y = 100;
	   msg = "Mouse Entered";
	   repaint();
	}
	
	public void mouseExited(MouseEvent me)
	{  x = y = 200;
	   msg = "Mouse Exited";
	   repaint();
	}
	
	public void mousePressed(MouseEvent me)
	{  x = me.getX(); y = me.getY();
	   msg = msg + " Mouse Pressed ";
	   repaint();
	}
	
	public void mouseReleased(MouseEvent me)
	{   x = me.getX(); y = me.getY();
	    msg = msg + " Mouse Released ";
	    repaint();
	}
	
	public void mouseDragged(MouseEvent me)
	{  x = me.getX(); y = me.getY();
	   msg = "* mouse at " + x +", "+y;
	   repaint();
	}
	
	

public void mouseMoved(MouseEvent me)
	{  x = me.getX(); y = me.getY();
	   msg = "Moving mouse at " + x +", "+y;
	   repaint();
	}
	
	public void paint(Graphics g)
	{  g.drawString(msg, x, y);
	}
	
	public static void main(String[] args)
	{  MouseEventDemo f = new MouseEventDemo();
	   f.setSize(600, 400);
	   f.setTitle("Mouse Event Demo");
	   
	   f.addMouseListener(f);
	   f.addMouseMotionListener(f);
	   
	   f.addWindowListener(new WindowAdapter(){
		   public void windowClosing(WindowEvent we)
	{  System.exit(0); }
	   });
	   f.setVisible(true);
	}	
}

 







FileChooserDemo.java

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

public class FileChooserDemo
{   private JFrame frame;
	private JFileChooser cc;
	private JButton b1, b2;
	private JTextArea ta;
     
	public FileChooserDemo()
	{
		frame = new JFrame("A Sample Frame");
		frame.setSize(700, 500);
		cc = new JFileChooser();
		ta = new JTextArea(20, 75);
 		frame.add(ta);
		
		b1 = new JButton("Open");
 		b1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae)
			{   cc.showOpenDialog(frame);
			    File f = cc.getSelectedFile();
				String text ="";
				try(FileInputStream fis = new FileInputStream(f))
				{ int c = -1;
				  while((c=fis.read()) != -1)
					  text += (char)c;
				  ta.setText(text);
				}
				catch(Exception e){ e.printStackTrace();}
			}
		});
		frame.add(b1);	

		b2 = new JButton("Save");
 		b2.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae)
			{    cc.showSaveDialog(frame);
			     File f = cc.getSelectedFile();
				String filename = f.getName();
				String text = ta.getText();
				byte[] b = text.getBytes();
				try(
                        FileOutputStream fos = new FileOutputStream(filename)
                         )
				{  for(int i=0; i<text.length();i++)
					   fos.write(b[i]);
				}
				catch(Exception e){ e.printStackTrace();}
			}
		});
		frame.add(b2);		
	
		frame.setLayout(new FlowLayout());
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	     frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{    	new FileChooserDemo();
	}
}

ColorChooserDemo.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.colorchooser.*;

public class ColorChooserDemo
{   private JFrame frame;
	private JColorChooser cc;
	private JButton b;
     
	public ColorChooserDemo()
	{
		frame = new JFrame("A Sample Frame");
		frame.setSize(700, 500);
		
		cc = new JColorChooser(); frame.add(cc);
		
		b = new JButton("Color Changer");
		b.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae)
			{ frame.getContentPane().setBackground(cc.getColor()); }
		});
		frame.add(b);		
				
		frame.setLayout(new FlowLayout());
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{  	new ColorChooserDemo(); 	}
}
BorderLayoutDemo.java

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

public class BorderLayoutDemo
{   JFrame frame;
	public BorderLayoutDemo()
	{   frame = new JFrame("Border Layout Demo");
	     
		frame.setSize(800, 500);
		
		frame.setLayout(new BorderLayout());
		frame.add(new JButton("North"), BorderLayout.NORTH);
		JPanel panel = new JPanel();
		panel.add(new JButton("Button 1"));
		panel.add(new JButton("Button 2"));
		frame.add(panel, BorderLayout.SOUTH);
		
		frame.add(new JLabel("Border Layout West"), BorderLayout.WEST);
		frame.add(new JTextField(10), BorderLayout.EAST);
		frame.add(new JButton("CENTER"), BorderLayout.CENTER);
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{
		new BorderLayoutDemo();
	}
}

GridLayoutDemo.java

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

public class GridLayoutDemo
{   JFrame frame;
	public GridLayoutDemo()
	{   frame = new JFrame("Border Layout Demo");
	    frame.setSize(800, 500);
		
		frame.setLayout(new GridLayout(4, 4));
		
		JButton b1 = new JButton("1");frame.add(b1);
		JButton b2 = new JButton("2");frame.add(b2);
		JButton b3 = new JButton("3");frame.add(b3);
		JButton b4 = new JButton("Add");frame.add(b4);
		
		JButton b5 = new JButton("4");frame.add(b5);
		JButton b6 = new JButton("5");frame.add(b6);
		JButton b7 = new JButton("6");frame.add(b7);
		JButton b8 = new JButton("Subtract");frame.add(b8);
		
		JButton b9 = new JButton("7");frame.add(b9);
		JButton b10 = new JButton("8");frame.add(b10);
		JButton b11 = new JButton("9");frame.add(b11);
		JButton b12 = new JButton("Multiply");frame.add(b12);
		
		JButton b13 = new JButton("Dot");frame.add(b13);
		JButton b14 = new JButton("0");frame.add(b14);
		JButton b15 = new JButton("Percentage");frame.add(b15);
		JButton b16 = new JButton("Divide");frame.add(b16);
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{
		new GridLayoutDemo();
	}
}


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

public class CardLayoutDemo
{   JFrame frame;
	public CardLayoutDemo()
	{   frame = new JFrame("Border Layout Demo");
	    frame.setSize(800, 500);
		frame.setLayout(new FlowLayout());
		
		CardLayout clo = new CardLayout();
		JPanel p1 = new JPanel();p1.setBackground(Color.yellow);
		JPanel p2 = new JPanel();p2.setBackground(Color.yellow);
		JPanel p3 = new JPanel();p3.setBackground(Color.yellow);
		JPanel p4 = new JPanel();p4.setBackground(Color.yellow);
		
		JPanel main = new JPanel();
		main.setLayout(clo);
		p1.setBackground(Color.yellow);
		
		JButton b1 = new JButton("Open");	p1.add(b1);
		JButton b2 = new JButton("Save");	p1.add(b2);
		
		JButton b3 = new JButton("Exit");   	p2.add(b3);
		JButton b4 = new JButton("Dispose"); 	p2.add(b4);
		
		JCheckBox c1 = new JCheckBox("AWT"); p3.add(c1);
		JCheckBox c2 = new JCheckBox("Swing"); p3.add(c2);
		
		JCheckBox c3 = new JCheckBox("Java"); p4.add(c3);
		JCheckBox c4 = new JCheckBox("Python"); p4.add(c4);
		
		main.add(p1, "panel1"); main.add(p2, "panel2"); 
		main.add(p3, "panel3"); main.add(p4, "panel4");
		frame.add(main);
		
		JButton next = new JButton("Next");
		next.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae)
			{ clo.next(main);}
		});
		frame.add(next);
		
		JButton previous = new JButton("Previous");
		previous.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae)
			{ clo.previous(main);}
		});
		frame.add(previous); 
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{
		new CardLayoutDemo();
	}
}










SwingDemo.java

// Listener implemented as a separate class

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

public class SwingDemo
{   private JFrame frame;
	private JButton b1, b2;
     
	public SwingDemo()
	{    	frame = new JFrame("A Sample Frame");
		frame.setSize(700, 500);
		
		MyListener lis = new MyListener(frame);
		
		b1 = new JButton("Green");
		b1.addActionListener(lis); 	frame.add(b1);
				
		b2 = new JButton("Yellow");
		b2.addActionListener(lis); frame.add(b2);
		
		frame.setLayout(new FlowLayout());
        	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    	frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{   new SwingDemo();
	}
	
}

class MyListener implements ActionListener
{   
    private JFrame fr;

    public MyListener(JFrame fr)
	{ this.fr = fr; }
	
	public void actionPerformed(ActionEvent ae)
	{    	String s = ae.getActionCommand();
		if(s.equals("Green"))
			fr.getContentPane().setBackground(Color.green);
		if(s.equals("Yellow"))
			fr.getContentPane().setBackground(Color.yellow);	
	}
}

SwingDemo2.java

// Listener implemented as an inner class

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

public class SwingDemo2
{   private JFrame frame;
	private JButton b1, b2;
     
	public SwingDemo2()
	{
		frame = new JFrame("A Sample Frame");
		frame.setSize(700, 500);
		
		MyListener lis = this.new MyListener();  
// note the use of this here
		
		b1 = new JButton("Green");
		b1.addActionListener(lis); frame.add(b1);
				
		b2 = new JButton("Yellow");
		b2.addActionListener(lis); frame.add(b2);
		
		frame.setLayout(new FlowLayout());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{   new SwingDemo2();
	}

	class MyListener implements ActionListener
	{   		
		public void actionPerformed(ActionEvent ae)
		{   String s = ae.getActionCommand();
			if(s.equals("Green"))
				frame.getContentPane().setBackground(Color.green);
			if(s.equals("Yellow"))
				frame.getContentPane().setBackground(Color.yellow);	
		}
	}
}






SwingDemo3.java

// Listener implemented as anonymoys classes

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

public class SwingDemo3
{   private JFrame frame;
	private JButton b1, b2;
     
	public SwingDemo3()
	{
		frame = new JFrame("A Sample Frame");
		frame.setSize(700, 500);
				
		b1 = new JButton("Green");
		b1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae)
			{	frame.getContentPane().setBackground(Color.green);
			}
		}); 
		frame.add(b1);
				
		b2 = new JButton("Yellow");
		b2.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae)
			{	frame.getContentPane().setBackground(Color.yellow);
			}
		});
		frame.add(b2);
		
		frame.setLayout(new FlowLayout());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{   new SwingDemo3();
	}	 
}


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

public class LabelDemo
{   private JFrame frame;
    private JLabel label;
	 
	public LabelDemo()
	{
		frame = new JFrame("A Simple Swing App");

		Toolkit tk = frame.getToolkit();
		Dimension dim = tk.getScreenSize();
		int width = (int)dim.getWidth();
		int height = (int)dim.getHeight();
		frame.setSize(width, height);
		
		frame.setLayout(new FlowLayout());	
		
		ImageIcon ic = new ImageIcon("Animated_butterfly.gif");
		
		label = new JLabel("A Butterfly", ic, JLabel.CENTER);
		label.setFont(new Font("Verdana", Font.BOLD, 18));	
		label.setBackground(Color.yellow);
		frame.add(label);
				
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{   new LabelDemo();
	}
}


ButtonDemo.java

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

public class ButtonDemo  
{   private JFrame frame;
    private JLabel label;
	private JButton b1, b2; 
	
	public ButtonDemo()
	{
		frame = new JFrame("A Simple Swing App");

		Toolkit tk = frame.getToolkit();
		Dimension dim = tk.getScreenSize();
		int width = (int)dim.getWidth();
		int height = (int)dim.getHeight();
		frame.setSize(width, height);
		
		frame.setLayout(new FlowLayout());	
		
		label = new JLabel("I show the button text");
		label.setFont(new Font("Verdana", Font.BOLD, 18));	
		frame.add(label);
		
		b1 = new JButton("The First Button");
		b1.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(b1);
		b1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae)
			{   label.setText(b1.getText()+" is pressed!"); 	}
		});
		
		b2 = new JButton("The Second Button");
		b2.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(b2);
		b2.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae)
			{   label.setText(b2.getText()+" is pressed!"); 	}
		});
				
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public static void main(String[] args)
	{   new ButtonDemo();
	}
}


CheckBoxDemo.java

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

public class CheckBoxDemo implements ItemListener
{ 
private JFrame frame;
	private JCheckBox c1, c2, c3, c4;
	private JLabel label;
	private String message =" ";
	
	public CheckBoxDemo()
	{
		frame = new JFrame("A Simple Swing App");

		//frame.setSize(600, 400);
		Toolkit tk = frame.getToolkit();
		Dimension dim = tk.getScreenSize();
		int width = (int)dim.getWidth();
		int height = (int)dim.getHeight();
		frame.setSize(width, height);
		 
		frame.setLayout(new FlowLayout());	
		
		c1 = new JCheckBox("Pizza");
		c1.addItemListener(this);
		c1.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(c1);
		
		c2 = new JCheckBox("Burger");
		c2.addItemListener(this);
		c2.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(c2);
		
		c3 = new JCheckBox("Rolls");
		c3.addItemListener(this);
		c3.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(c3);
		
		c4 = new JCheckBox("Beverage");
		c4.addItemListener(this);
		c4.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(c4);
		
		label = new JLabel("I show the selected items");
		label.setFont(new Font("Verdana", Font.BOLD, 18));
		label.setForeground(Color.RED);
		frame.add(label);
		
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public void itemStateChanged(ItemEvent ie)
	{
		if(c1.isSelected())
			message += c1.getText() +" ";
		if(c2.isSelected())
			message += c2.getText() +" ";
		if(c3.isSelected())
			message += c3.getText() +" ";
		if(c4.isSelected())
			message += c4.getText() +" ";
		label.setText(message);
		
		message = " ";
	}
	
	public static void main(String[] args)
	{
		new CheckBoxDemo();
	}
}

RadioButtonDemo.java

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

public class RadioButtonDemo implements ActionListener
{ 
    private JFrame frame;
	private JRadioButton c1, c2, c3, c4;
	private JLabel label;
	 
	public RadioButtonDemo()
	{
		frame = new JFrame("A Simple Swing App");

		//frame.setSize(600, 400);
		Toolkit tk = frame.getToolkit();
		Dimension dim = tk.getScreenSize();
		int width = (int)dim.getWidth();
		int height = (int)dim.getHeight();
		frame.setSize(width, height);
		 
		frame.setLayout(new FlowLayout());	
		
		c1 = new JRadioButton("Pizza");
		c1.addActionListener(this);
		c1.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(c1);
		
		c2 = new JRadioButton("Burger");
		c2.addActionListener(this);
		c2.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(c2);
		
		c3 = new JRadioButton("Rolls");
		c3.addActionListener(this);
		c3.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(c3);
		
		c4 = new JRadioButton("Beverage");
		c4.addActionListener(this);
		c4.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(c4);
		
		ButtonGroup bg = new ButtonGroup();
		bg.add(c1); bg.add(c2); bg.add(c3); bg.add(c4);
		
		label = new JLabel("I show the selected items");
		label.setFont(new Font("Verdana", Font.BOLD, 18));
		label.setForeground(Color.RED);
		frame.add(label);
				
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public void actionPerformed(ActionEvent ae)
	{   label.setText(ae.getActionCommand());		 
	}
	
	public static void main(String[] args)
	{   new RadioButtonDemo();
	}
}

ComboBoxDemo.java

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

public class ComboBoxDemo implements ActionListener
{ 
    private JFrame frame;
	private JComboBox cb;
	private JLabel label;
		
	public ComboBoxDemo()
	{
		frame = new JFrame("A Simple Swing App");

		//frame.setSize(600, 400);
		Toolkit tk = frame.getToolkit();
		Dimension dim = tk.getScreenSize();
		int width = (int)dim.getWidth();
		int height = (int)dim.getHeight();
		frame.setSize(width, height);
		 
		frame.setLayout(new FlowLayout());	
		
		cb = new JComboBox();
		cb.addItem("Banana"); cb.addItem("Apple"); cb.addItem("Orange"); 
		cb.addItem("Grape");  cb.addItem("Mango"); cb.addItem("Pineapple");			
		
		cb.addActionListener(this);
		frame.add(cb);
		
		label = new JLabel("I show the selected item");
		label.setFont(new Font("Verdana", Font.BOLD, 18));
		label.setForeground(Color.RED);
		frame.add(label);
				
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public void actionPerformed(ActionEvent ae)
	{   label.setText((String)cb.getSelectedItem());		 
	}
	
	public static void main(String[] args)
	{   new ComboBoxDemo();
	}
}

ComboBoxDemo2.java

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

public class ComboBoxDemo2 implements ActionListener
{ 
    private JFrame frame;
	private JComboBox cb1, cb2, cb3;
	private JLabel label;
	
	public ComboBoxDemo2()
	{
		frame = new JFrame("A Simple Swing App");

		//frame.setSize(600, 400);
		Toolkit tk = frame.getToolkit();
		Dimension dim = tk.getScreenSize();
		int width = (int)dim.getWidth();
		int height = (int)dim.getHeight();
		frame.setSize(width, height);
		 
		frame.setLayout(new FlowLayout());	
		
		String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", 
		                   "September", "October", "November", "December"};
		cb1 = new JComboBox(); cb2 = new JComboBox(months); cb3 = new JComboBox();
		
		for(int i = 1; i<=31; i++){ cb1.addItem(i); }
		for(int i = 1970; i<2048; i++){ cb3.addItem(i); }	
				
		cb1.addActionListener(this); cb2.addActionListener(this); cb3.addActionListener(this);
		frame.add(cb1); frame.add(cb2); frame.add(cb3);
		
		label = new JLabel("I show the selected Date");
		label.setFont(new Font("Verdana", Font.BOLD, 18));
		label.setForeground(Color.RED);
		frame.add(label);
				
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public void actionPerformed(ActionEvent ae)
	{   String message = "";
	    message += (Integer)cb1.getSelectedItem()+", ";
		message += (String)cb2.getSelectedItem()+", ";
		message += (Integer)cb3.getSelectedItem();
		label.setText(message);		 
	}
	
	public static void main(String[] args)
	{   new ComboBoxDemo2();
	}
}

ListDemo.java

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

public class ListDemo implements ListSelectionListener
{ 
    private JFrame frame;
	private JList<String> list;
	private JLabel label;
	private JToolTip tip;
	
	public ListDemo()
	{
		frame = new JFrame("A Simple Swing App");

		//frame.setSize(600, 400);
		Toolkit tk = frame.getToolkit();
		Dimension dim = tk.getScreenSize();
		int width = (int)dim.getWidth();
		int height = (int)dim.getHeight();
		frame.setSize(width, height);
		 
		frame.setLayout(new FlowLayout());	
		
		String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", 
		                   "September", "October", "November", "December"};
		list = new JList<String>(months);
		list.addListSelectionListener(this);
		frame.add(list);
		
		//JScrollPane sp = new JScrollPane(list);
		//frame.add(sp);
		
		label = new JLabel("I show the selected Date");
		label.setFont(new Font("Verdana", Font.BOLD, 18));
		label.setForeground(Color.RED);
		frame.add(label);
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public void valueChanged(ListSelectionEvent ae)
	{   String message = "";
	    for(String each: list.getSelectedValuesList())
			message += each +" ";
		label.setText(message);		 
	}
	
	public static void main(String[] args)
	{   new ListDemo();
	}
}





TextDemo.java

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

public class TextDemo implements ActionListener 
{ 
    private JFrame frame;
	private JTextField tf1, tf2, tf3;
	private JTextArea ta;
	private JLabel label, label2;
	private JButton b;
		
	public TextDemo()
	{
		frame = new JFrame("A Simple Swing App");

		//frame.setSize(600, 400);
		Toolkit tk = frame.getToolkit();
		Dimension dim = tk.getScreenSize();
		int width = (int)dim.getWidth();
		int height = (int)dim.getHeight();
		frame.setSize(width, height);
		 
		frame.setLayout(new FlowLayout());	
		
		tf1 = new JTextField("Enter the name", 25); tf2 = new JTextField(20); tf3 = new JTextField("Enter a value");
		tf1.setFont(new Font("Verdana", Font.BOLD, 18));
		tf2.setFont(new Font("Verdana", Font.BOLD, 18));
		tf3.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(tf1); frame.add(tf2); frame.add(tf3);
		//tf1.addActionListener(this); tf2.addActionListener(this); tf3.addActionListener(this);
		
		ta = new JTextArea(20, 15);
		ta.setFont(new Font("Verdana", Font.BOLD, 18));
		frame.add(ta);
				
		label = new JLabel();
		label.setFont(new Font("Verdana", Font.BOLD, 18));
		label.setForeground(Color.RED);
		frame.add(label);
		
		label2 = new JLabel();
		label2.setFont(new Font("Verdana", Font.BOLD, 18));
		label2.setForeground(Color.green);
		frame.add(label2);
		
		b = new JButton("Display");
		b.addActionListener(this);
		frame.add(b);
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public void actionPerformed(ActionEvent ae)
	{   String message ="";
		message += tf1.getText()+": ";
		message += tf2.getText()+": ";
		message += tf3.getText()+": ";
		label.setText(message);
		label2.setText(ta.getText());
	}
		
	public static void main(String[] args)
	{   new TextDemo();
	}
}
function onOpen(e) {
   SpreadsheetApp.getUi()
       .createMenu('SBS Mailer')
       .addItem('Send out emails', 'sendEmails')
       .addItem('Remaining quota', 'remainingQuota')
       .addToUi();
}

function remainingQuota() {
   var emailQuotaRemaining = MailApp.getRemainingDailyQuota();
   Logger.log("Remaining email quota: " + emailQuotaRemaining);
  
  var ss = SpreadsheetApp.openById("1sxOrLJM0Tvd-21vu2zfVxSOSd2lL-hKmYOppQJGDtT8");
  var sheet = ss.getSheetByName('emails_list');
  var quota = ss.getRange("F2").setValue(emailQuotaRemaining);
}

function sendEmails() {
  var ss = SpreadsheetApp.openById("1sxOrLJM0Tvd-21vu2zfVxSOSd2lL-hKmYOppQJGDtT8");
  var sheet = ss.getSheetByName('emails_list');
  var subject = ss.getRange("E2").getValue();
  
  var count_range = sheet.getRange(2, 1, 1500).getValues();
  var flat = count_range.reduce(function(acc, row){
    return acc.concat(row.filter(function(x) {
      return x != "";
    }));
  }, []);
  
  var startRow=2; 
  var numRows=flat.length;
  
  var dataRange=sheet.getRange(startRow, 1, numRows, 3);
  //changed to getDisplayValues
  var data=dataRange.getDisplayValues();
  //changed to for loop
  for (var i=0;i<data.length;i++) {
    var row=data[i];
    var emailAddress=row[0]; 
    
      
    var message=HtmlService.createHtmlOutputFromFile('mail_template').getContent();
    
    var options = {}
    options.htmlBody = message;
    MailApp.sendEmail(emailAddress, subject, '', options);

  }
}


<input                       
    type="text" 
    placeholder="Start date" 
    class="px-2 py-1 text-sm rounded text-gray-800" 
    x-init="new Pikaday({ field: $el })"
    x-on:change="$wire.startDate = formatDateToYYYYMMDD(new Date($el.value))"
/>
#top-menu .current-menu-item a::before,
#top-menu .current_page_item a::before {
 content: "";
 position: absolute;
 z-index: 2;
 left: 0;
 right: 0;
}
#top-menu li a:before {
 content: "";
 position: absolute;
 z-index: -2;
 left: 0;
 right: 100%;
 bottom: 50%;
 background: #15bf86; /*** COLOR OF THE LINE ***/
 height: 3px; /*** THICKNESS OF THE LINE ***/
 -webkit-transition-property: right;
 transition-property: right;
 -webkit-transition-duration: 0.3s;
 transition-duration: 0.3s;
 -webkit-transition-timing-function: ease-out;
 transition-timing-function: ease-out;
}
#top-menu li a:hover {
 opacity: 1 !important;
}
#top-menu li a:hover:before {
 right: 0;
}
#top-menu li li a:before {
 bottom: 10%;
}
json-server --watch db.json --id _id --port 3001 
// Execute the client side code
function confirmClosure() {
    if (confirm('Are you sure you want to close this issue?') == false) {
        return false;
    } else {
        // Submit the server side code below
        gsftSubmit(null, g_form.getFormElement(), 'vf_close_complete');
    }
}

// Ensure call to server-side function with no browser errors
if (typeof window == 'undefined') {
	// Server side code
    updateCloseComplete();
}

// Server side code
function updateCloseComplete() {
    var taskList = new IssueGrouping().hasOpenTasks(current);
    if (taskList.length > 0) {
        var link = '<a id="permalink" class="linked" style="color:#666666;" href="/sn_grc_task_list.do?sysparm_query=sys_idIN' + taskList.toString() + '" target="_blank">Active Remediation Tasks</a>';
        gs.addErrorMessage(gs.getMessage('This Issue has open Tasks and/or Actions and the state of the Issue cannot be set to Closed Complete whilst open child Tasks or Actions exists Please close the child Tasks and/or Actions first.  Click here for a complete list of open child Tasks and/or Actions: {0}', link));
    } else {
        current.state = '3';
		current.substate = '';
        current.update();
        action.setRedirectURL(current);
    }
}
{% if attribute(theme.settings.header, 'show_top_message_'~locale) == 'yes' %}
    {% set move = 15 %}
    {% set delay = 0 %}
	<section id="top_message">
		<a href="{{attribute(theme.settings.header, 'top_message_link_'~locale)}}" 
		   rel="{{theme.settings.header.top_message_link_REL}}"
		   target="{{theme.settings.header.top_message_link_TARGET}}"
		   title="{{attribute(theme.settings.header, 'top_message_link_TITLE_'~locale)}}"
		   >
		    {% if attribute(theme.settings.header, 'animation_type') == 'fisso' %}
    			<div class="container text-center">
    				<span id="settings_header_top_message_text_{{locale}}" 
    					  data-editor="settings_header_top_message_text_{{locale}}">
    					{{attribute(theme.settings.header, 'top_message_text_'~locale)}}
    				</span>
				</div>
			{% elseif attribute(theme.settings.header, 'animation_type') == 'scorrimento' %}
		        {% if '##' in attribute(theme.settings.header, 'top_message_text_'~locale) %}
		            {% set topMessages = attribute(theme.settings.header, 'top_message_text_'~locale) | split('##') %}
		            <div class="d-flex">
    		            {% for i,message in topMessages  %}
    		                {% if i > 0 %}
    		                    {% set delay = (move + 1) * (i * 5) %}
    		                {% endif %}
    		                <div class="container text-center"
    		                    {% if i > 0 %}
    		                        style="animation-delay: {{delay}}s;"
    		                    {% endif %}
    		                >
    			                <span>
    			                    {{message | trim}}
    		                    </span>
    	                    </div>
    		            {% endfor %}
    		            <style>
    		                #top_message .container {
    		                    width: 500px;
    		                }
    		            </style>
		            </div>
		        {% else %}
		            <div class="container text-center">
        				<span id="settings_header_top_message_text_{{locale}}" 
        					  data-editor="settings_header_top_message_text_{{locale}}">
        					{{attribute(theme.settings.header, 'top_message_text_'~locale)}}
        				</span>
    				</div>
				{% endif %}
			{% else %}
                {% set topMessages = attribute(theme.settings.header, 'top_message_text_'~locale) | split('##') %} 
			    <div class="my-container text-center">
			        {% set duration = 6 %}
				    {% for i,message in topMessages %}
				        <span class="slide_message slide_message-{{i}} {{i == 0 and topMessages | length > 0 ? 'initial-anim' : ''}}">
				            {{message | trim}}
			            </span>
				    {% endfor %}
				    {% if topMessages | length == 1 %}
				        {% set duration = 8 %}
			        {% elseif topMessages | length == 2 %}
			            {% set duration = 12 %}
				    {% elseif topMessages | length > 2 %}
				        {% set duration = duration * topMessages | length %}
				    {% endif %}
			    </div>
			{% endif %}
		</a>
		{#
		<div class="close">
		    <i class="fa-solid fa-xmark"></i>
		</div>
		#}
	</section>
{% endif %}

{% if attribute(theme.settings.header, 'show_top_message_'~locale) == 'yes' %}
    {% if attribute(theme.settings.header, 'animation_type') == 'scorrimento' %}
        <style scoped>
            @keyframes move {
                to { transform: translateX(-100%); }
            }
            
            #top_message > a > div {
                transform: translateX(100%);
                animation: move {{move}}s linear infinite;
            }
            
            #top_message, #top_message * {
                overflow: hidden;
            }
        </style>
    {% endif %}
{% endif %}

{% if attribute(theme.settings.header, 'show_top_message_'~locale) == 'yes' %}
    {% if attribute(theme.settings.header, 'animation_type') == 'slide' %}
        {% if topMessages | length > 0 %}
            <script>
                $(document).ready(function() {
                    $(".initial-anim").on("animationiteration", function() {
                        $(this).removeClass("initial-anim");
                    });
                });
            </script>
            
            <style scoped>
        
                #top_message .my-container {
                    overflow: hidden;
                    position: relative;
                    height: 20px;
                    margin: 0 auto;
                }
                
                #top_message .my-container > div {
                    overflow: hidden;
                    width: 70%;
                    height: 100%;
                    position: relative;
                    margin: 0 auto;
                }
                
                #top_message .slide_message {
                    display: block;
                    width: 100%;
                    text-align: center;
                    position: absolute;
                    top: 0;
                    bottom: auto;
                    animation-duration: {{duration}}s;
                    animation-timing-function: linear;
	                animation-iteration-count: infinite;
                }
                
                .slide_message-0.initial-anim {
                	animation-name: initial-anim;
                }
                
                .slide_message-0:not(.initial-anim) {
                	animation-name: anim-0;
                }
                
                .slide_message-1 {
                	animation-name: anim-1;
                }
                
                .slide_message-2 {
                	animation-name: anim-2;
                }
                
                @keyframes initial-anim {
                	0%, 8.3% { left: 0; opacity: 1; }
                    8.3%,25% { left: 0; opacity: 1; }
                    33.33%, 100% { left: 110%; opacity: 0; }
                }
                
                
                @keyframes anim-0 {
                	0%, 8.3% { left: -100%; opacity: 0.5; }
                    8.3%,25% { left: 0; opacity: 1; }
                    33.33%, 100% { left: 110%; opacity: 0; }
                }
                
                @keyframes anim-1 {
                	0%, 33.33% { left: -100%; opacity: 0.5; }
                    41.63%, 58.29% { left: 0; opacity: 1; }
                    66.66%, 100% { left: 110%; opacity: 0; }
                }
                
                @keyframes anim-2 {
                	0%, 66.66% { left: -100%; opacity: 0.5; }
                    74.96%, 91.62% { left: 0; opacity: 1; }
                    100% { left: 110%; opacity: 0; }
                }
                
                #top_message .my-container:hover .slide_message-0,
                #top_message .my-container:hover .slide_message-1,
                #top_message .my-container:hover .slide_message-2
                {
                	animation-play-state: paused;
                }
                
                @media all and (min-width: 769px){
                    #top_message .my-container {
                        max-width: 92%;
                    }
                }
                
                @media all and (max-width: 768px){
                    #top_message .my-container {
                        max-width: 96%;
                    }
                }
                
            </style>
        
        {% endif %}
    {% endif %}
{% endif %}
https://codepen.io/exitfish/pen/oOaOPz
[
    {
        "$match": {
            "userId": 
                ObjectId("64d1ee7758a82e63a46206fe")
            ,
            "$and": [
                {
                    "insertedFor": {
                        "$gte": {
                            "$date": "2024-02-18T09:52:03Z"
                        }
                    }
                },
                {
                    "insertedFor": {
                        "$lte": {
                            "$date": "2024-02-20T09:52:03Z"
                        }
                    }
                }
            ]
        }
    },
    {
        "$project": {
            "insertedFor": 1
        }
    },
  {
    $count:"toot"
  }
]
# mount share folder
sudo mount -t 9p -o trans=virtio /[set shareFolder] /[path vm share folder]

# make change like permanents
# edit file fstab
/[set share folder] /[path vm share folder] 9p trans=virtio, version=9p2000L, rw   0   0
#include <iostream>
#include<cstring>
#include<memory>

using namespace std;

bool isValid (string customerNumber) {
    if (customerNumber.length() != 6)
        return false;

    for(int i = 0; i < 2; i++)
    if (!isalpha(customerNumber[i]))
        return false;

   for (int i = 2; i < customerNumber.length(); i++)
       if(!isdigit(customerNumber[i]))
           return false;

   return true;
}

int main() {

    string cust_number = "AB1234";
    cout << isValid(cust_number);
  return 0;
}
git reset --mixed origin/main
git add .
git commit -m "This is a new commit for what I originally planned to be amended"
git push origin main
<script>
    jQuery(document).ready(function($) {
        // Handle clicks on main menu items
        $("a.premium-menu-link").click(function(e) {
            var submenu = $(this).siblings('.premium-sub-menu');

            if (submenu.length) {
                // Toggle the submenu visibility with a delay
                setTimeout(function() {
                    submenu.toggleClass('active-menu');

                    // Add a class to the clicked parent menu link
                    $(this).addClass('parent-menu-link');

                    // Remove submenu-link class from all submenu items
                    $(".premium-sub-menu a.premium-menu-link").removeClass('submenu-link');

                    // Set inline styles on the parent <ul>
                    var parentUl = $(this).closest('ul');
                    parentUl.css({
                        'visibility': 'visible',
                        'overflow': 'visible',
                        'opacity': 1,
                        'height': 'auto'
                    });

                    // Set opacity to 1 on the <li> elements of the same <ul>
                    parentUl.find('li').css('opacity', 1);
                }.bind(this), 150); // Adjust the delay in milliseconds

                // Close other open submenus (optional)
                $(".premium-sub-menu").not(submenu).removeClass('active-menu');

                // Prevent redirection for non-leaf items
                e.preventDefault();
            }
        });

        // Handle clicks on submenu items
        $(".premium-sub-menu a.premium-menu-link").click(function(e) {
            // Add a class to the submenu link
            $(this).addClass('submenu-link');

            // Set inline styles on the parent <ul>
            var parentUl = $(this).closest('ul');
            parentUl.css({
                'visibility': 'visible',
                'overflow': 'visible',
                'opacity': 1,
                'height': 'auto'
            });

            // Set opacity to 1 on the <li> elements of the same <ul>
            parentUl.find('li').css('opacity', 1);
        });
    });
</script>
public class WordToNumAR
{
    str bigCurrency;
    str smallCurrency;
    real X;
    real InputNo;
    str OutStr;

    str bigCurrency( str _bigCurrency = bigCurrency)
    {
        bigCurrency = _bigCurrency;
        return bigCurrency;
    }

    protected void Eightd()
    {
        real xx;
        ;
        if (InputNo < 10000000 || X < 10000000)
        {
            this.Sevend();
            return;
        }
        //double xx;
        xx = X;
        X = real2int(X / 1000000);
        this.Twod();
        OutStr = OutStr + " مليون";
        X = xx - real2int(xx / 1000000) * 1000000;
        if (X != 0)
        {
            OutStr = OutStr + " و";
        }
        this.Sixd();
        X = xx;
    }

    protected void Fived()
    {
        real xx;
        ;
        if (InputNo < 10000 || X < 10000)
        {
            this.Fourd();
            return;
        }

        xx = X;
        X = real2int(X / 1000);
        this.Twod();
        OutStr = OutStr + " ألف";
        X = xx - real2int(xx / 1000) * 1000;
        if (X != 0)
        {
            OutStr = OutStr + " و";
        }
        this.Threed();

    }

    protected void Fourd()
    {
        real xx
            ;
        if (InputNo < 1000 || X < 1000)
        {
            this.Threed();
            return;
        }

        xx = X;
        X = real2int(X / 1000);
        switch (X)
        {
            case 1:
                OutStr = OutStr + " ألف";
                break;
            case 2:
                OutStr = OutStr + " ألفان";
                break;
            default:
                this.Oned();
                OutStr = OutStr + " آلاف";
                break;
        }
        X = xx - (X * 1000);
        if (X != 0)
        {
            OutStr = OutStr + " و";
        }
        this.Threed();

    }

    protected void Nined()
    {
        real xx;
        if (InputNo < 100000000 || X < 100000000)
        {
            this.Eightd();
            return;
        }

        xx = X;
        X = real2int(X / 1000000);
        this.Threed();
        OutStr = OutStr + " مليون";
        X = xx - real2int(xx / 1000000) * 1000000;
        if (X != 0)
        {
            OutStr = OutStr + " و";
        }
        this.Sixd();
    }

    protected boolean Oned()
    {
        switch (X)
        {
            case 1:
                OutStr = OutStr + " واحد";
                return true;
            case 2:
                OutStr = OutStr + " اثنان";
                return true;
            case 3:
                OutStr = OutStr + " ثلاثة";
                return true;
            case 4:
                OutStr = OutStr + " أربعة";
                return true;
            case 5:
                OutStr = OutStr + " خمسة";
                return true;
            case 6:
                OutStr = OutStr + " ستة";
                return true;
            case 7:
                OutStr = OutStr + " سبعة";
                return true;
            case 8:
                OutStr = OutStr + " ثمانية";
                return true;
            case 9:
                OutStr = OutStr + " تسعة";
                return true;
        }
        // case 0
        return false;
    }

    protected void Sevend()
    {
        real xx;
        ;
        if (InputNo < 1000000 || X < 1000000)
        {
            this.Sixd();
            return;
        }

        xx = X;
        X = real2int(X / 1000000);
        switch (X)
        {
            case 1:
                OutStr = OutStr + " مليون";
                break;
            case 2:
                OutStr = OutStr + " مليونان";
                break;
            default:
                this.Oned();
                OutStr = OutStr + " ملايين";
                break;
        }
        X = xx - (X * 1000000);
        if (X != 0)
        {
            OutStr = OutStr + " و";
        }
        this.Sixd();

    }

    protected void Sixd()
    {
        real xx;

        if (InputNo < 100000 || X < 100000)
        {
            this.Fived();
            return;
        }

        xx = X;
        X = real2int(X / 1000);
        this.Threed();
        OutStr = OutStr + " ألف";
        X = xx - (X * 1000);
        if (X != 0)
        {
            OutStr = OutStr + " و";
        }

        this.Threed();
    }

    str smallCurrency( str _smallCurrency = smallCurrency)
    {
        smallCurrency =  _smallCurrency;
        return smallCurrency;
    }

    protected void Teen()
    {
        if (InputNo < 10 || X < 10)
        {
            this.Oned();
            return;
        }
        switch (real2int(X))
        {
            case 10:
                OutStr = OutStr + " عشرة";
                break;
            case 11:
                OutStr = OutStr + " أحد عشر";
                break;
            case 12:
                OutStr = OutStr + " اثنى عشر";
                break;
            case 13:
                OutStr = OutStr + " ثلاث عشر";
                break;
            case 14:
                OutStr = OutStr + " أربعة عشر";
                break;
            case 15:
                OutStr = OutStr + " خمسة عشر";
                break;
            case 16:
                OutStr = OutStr + " ستة عشر";
                break;
            case 17:
                OutStr = OutStr + " سبعة عشر";
                break;
            case 18:
                OutStr = OutStr + " ثمانية عشر";
                break;
            case 19:
                OutStr = OutStr + " تسعة عشر";
                break;

        }
    }

    protected void Threed()
    {
        real xx;
        if (InputNo < 100 || X < 100)
        {
            this.Twod();
            return;
        }

        xx = X;
        if (X>=100 && X<=199)
                OutStr = OutStr + " مائة";
        else if (X>=200 && X<=299)
                OutStr = OutStr + " مائتان";
        else if (X >= 300 && X <= 399)
                OutStr = OutStr + " ثلاثمائة";
        else if (X >= 400 && X <= 499)
                OutStr = OutStr + " أربعمائة";
        else if (X >= 500 && X <= 599)
                OutStr = OutStr + " خمسمائة";
        else if (X >= 600 && X <= 699)
                OutStr = OutStr + " ستمائة";
        else if (X >= 700 && X <= 799)
                OutStr = OutStr + " سبعمائة";
        else if (X >= 800 && X <= 899)
                OutStr = OutStr + " ثمانمائة";
        else if (X >= 900 && X <= 999)
                OutStr = OutStr + " تسعمائة";

        X = X - (real2int(X / 100) * 100);
        if (X != 0)
        {
            OutStr = OutStr + " و";
        }
        this.Twod();
        X = xx;
    }

    protected void Twod()
    {
        real xx;
        if (InputNo < 20 || X < 20)
        {
            this.Teen();
            return;
        }

        xx = X;
        X = X - real2int(X / 10) * 10;
        if (this.Oned())
                OutStr = OutStr + " و";
        X = xx;
        if (X >= 20 && X <= 29)
                OutStr = OutStr + " عشرون ";
        else if (X >= 30 && X <= 39)
                OutStr = OutStr + " ثلاثون ";
        else if (X >= 40 && X <= 49)
                OutStr = OutStr + " أربعون ";
        else if (X >= 50 && X <= 59)
                OutStr = OutStr + " خمسون";
        else if (X >= 60 && X <= 69)
                OutStr = OutStr + " ستون";
        else if (X >= 70 && X <= 79)
                OutStr = OutStr + " سبعون";
        else if (X >= 80 && X <= 89)
                OutStr = OutStr + " ثمانون";
        else if (X >= 90 && X <= 99)
                OutStr = OutStr + " تسعون";
    }

    public str WordToNumAR(str Amount)
    {

        str des = subStr( Amount, strLen(Amount) - 1 , 2);
        str Taf1 = "";
        real tmpInputNo = InputNo;
        str Taf2 = "";


        InputNo = str2num(Amount);

        // Amount = InputNo.ToString("N2");

        if (InputNo >= 1)
        {
            X = real2int(InputNo);
            this.Nined();
            Taf1 = OutStr;
            Taf1 += bigCurrency;
        }

        OutStr = "";
        InputNo = str2num(des);
        if (InputNo > 0)
        {
            X = real2int(InputNo);
            this.Nined();
            if (tmpInputNo >= 0)
            Taf2 = " و ";
            Taf2 += OutStr;
            Taf2 += " " + smallCurrency;
        }

        X = 0;
        InputNo = 0;
        OutStr = "";

        return Taf1 + Taf2;
    }

}
[
SRSReportParameterAttribute(classStr(NW_PurchaseConfirmContract))
]
    
    class NW_PurchaseConfirmDP extends  SRSReportDataProviderBase
{
    NW_PurchaseConfirmTmp    _NW_PurchaseConfirmTmp;


    

    [SRSReportDataSetAttribute("NW_PurchaseConfirmTmp")]

    public NW_PurchaseConfirmTmp getNW_PurchaseConfirmTmp()
    {

        select * from _NW_PurchaseConfirmTmp;

        return _NW_PurchaseConfirmTmp;

    }

    public void processReport()

    {
      
        PurchId        PurId;
        PurchaseOrderId    JournID;
        VendPurchOrderJour  NW_VendPurchOrderJour ,_VendPurchOrderJour ;
        PurchLineAllVersions             NW_PurchLineAllVersions,_NW_PurchLineAllVersions;
        TmpTaxWorkTrans tmpTax;
        PurchTable purchTable;
        PurchTotals purchTotals;
        taxJournalTrans taxJournalTrans;
        InventLocation InventLocation;
        PurchLine PurchLine;
      
         WordToNumAR     _WordToNumAR;
        _WordToNumAR = new  WordToNumAR();

        NW_PurchaseConfirmContract datacontract  = this.parmDataContract();

        PurId         = datacontract.parmPurchId();
        JournID       = datacontract.parmPurchaseOrderId();

        select purchTable where purchTable.PurchId == PurId
            outer join InventLocation where purchTable.InventLocationId == InventLocation.InventLocationId
            outer join firstonly PurchLine where PurchLine.PurchId == purchTable.PurchId;

   
        select NW_VendPurchOrderJour where NW_VendPurchOrderJour.PurchId == PurId &&  NW_VendPurchOrderJour.PurchOrderDocNum == JournID;

        _NW_PurchaseConfirmTmp.clear();

        _NW_PurchaseConfirmTmp.NW_OrderedByName           = HcmWorker::find(NW_VendPurchOrderJour.purchTable().Requester).name();
        _NW_PurchaseConfirmTmp.NW_CompanyLogo           = FormLetter::companyLogo();

        _NW_PurchaseConfirmTmp.Warehouse = InventLocation.Name;
        _NW_PurchaseConfirmTmp.PurchReqId = PurchLine.PurchReqId;
         
        _NW_PurchaseConfirmTmp.NW_VendorName = VendTable::find(NW_VendPurchOrderJour.OrderAccount).name()
            + NW_VendPurchOrderJour.OrderAccount;
        _NW_PurchaseConfirmTmp.NW_VendorAddress = 
            DirParty::primaryPostalAddress(VendTable::find(NW_VendPurchOrderJour.OrderAccount).Party).Address;

        _NW_PurchaseConfirmTmp.NW_VendorTele =
            VendTable::find(NW_VendPurchOrderJour.OrderAccount).telefax();
        
        _NW_PurchaseConfirmTmp.NW_VendorTele =
            VendTable::find(NW_VendPurchOrderJour.OrderAccount).phone();
        _NW_PurchaseConfirmTmp.NW_Po                = NW_VendPurchOrderJour.PurchId;
        _NW_PurchaseConfirmTmp.NW_PoDate            = NW_VendPurchOrderJour.PurchOrderDate;

        _NW_PurchaseConfirmTmp.NW_DeliveryAddress   = LogisticsLocation::find(purchTable.deliveryLocation()).Description;// PurchTable::find(NW_VendPurchOrderJour.PurchId).deliveryAddressing();
        _NW_PurchaseConfirmTmp.NW_DeliveryDate            =  PurchTable::find(NW_VendPurchOrderJour.PurchId).DeliveryDate;
        _NW_PurchaseConfirmTmp.NW_Currency         = NW_VendPurchOrderJour.purchTable().CurrencyCode;
        _NW_PurchaseConfirmTmp.NW_Amount           = NW_VendPurchOrderJour.Amount;

        if(NW_VendPurchOrderJour.purchTable().CurrencyCode =="SAR")
        {
            _WordToNumAR.bigCurrency(" ريـال سعودي");
            _WordToNumAR.smallCurrency(" هلله");

        }
        if(NW_VendPurchOrderJour.Amount<0)
        {
            _NW_PurchaseConfirmTmp.NW_AmountArabic =   _WordToNumAR.WordToNumAR(num2str((NW_VendPurchOrderJour.Amount*-1),0,2,1,0)) + " فقط لاغير ";

            _NW_PurchaseConfirmTmp.NW_AmountEng=  numeralsToTxt_EN(NW_VendPurchOrderJour.Amount*-1);

            _NW_PurchaseConfirmTmp.NW_VatAmountArabic =   _WordToNumAR.WordToNumAR(num2str(( NW_VendPurchOrderJour.SumTax*-1),0,2,1,0)) + " فقط لاغير ";

            _NW_PurchaseConfirmTmp.NW_VatAmountEng =  numeralsToTxt_EN(NW_VendPurchOrderJour.SumTax*-1);
        }
        else
        {
            _NW_PurchaseConfirmTmp.NW_AmountArabic =   _WordToNumAR.WordToNumAR(num2str((NW_VendPurchOrderJour.Amount),0,2,1,0)) + " فقط لاغير ";

            _NW_PurchaseConfirmTmp.NW_AmountEng=  numeralsToTxt_EN(NW_VendPurchOrderJour.Amount);

            _NW_PurchaseConfirmTmp.NW_VatAmountArabic =   _WordToNumAR.WordToNumAR(num2str(( NW_VendPurchOrderJour.SumTax),0,2,1,0)) + " فقط لاغير ";

            _NW_PurchaseConfirmTmp.NW_VatAmountEng =  numeralsToTxt_EN(NW_VendPurchOrderJour.SumTax);
        }
        _NW_PurchaseConfirmTmp.NW_DeliveryTerms = DlvTerm::find(NW_VendPurchOrderJour.purchTable().DlvTerm).Txt;
        _NW_PurchaseConfirmTmp.NW_PaymentTerms = PaymTerm::find(NW_VendPurchOrderJour.purchTable().Payment).Description;

        while select NW_PurchLineAllVersions  where NW_PurchLineAllVersions.PurchTableVersionRecId == NW_VendPurchOrderJour.PurchTableVersion
        {
            
       

            _NW_PurchaseConfirmTmp.NW_ItemName        =  NW_PurchLineAllVersions.Name;
            _NW_PurchaseConfirmTmp.NW_ItemId          =  NW_PurchLineAllVersions.ItemId;
            _NW_PurchaseConfirmTmp.NW_Qty             =  NW_PurchLineAllVersions.PurchQty;
            _NW_PurchaseConfirmTmp.NW_Price           =  NW_PurchLineAllVersions.PurchPrice;
            _NW_PurchaseConfirmTmp.NW_Unit            =  NW_PurchLineAllVersions.PurchUnit;

            
          /*  purchTable = PurchTable::find(NW_PurchLineAllVersions.PurchId);
            purchTotals = purchTotals::newPurchTable(purchTable);
            purchTotals.calc();
            tmpTax.setTmpData(purchTotals.tax().tmpTaxWorkTrans());
            _NW_PurchaseConfirmTmp.NW_VatRatio =  tmpTax.TaxCode;
            _NW_PurchaseConfirmTmp.NW_LineAmountIncVat      =  (NW_PurchLineAllVersions.LineAmount + tmpTax.TaxAmount)- NW_PurchLineAllVersions.LineDisc;;*/
         
            select sum(SourceRegulateAmountCur) from taxJournalTrans
        where taxJournalTrans.TransRecId    == NW_PurchLineAllVersions.RECID
            && taxJournalTrans.TransTableId  == tableNum(PurchLineAllVersions);
            _NW_PurchaseConfirmTmp.NW_VatAmount =  taxJournalTrans.SourceRegulateAmountCur;
            _NW_PurchaseConfirmTmp.NW_LineAmountIncVat =   _NW_PurchaseConfirmTmp.NW_VatAmount +
                NW_PurchLineAllVersions.LineAmount;
           
            _NW_PurchaseConfirmTmp.insert();
        }
        
    }

}
Test automation code involves creating test cases, handling different locators, interacting with various elements, and implementing assertions to validate expected outcomes. I am sharing a general example using Python with the popular testing framework, Selenium, for web automation.

from selenium import webdriver
from selenium.webdriver.common.by import By

# Set up the WebDriver (assuming Chrome for this example)
driver = webdriver.Chrome(executable_path='path/to/chromedriver.exe')

# Navigate to a website
driver.get('https://www.example.com')

# Find an element using its ID and perform an action (e.g., click)
element = driver.find_element(By.ID, 'example-button')
element.click()

# Perform an assertion to verify the expected result
assert "Example Domain" in driver.title

# Close the browser window
driver.quit()

import 'package:flutter/material.dart';

class Home extends StatefulWidget {
  const Home({Key? key}) : super(key: key);

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  int currentPageIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Page Slider'),
      ),
      body: PageView.builder(
        itemCount: 3, // عدد الصفحات
        onPageChanged: (index) {
          setState(() {
            currentPageIndex = index;
          });
        },
        itemBuilder: (BuildContext context, int index) {
          return Center(
            child: Text(
              'Page ${index + 1}',
              style: TextStyle(fontSize: 24.0),
            ),
          );
        },
      ),

    );
  }
}
 public void init()
    {

        #SysSystemDefinedButtons
        formCommandButtonControl delb,newb;
        FormRun _formRun = this as FormRun;
        this.form().design().ViewEditMode(1);
               next init();
        delb = this.control(this.controlId(#SystemDefinedDeleteButton)) as formCommandButtonControl;
        newb = this.control(this.controlId(#SystemDefinedNewButton)) as formCommandButtonControl;
      
        newb.visible(false);
        delb.visible(false);
    }
star

Thu Feb 22 2024 00:20:16 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Thu Feb 22 2024 00:16:48 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Thu Feb 22 2024 00:10:17 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 23:53:09 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 23:49:49 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 19:07:50 GMT+0000 (Coordinated Universal Time) https://chat.openai.com/

@eziokittu

star

Wed Feb 21 2024 17:56:41 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 17:49:54 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 17:48:33 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 17:46:12 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 17:16:57 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 17:14:51 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 17:03:41 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 17:02:02 GMT+0000 (Coordinated Universal Time)

@tchives #javascript

star

Wed Feb 21 2024 16:09:03 GMT+0000 (Coordinated Universal Time)

@papi292 #c++ #makefile #make

star

Wed Feb 21 2024 14:46:58 GMT+0000 (Coordinated Universal Time)

@tchives #formula

star

Wed Feb 21 2024 14:46:33 GMT+0000 (Coordinated Universal Time)

@tchives #formula

star

Wed Feb 21 2024 14:45:39 GMT+0000 (Coordinated Universal Time)

@tchives #formula

star

Wed Feb 21 2024 14:44:09 GMT+0000 (Coordinated Universal Time)

@tchives #formula

star

Wed Feb 21 2024 14:43:21 GMT+0000 (Coordinated Universal Time)

@tchives #formula

star

Wed Feb 21 2024 14:42:31 GMT+0000 (Coordinated Universal Time)

@tchives #formula

star

Wed Feb 21 2024 14:41:06 GMT+0000 (Coordinated Universal Time)

@tchives #formula

star

Wed Feb 21 2024 10:16:04 GMT+0000 (Coordinated Universal Time)

@Shira

star

Wed Feb 21 2024 09:39:44 GMT+0000 (Coordinated Universal Time)

@dsce

star

Wed Feb 21 2024 09:25:30 GMT+0000 (Coordinated Universal Time)

@sentgine #javascript #date

star

Wed Feb 21 2024 09:06:57 GMT+0000 (Coordinated Universal Time)

@dsce

star

Wed Feb 21 2024 08:50:20 GMT+0000 (Coordinated Universal Time)

@dsce

star

Wed Feb 21 2024 08:49:55 GMT+0000 (Coordinated Universal Time)

@dsce

star

Wed Feb 21 2024 08:48:31 GMT+0000 (Coordinated Universal Time)

@dsce

star

Wed Feb 21 2024 08:41:44 GMT+0000 (Coordinated Universal Time)

@iliavial #c#

star

Wed Feb 21 2024 07:55:51 GMT+0000 (Coordinated Universal Time)

@sentgine #blade #php #laravel #html #livewire #alpinejs

star

Wed Feb 21 2024 05:40:07 GMT+0000 (Coordinated Universal Time) https://www.elegantthemes.com/blog/divi-resources/beautiful-css-hover-effects-you-can-add-to-your-divi-menus

@vidas

star

Wed Feb 21 2024 05:21:17 GMT+0000 (Coordinated Universal Time) https://tripleten.com/trainer/web/lesson/a2c0f955-8374-4357-a7bf-e3e4c1ba4a36/

@Marcelluki

star

Tue Feb 20 2024 22:23:58 GMT+0000 (Coordinated Universal Time)

@RahmanM

star

Tue Feb 20 2024 12:01:43 GMT+0000 (Coordinated Universal Time)

@StefanoGi

star

Tue Feb 20 2024 08:50:31 GMT+0000 (Coordinated Universal Time)

@StefanoGi

star

Tue Feb 20 2024 05:55:17 GMT+0000 (Coordinated Universal Time)

@CodeWithSachin ##jupyter #aggregation

star

Mon Feb 19 2024 17:30:07 GMT+0000 (Coordinated Universal Time) youtube.com/watch?v=8LmLwdhh5wA

@wizyOsva #linux #vm #virt-manager

star

Mon Feb 19 2024 16:23:28 GMT+0000 (Coordinated Universal Time)

@sinasina1368 #c++

star

Mon Feb 19 2024 13:22:36 GMT+0000 (Coordinated Universal Time)

@Roytegz

star

Mon Feb 19 2024 12:18:25 GMT+0000 (Coordinated Universal Time)

@Ashu@1208

star

Mon Feb 19 2024 10:45:23 GMT+0000 (Coordinated Universal Time)

@MinaTimo

star

Mon Feb 19 2024 10:44:11 GMT+0000 (Coordinated Universal Time)

@MinaTimo

star

Mon Feb 19 2024 08:45:55 GMT+0000 (Coordinated Universal Time) https://thinkpalm.com/services/test-automation-services/

@Athi #python

star

Mon Feb 19 2024 02:20:56 GMT+0000 (Coordinated Universal Time) https://pastes.io/gotienbj8a

@uae_n1

star

Sun Feb 18 2024 20:31:49 GMT+0000 (Coordinated Universal Time) https://chat.openai.com/

@mebean

star

Sun Feb 18 2024 18:33:11 GMT+0000 (Coordinated Universal Time) https://www.linuxcapable.com/how-to-install-budgie-desktop-on-debian-linux/

@Billzyboi #bash

star

Sun Feb 18 2024 18:32:33 GMT+0000 (Coordinated Universal Time) https://www.linuxcapable.com/how-to-install-budgie-desktop-on-debian-linux/

@Billzyboi #bash

star

Sun Feb 18 2024 16:42:51 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-us/windows/wsl/install?source

@Mad_Hatter

star

Sun Feb 18 2024 13:27:47 GMT+0000 (Coordinated Universal Time)

@MinaTimo

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension