lebohangmaphothoane
Member
so can u help me with any material or code of making interfaces
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Summary description for turn
*
*/
public class turn extends JFrame
{
// Variables declaration
private JButton jButton1;
private JButton jButton2;
private JPanel contentPane;
// End of variables declaration
public turn()
{
super();
initializeComponent();
//
// TODO: Add any constructor code after initializeComponent call
//
this.setVisible(true);
}
private void initializeComponent()
{
jButton1 = new JButton();
jButton2 = new JButton();
contentPane = (JPanel)this.getContentPane();
//
// jButton1
//
jButton1.setText("clockwise");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
//
// jButton2
//
jButton2.setText("anticlockwise");
jButton2.setMaximumSize(new Dimension(151, 25));
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton2_actionPerformed(e);
}
});
//
// contentPane
//
contentPane.setLayout(null);
addComponent(contentPane, jButton1, 26,32,83,28);
addComponent(contentPane, jButton2, 194,38,108,28);
//
// turn
//
this.setTitle("turn - extends JFrame");
this.setLocation(new Point(76, 59));
this.setSize(new Dimension(390, 300));
}
/** Add Component Without a Layout Manager (Absolute Positioning) */
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
//
// TODO: Add any appropriate code in the following Event Handling Methods
//
private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jButton2_actionPerformed(ActionEvent e)
{
System.out.println("\njButton2_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
;
}
new turn();
}
}
private void jButton1_actionPerformed(ActionEvent e)
{
}
private void jButton2_actionPerformed(ActionEvent e)
{
}
;Author : LEBOHANG MAPHOTHOANE
;PROGRAM FUNCTION:turning motor
list P=16F877a
include "P16F877a.inc"
__config 0x3D18
;errorlevel -302, -207;suppress message 302 from the list
;Declarations:
CBLOCK 20h ; Temporary storage
dc1 ; General purpose registers for delay
dc2 ;General purpose registers for storing received data
ENDC
org 0x0000
goto Init
;Subroutines:
Init
clrw ; Zero.
movwf PORTB ; Ensure PORTB is zero before we enable it.
bsf STATUS,RP0 ; Select Bank 1
movlw 0xF0 ; Set port B bits 0-3 as outputs
movwf TRISB ; Set TRISB register.
;*** UART Set Up ***
MOVLW 0x19 ; 0x19 = 9600 BPS (0x0C = 19200 BPS)
MOVWF SPBRG ; Baud Rate Generator Store Location
BSF TXSTA,BRGH ; High Baud Rate Select bit
BCF STATUS,RP0 ; Bank 0
BSF RCSTA,SPEN ; Serial Port Enable bit
BSF RCSTA,CREN ; Continuous Receive Enable bit
Main
;*** Receive ***
Receive:
BTFSS PIR1,RCIF ; P1R1 is set when byte is recieved
GOTO Receive ;
MOVF RCREG,W ; Move received data into W
movwf dc2 ; move data from the working register into general purpose register
btfss dc2,1 ;check if the second bit is 1 and if it is 1 the data received is letter A(1010)
goto clockwise ; if not the letter is C(1100)
goto anticockwise
clockwise
;1-----------------------
movlw b'1000'
movwf PORTB
call wait
goto Main
anticockwise
movlw b'0100'
movwf PORTB
call wait
goto Main
wait movlw 40 ; Outer loop iteration count
d11 movwf dc1
decfsz dc1,F
goto $-1
return
end