Olá amigos,
estou precisando de uma ajudinha pra colocar num jframe do netbeans uma hora e data…
vou postar o codigo fonte anexado estou com muitos erros…
NetBeans
/*
* Principal.java
*
* Created on 4 de Maio de 2007, 00:30
*/
package sistema;
/**
*
* @author LV Consultoria
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Principal extends javax.swing.JFrame {
/** Creates new form Principal */
public Principal() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
jPopupMenu1 = new javax.swing.JPopupMenu();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
X = new javax.swing.JButton();
R = new javax.swing.JButton();
Start = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("SISLV - Sistema de Informa\u00e7\u00e3o LV Consultoria.");
setBounds(new java.awt.Rectangle(100, 80, 50, 70));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setMinimumSize(new java.awt.Dimension(800, 600));
setResizable(false);
addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
formKeyTyped(evt);
}
});
jLabel1.setFont(new java.awt.Font("Bitstream Vera Sans Mono", 0, 14));
jLabel1.setForeground(new java.awt.Color(0, 153, 0));
jLabel1.setText("SISLV - Sistema de Informa\u00e7\u00e3o LV Consultoria");
jLabel2.setFont(new java.awt.Font("Bitstream Vera Sans Mono", 0, 10));
jLabel2.setForeground(new java.awt.Color(0, 153, 0));
jLabel2.setText("Uma empresa LV Consultoria");
X.setText("X");
X.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
XActionPerformed(evt);
}
});
R.setText("R");
R.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RActionPerformed(evt);
}
});
Start.setBackground(new java.awt.Color(204, 255, 204));
Start.setText("Start");
Start.setBorder(javax.swing.BorderFactory.createEtchedBorder());
Start.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
StartActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(R)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 268, Short.MAX_VALUE)
.add(jLabel2))
.add(Start, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(X)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 72, Short.MAX_VALUE)
.add(jLabel1)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel2))
.add(layout.createSequentialGroup()
.add(X)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(R)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 296, Short.MAX_VALUE)
.add(Start))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void RActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RActionPerformed
// TODO add your handling code here:
RecrasUso recras = new RecrasUso();
recras.setVisible(true);
}//GEN-LAST:event_RActionPerformed
private void XActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_XActionPerformed
// Botao Topo Sair X
System.exit(0);
}//GEN-LAST:event_XActionPerformed
private void formKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyTyped
// TODO add your handling code here:
}//GEN-LAST:event_formKeyTyped
private void StartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StartActionPerformed
// Botao Start
sislv sistema = new sislv();
sistema.setVisible(true);
}//GEN-LAST:event_StartActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Principal().setVisible(true);
}
});
sislv sis = new sislv();
sis.sislv();
}
void Principal() {
throw new UnsupportedOperationException("Not yet implemented");
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton R;
private javax.swing.JButton Start;
private javax.swing.JButton X;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPopupMenu jPopupMenu1;
// End of variables declaration//GEN-END:variables
}
Relogio
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
class Relogio extends JFrame implements ActionListener {
private javax.swing.Timer timer;
private Date data;
private JLabel label;
private JFrame frame;
public Relogio() {
super("Relógio");
label = new JLabel();
label.setFont(new Font("Tahoma", Font.BOLD, 22));
JPanel panel = new JPanel();
panel.add(label);
Container c = getContentPane();
FlowLayout layout = new FlowLayout();
layout.setAlignment(FlowLayout.CENTER);
c.setLayout(layout);
c.add(panel);
// setResizable(false);
setBounds(250, 200, 150, 80);
show();
disparaRelogio();
}
public void disparaRelogio() {
if (timer == null) {
timer = new javax.swing.Timer(1000, this);
timer.setInitialDelay(0);
timer.start();
} else if (!timer.isRunning()) {
timer.restart();
}
}
public void actionPerformed(ActionEvent ae) {
GregorianCalendar calendario = new GregorianCalendar();
int h = calendario.get(GregorianCalendar.HOUR_OF_DAY);
int m = calendario.get(GregorianCalendar.MINUTE);
int s = calendario.get(GregorianCalendar.SECOND);
String hora =
((h < 10) ? "0" : "")
+ h
+ ":"
+ ((m < 10) ? "0" : "")
+ m
+ ":"
+ ((s < 10) ? "0" : "")
+ s;
label.setText(hora);
}
public static void main(String args[]) {
new Relogio();
}
}