VB.Net - Make A DropDown Menu

How To Make A Drop And Down Menu Using Visual Basic.Net

dropdown menu in vbnet


In This VB.Net Tutorial  We Will See How To Create A Drop-Down Menu Using Panels, Buttons, And Timers In Visual Basic.Net Programming Language.


Project Source Code:

Public Class drop_down_menu

    ' pl1 = panel1 height
    Dim pl1 As Integer = 60

    ' pl2 = panel2 height
    Dim pl2 As Integer = 60

    ' pl3 = panel3 height
    Dim pl3 As Integer = 60

    Private Sub drop_down_menu_Load(sender As Object, e As EventArgs) Handles MyBase.Load


    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        ' 250 = panel height
        If pl1 > 240 Then

            Timer1.Stop()

        Else
            Me.Panel1.Size = New Size(Me.Panel1.Size.Width, pl1)
            pl1 += 10
        End If

    End Sub

    Private Sub Button1_MouseHover(sender As Object, e As EventArgs) Handles Button1.MouseHover

        ' on button1 mouse hover set panel2 and panel3 to the default height (60) 
        Me.Panel2.Size = New Size(Me.Panel2.Size.Width, pl2)
        Me.Panel3.Size = New Size(Me.Panel3.Size.Width, pl3)
        Timer1.Start()

    End Sub

    Private Sub Button1_MouseLeave(sender As Object, e As EventArgs) Handles Button1.MouseLeave

        Timer1.Stop()
        pl1 = 60

    End Sub

    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick

        If pl2 > 240 Then

            Timer2.Stop()

        Else
            Me.Panel2.Size = New Size(Me.Panel2.Size.Width, pl2)
            pl2 += 10
        End If

    End Sub

    Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick

        If pl3 > 240 Then

            Timer3.Stop()

        Else
            Me.Panel3.Size = New Size(Me.Panel3.Size.Width, pl3)
            pl3 += 10
        End If

    End Sub

    Private Sub Button8_MouseHover(sender As Object, e As EventArgs) Handles Button8.MouseHover

        ' on button8 mouse hover set panel1 and panel3 to the default height (60) 
        Me.Panel1.Size = New Size(Me.Panel1.Size.Width, pl1)
        Me.Panel3.Size = New Size(Me.Panel3.Size.Width, pl3)
        Timer2.Start()

    End Sub

    Private Sub Button8_MouseLeave(sender As Object, e As EventArgs) Handles Button8.MouseLeave

        Timer2.Stop()
        pl2 = 60

    End Sub

    Private Sub Button12_MouseHover(sender As Object, e As EventArgs) Handles Button12.MouseHover

        ' on button12 mouse hover set panel2 and panel1 to the default height (60) 
        Me.Panel2.Size = New Size(Me.Panel2.Size.Width, pl2)
        Me.Panel1.Size = New Size(Me.Panel1.Size.Width, pl1)
        Timer3.Start()

    End Sub

    Private Sub Button12_MouseLeave(sender As Object, e As EventArgs) Handles Button12.MouseLeave

        Timer3.Stop()
        pl3 = 60

    End Sub
End Class


//OutPut:

vb.net drop-down menu

Java - Move JList Item Up And Down

How To Move Selected JList Item Up N Down In Java NetBeans

java jlist item up n down



In this Java Tutorial we will see How To Make Two Buttons To Move Selected List Item Up Or Down On Click In Java Using NetBeans .




Project Source Code:

        // populate jlist using string array and for loop
        DefaultListModel model = new DefaultListModel();
        jList1.setModel(model);
        
        String[] JlistItems = {"A1","A2","A3","A4","A5","A6","A7","A8","A9","A10","A11"};
        for(int i = 0; i < JlistItems.length; i++)
        {
            model.add(i, JlistItems[i]);
        }

// button to move selected jlist item up
private void jButton_UPActionPerformed(java.awt.event.ActionEvent evt) {                                           
        String selectedItem = jList1.getSelectedValue();//get item value
        int itemIndex = jList1.getSelectedIndex();// get item index
        DefaultListModel model = (DefaultListModel)jList1.getModel();// get list model
        
        if(itemIndex > 0){
            model.remove(itemIndex);// remove selected item from the list
            model.add(itemIndex - 1, selectedItem);// add the item to a new position in the list
            jList1.setSelectedIndex(itemIndex - 1);// set selection to the new item
        }   
    }        


// button to move selected jlist item down
private void jButton_DownActionPerformed(java.awt.event.ActionEvent evt) {                                             
        String selectedItem = jList1.getSelectedValue();
        int itemIndex = jList1.getSelectedIndex();
        DefaultListModel model = (DefaultListModel)jList1.getModel();
        
        if( itemIndex < model.getSize() -1 ){
            model.remove(itemIndex);
            model.add(itemIndex + 1, selectedItem);
            jList1.setSelectedIndex(itemIndex + 1);
        }
    } 

// OUTPUT :

java move selected jlist item up and down

Java - Drop Down Menu

How To Make A Drop And Down Menu In Java Eclipse

Java Drop-Down Menu



In this Java Tutorial we will see How To Make A Drop N Down Menu Using Panel Buttons And Timer In Java Using Eclipse .




Project Source Code:

package p;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class drop_down_menu extends JFrame {

private JPanel contentPane;
Timer tm1,tm2,tm3;
// the panels default height = 60
    Integer pl1 = 60,pl2 = 60,pl3 = 60;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
drop_down_menu frame = new drop_down_menu();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public drop_down_menu() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 550, 435);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JPanel panel = new JPanel();
panel.setBounds(376, 11, 148, 60);
contentPane.add(panel);
panel.setLayout(null);
JButton btnNewButton = new JButton("New button");
btnNewButton.setBackground(Color.ORANGE);
btnNewButton.setBounds(0, 0, 148, 60);
panel.add(btnNewButton);
JButton button = new JButton("New button");
button.setBackground(Color.ORANGE);
button.setBounds(0, 61, 148, 60);
panel.add(button);
JButton button_1 = new JButton("New button");
button_1.setBackground(Color.ORANGE);
button_1.setBounds(0, 122, 148, 60);
panel.add(button_1);
JButton button_2 = new JButton("New button");
button_2.setBackground(Color.ORANGE);
button_2.setBounds(0, 183, 148, 60);
panel.add(button_2);
JButton button_3 = new JButton("New button");
button_3.setBackground(Color.ORANGE);
button_3.setBounds(0, 243, 148, 60);
panel.add(button_3);
JPanel panel_1 = new JPanel();
panel_1.setLayout(null);
panel_1.setBounds(211, 11, 148, 60);
contentPane.add(panel_1);
JButton button_4 = new JButton("New button");
button_4.setBackground(Color.ORANGE);
button_4.setBounds(0, 0, 148, 60);
panel_1.add(button_4);
JButton button_5 = new JButton("New button");
button_5.setBackground(Color.ORANGE);
button_5.setBounds(0, 61, 148, 60);
panel_1.add(button_5);
JButton button_6 = new JButton("New button");
button_6.setBackground(Color.ORANGE);
button_6.setBounds(0, 122, 148, 60);
panel_1.add(button_6);
JButton button_7 = new JButton("New button");
button_7.setBackground(Color.ORANGE);
button_7.setBounds(0, 183, 148, 60);
panel_1.add(button_7);
JButton button_8 = new JButton("New button");
button_8.setBackground(Color.ORANGE);
button_8.setBounds(0, 243, 148, 60);
panel_1.add(button_8);
JPanel panel_2 = new JPanel();
panel_2.setLayout(null);
panel_2.setBounds(42, 11, 148, 60);
contentPane.add(panel_2);
JButton button_9 = new JButton("New button");
button_9.setBackground(Color.ORANGE);
button_9.setBounds(0, 0, 148, 60);
panel_2.add(button_9);
JButton button_10 = new JButton("New button");
button_10.setBackground(Color.ORANGE);
button_10.setBounds(0, 61, 148, 60);
panel_2.add(button_10);
JButton button_11 = new JButton("New button");
button_11.setBackground(Color.ORANGE);
button_11.setBounds(0, 122, 148, 60);
panel_2.add(button_11);
JButton button_12 = new JButton("New button");
button_12.setBackground(Color.ORANGE);
button_12.setBounds(0, 183, 148, 60);
panel_2.add(button_12);
JButton button_13 = new JButton("New button");
button_13.setBackground(Color.ORANGE);
button_13.setBounds(0, 243, 148, 60);
panel_2.add(button_13);
tm1 = new Timer(20, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// 300 the maximum height
if(pl1 > 300)
{
tm1.stop();
}
else{
panel.setSize(panel.getWidth(),pl1);
pl1 += 20;
}
}
});
      tm2 = new Timer(20, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(pl2 > 300)
{
tm2.stop();
}
else{
panel_1.setSize(panel_1.getWidth(),pl2);
pl2 += 20;
}
}
});
      
      tm3 = new Timer(20, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(pl3 > 300)
{
tm3.stop();
}
else{
panel_2.setSize(panel_2.getWidth(),pl3);
pl3 += 20;
}
}
});
btnNewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent arg0) {
// set the panels to the dafault height
panel_1.setSize(panel_1.getWidth(), pl2);
panel_2.setSize(panel_2.getWidth(), pl3);
tm1.start();
}
@Override
public void mouseExited(MouseEvent e) {
tm1.stop();
pl1 = 60;
}
});
button_4.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent arg0) {
panel.setSize(panel.getWidth(), pl1);
panel_2.setSize(panel_2.getWidth(), pl3);
tm2.start();
}
@Override
public void mouseExited(MouseEvent e) {
tm2.stop();
pl2 = 60;
}
});
button_9.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
panel_1.setSize(panel_1.getWidth(), pl2);
panel.setSize(panel.getWidth(), pl1);
tm3.start();
}
@Override
public void mouseExited(MouseEvent e) {
tm3.stop();
pl3 = 60;
}
});
}
}

// OUTPUT :


java dropdown menu in eclipse ide

Javascript Move Row Up And Down

How To Move Selected HTML Table Row Up And Down In Javascript  

Move Table Row Up & Down In Javascript


In This Javascript Tutorial we will See How To Change Selected HTML Table Row Position Up Or Down On Button Click using JS And Netbeans Editor .


Project Source Code:


<!DOCTYPE html>
<html>
    <head>
        <title>HTML Table Row Up And Down</title>
        <meta charset="windows-1252">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style>
            
            tr{cursor: pointer}
            
            .selected{background-color: red; color: #fff;font-weight: bold}
            
            button{margin-top:10px;background-color: #eee;border: 2px solid #00F;
                  color: #17bb1c;font-weight: bold;font-size: 25px;cursor: pointer}
            
        </style>
    </head>
    <body>
        <table id="table" border="1">
            <tr>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Age</th>
            </tr>
            <tr>
                <td>A1</td>
                <td>B1</td>
                <td>C1</td>
            </tr>
            <tr>
                <td>A2</td>
                <td>B2</td>
                <td>C2</td>
            </tr>
            <tr>
                <td>A3</td>
                <td>B3</td>
                <td>C3</td>
            </tr>
            <tr>
                <td>A4</td>
                <td>B4</td>
                <td>C4</td>
            </tr>
            <tr>
                <td>A5</td>
                <td>B5</td>
                <td>C5</td>
            </tr>
        </table>
        <button onclick="upNdown('up');">&ShortUpArrow;</button>
        <button onclick="upNdown('down');">&ShortDownArrow;</button>
        
        <script>
            
            var index;  // variable to set the selected row index
            function getSelectedRow()
            {
                var table = document.getElementById("table");
                for(var i = 1; i < table.rows.length; i++)
                {
                    table.rows[i].onclick = function()
                    {
                        // clear the selected from the previous selected row
                        // the first time index is undefined
                        if(typeof index !== "undefined"){
                            table.rows[index].classList.toggle("selected");
                        }
                       
                        index = this.rowIndex;
                        this.classList.toggle("selected");

                    };
                }
                    
            }
  

            getSelectedRow();
            
            
            function upNdown(direction)
            {
                var rows = document.getElementById("table").rows,
                    parent = rows[index].parentNode;
                 if(direction === "up")
                 {
                     if(index > 1){
                        parent.insertBefore(rows[index],rows[index - 1]);
                        // when the row go up the index will be equal to index - 1
                        index--;
                    }
                 }
                 
                 if(direction === "down")
                 {
                     if(index < rows.length -1){
                        parent.insertBefore(rows[index + 1],rows[index]);
                        // when the row go down the index will be equal to index + 1
                        index++;
                    }
                 }
            }
            
        </script>
    </body>
</html>



OUTPUT:


moving selected html table row up & down in javascript

Best Javascript Courses On Udemy

Top Javascript Courses

Best Javascript Courses On Udemy


You Will Learn:
  • Lifetime access to my HD quality videos. No monthly subscription. Learn at your own pace, whenever you want.
  • You will gain a deep and true understanding of how JavaScript works behind the scenes.
  • You will understand and use complex features like the 'this' keyword, function constructors, prototypal inheritance, first-class functions, closures, and more.
  • You will learn how to organize and structure your code using modules and functions. Because coding is not just writing code, it's also thinking about your code!
  • You will get my personal support in the Q&A.
  • Multiple coding challenges to practice your new skills (solutions included).
  • You will go all the way from JavaScript beginner to advanced JavaScript developer.
  • You will be able to debug your code and understand other developer's code.
  • You will code two beautiful real-world apps (starter code included) and not just boring toy apps.
  • You will become familiar with the new features of ES6 / ES2015.
  • Downloadable starter code and final code for each section.
  • A final course exam with 30 questions to truly test your JavaScript knowledge.
Instructor: Jonas Schmedtmann
Social Proof: 18,664 students - rating 4.7

Review Example:



  • Grasp how Javascript works and it's fundamental concepts
  • Understand advanced concepts such as closures, prototypal inheritance, IIFEs, and much more.
  • Avoid common pitfalls and mistakes other Javascript coders make
  • Build your own Javascript framework or library
  • Write solid, good Javascript code
  • Drastically improve your ability to debug problems in Javascript.
  • Understand the source code of popular Javascript frameworks
Instructor: Anthony Alicea
Social Proof: 71,350 students - rating 4.7

Review Example: