Java - Horizontal Menu Design

How To Design Horizontal Menu In Java Using NetBeans

Java - Horizontal Menu Design





In this Java Tutorial we will see How To Design A Horizontal Menu In Java NetBeans .

In This Java Swing Design Tutorial We Will Use:
- Java Programming Language.
- Netbeans IDE.



Project Description And Source Code:

    // create border
    Border default_border = BorderFactory.createMatteBorder(0, 0, 3, 0, new Color(153,153,153));
    Border red_border = BorderFactory.createMatteBorder(0, 0, 3, 0, Color.red);
    
    // create an array of jbuttons
    JButton[] buttons;

// the form constructor
    public horizontal_menu() {
        initComponents();
        
        // center the form
        this.setLocationRelativeTo(null);
        
        // add buttons to the array
        buttons = new JButton[5];
        buttons[0] = jButton1;
        buttons[1] = jButton2;
        buttons[2] = jButton3;
        buttons[3] = jButton4;
        buttons[4] = jButton5;
        
        // add the desfault border to the jbuttons
        for (JButton button : buttons) {
            button.setBorder(default_border);
        }
        
        // call the function to create mouse click event
        addAction();

    }


    // create a function to add a mouseClick event to all buttons
    public void addAction()
    {
        for(JButton button : buttons)
        {
            button.addMouseListener(new MouseListener() {
                @Override
                public void mouseClicked(MouseEvent e) {
                
                    setButtonBorder(button);
                    
                }

                @Override
                public void mousePressed(MouseEvent e) {}

                @Override
                public void mouseReleased(MouseEvent e) {}

                @Override
                public void mouseEntered(MouseEvent e) {}

                @Override
                public void mouseExited(MouseEvent e) {}
            });
        }
    }
    
    
    // create a unction to set border to the selected menu item
    public void setButtonBorder(JButton button)
    {
        // reset all buttons to the default border and forground color
        for (JButton btn : buttons) {
            
            btn.setBorder(default_border);
            btn.setForeground(new Color(153,153,153));
            
        }
        
        // red border for the selected item
        button.setBorder(red_border);
        button.setForeground(Color.black);
    }
    
// button close
    private void jButton_CloseActionPerformed(java.awt.event.ActionEvent evt) {                                           
        this.dispose();
        
    } 



VB.Net - Login And Register Form Design


How To Design a Login And Register Form In VB.Net

How To Design a Login And Register Form In VB.Net



in this visual basic .net form design tutorial we will see how to design a login and register form in one  windowForm using vb.net programming language .

tools:
- visual basic .net programming language.
- microsoft visual studio express 2013.
- iconsdb.com ( to get the close icon).
- canva.com ( to create the app logo ).
- flatuicolorpicker.com ( for color ideas ).

Watch The Full Tutorial



- The Project Source Code

we will add two buttons and two panels to the form, inside the panels we will add the textboxes and buttons to login and register, and the two buttons will help us to go between the two panels.


Login Form Design


Register Form Design


Public Class Login_Register_Form

    ' display the login panel
    Private Sub ButtonGoToLogin_Click(sender As Object, e As EventArgs) Handles ButtonGoToLogin.Click

        Panel_Login.BringToFront()

        ButtonGoToLogin.BackColor = Color.FromArgb(34, 167, 240)
        ButtonGoToLogin.Font = New Font("Microsoft Sans Serif", 28)
        ButtonGoToLogin.ForeColor = Color.White
        Panel_LoginBar.BackColor = Color.Yellow

        ButtonGoToRegister.BackColor = Color.White
        ButtonGoToRegister.ForeColor = Color.Black
        ButtonGoToRegister.Font = New Font("Microsoft Sans Serif", 20)
        Panel_RegisterBar.BackColor = Color.FromArgb(34, 167, 240)

    End Sub

    ' display the register panel
    Private Sub ButtonGoToRegister_Click(sender As Object, e As EventArgs) Handles ButtonGoToRegister.Click

        Panel_Register.BringToFront()

        ButtonGoToRegister.BackColor = Color.FromArgb(34, 167, 240)
        ButtonGoToRegister.Font = New Font("Microsoft Sans Serif", 28)
        ButtonGoToRegister.ForeColor = Color.White
        Panel_RegisterBar.BackColor = Color.Yellow

        ButtonGoToLogin.BackColor = Color.White
        ButtonGoToLogin.ForeColor = Color.Black
        ButtonGoToLogin.Font = New Font("Microsoft Sans Serif", 20)
        Panel_LoginBar.BackColor = Color.FromArgb(34, 167, 240)

    End Sub

    ' close the form
    Private Sub PictureBox_Close_Click(sender As Object, e As EventArgs) Handles PictureBox_Close.Click

        Me.Close()

    End Sub

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

        ButtonGoToLogin.PerformClick()

    End Sub
End Class