Então R063r5 eu fiz oque vc flo so que esta dando erro na seguinte Linhaa
Aqui esta meu main para ter uma visão mais ampla do projeto:
Não sei se os encaixes dos codigos estão corretos
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
//import javax.swing.UnsupportedLookAndFeelException;
import org.jvnet.substance.skin.SubstanceRavenLookAndFeel;
public class Main {
public static void main(String[] args) {
/*
try {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
} catch (UnsupportedLookAndFeelException ulfe) {
ulfe.printStackTrace();
}
*/
JFrame.setDefaultLookAndFeelDecorated(true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(new SubstanceRavenLookAndFeel());// aqui você altera os temas
} catch (Exception e) {
System.out.println("Substance Raven Graphite failed to initialize");
}
new Messenger().setVisible(true);
}
});
JfrmChefe chefe = new JfrmChefe();
chefe.setSize(600, 520);
chefe.setLocation(200,200);
chefe.setTitle("Tela Principal");
chefe.setVisible(true);
chefe.setResizable(false);
}
}
e Aqui esta minha classe que contem minha janelaa:
import javax.swing.*;
import javax.swing.BorderFactory;
import java.awt.event.*;
import java.awt.*;
import javax.swing.border.*;
class JfrmChefe extends JFrame implements ActionListener {
private JButton
btnMoChefe1 = new JButton("<html><font size=4 color ='000080'><b> M.Chefe </b></font></html>"),
btnChefe2 = new JButton("<html><font size=4 color ='000080'><b> Cadastrar </b></font></html>"),
btnChefe3 = new JButton("<html><font size=4 color ='000080'><b> Mostrar </b></font></html>"),
btnMoTrab1 = new JButton("<html><font size=4 color ='000080'><b> M.Trabalhador </b></font></html>"),
btnTraba2 = new JButton("<html><font size=4 color ='000080'><b> Cadastrar </b></font></html>"),
btnTraba3 = new JButton("<html><font size=4 color ='000080'><b> Mostrar </b></font></html>");
private JPanel
layoutPri = new JPanel(),
layoutSub = new JPanel(),
layoutChefe = new JPanel(),
layoutTrab = new JPanel();
private JLabel
lblPri = new JLabel("<html><font size = 6 color ='000080' ><b>Laboratorio de Informática SM</b></font></html>"),
lblSub = new JLabel("<html><font size = 5 color ='000080' ><b>Cadastro</b></font></html>"),
lblChefe1 = new JLabel("<html><font size = 4 color ='000080' ><b>Nome: </b></font></html>"),
lblChefe2 = new JLabel("<html><font size = 4 color ='000080' ><b>Salario: </b></font></html>"),
lblChefe3 = new JLabel("<html><font size = 3 color ='000080' ><b>PagamentAdd:</b></font></html>"),
lblTraba1 = new JLabel("<html><font size = 4 color ='000080' ><b>Nome: </b></font></html>"),
lblTraba2 = new JLabel("<html><font size = 4 color ='000080' ><b>Salario: </b></font></html>");
private JTextField
txtChefe1 = new JTextField(40),
txtChefe2 = new JTextField(40),
txtChefe3 = new JTextField(40),
txtTraba1 = new JTextField(40),
txtTraba2 = new JTextField(40);
public JfrmChefe(){
setDefaultCloseOperation(EXIT_ON_CLOSE);
layoutPri.setLayout(new FlowLayout());
layoutSub.setLayout(new FlowLayout());
layoutChefe.setLayout(null);
layoutTrab.setLayout(null);
getContentPane().setBackground(Color.gray);
layoutPri.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
layoutPri.setBackground(Color.LIGHT_GRAY);
layoutSub.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
layoutSub.setBackground(Color.LIGHT_GRAY);
layoutChefe.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
layoutTrab.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
//pAut3.setBackground(Color.LIGHT_GRAY);
layoutPri.add(lblPri);
layoutPri.setBounds(1,5,593,40);
layoutSub.add(lblSub);
layoutSub.setBounds(80,44,420,40);
//================CHEFE============================
layoutChefe.add(txtChefe1);
txtChefe1.setBounds(70, 50, 100, 25);
txtChefe1.setFont(new Font("Candara",Font.BOLD,15));
layoutChefe.add(lblChefe1);
lblChefe1.setBounds(25, 50, 100, 25);
//=================================================
layoutChefe.add(txtChefe2);
txtChefe2.setBounds(77, 100, 100, 25);
txtChefe2.setFont(new Font("Candara",Font.BOLD,15));
layoutChefe.add(lblChefe2);
lblChefe2.setBounds(25, 100, 100, 25);
//=================================================
layoutChefe.add(txtChefe3);
txtChefe3.setBounds(89, 150, 100, 25);
txtChefe3.setFont(new Font("Candara",Font.BOLD,15));
layoutChefe.add(lblChefe3);
lblChefe3.setBounds(5,150,100,25);
//=================================================
layoutChefe.add(btnChefe2);
btnChefe2.setBackground(Color.LIGHT_GRAY);
btnChefe2.setBounds(65,190,120,30);
layoutChefe.add(btnChefe3);
btnChefe3.setBackground(Color.LIGHT_GRAY);
btnChefe3.setBounds(65,230,120,30);
layoutChefe.setBounds(170, 150, 250,280);
//================FIM=CHEFE========================
//===============TRABALHADOR=======================
layoutTrab.add(txtTraba1);
txtTraba1.setBounds(70, 50, 100, 25);
txtTraba1.setFont(new Font("Candara",Font.BOLD,15));
layoutTrab.add(lblTraba1);
lblTraba1.setBounds(25, 50, 100, 25);
//=================================================
layoutTrab.add(txtTraba2);
txtTraba2.setBounds(78, 100, 100, 25);
txtTraba2.setFont(new Font("Candara",Font.BOLD,15));
layoutTrab.add(lblTraba2);
lblTraba2.setBounds(25, 100, 100, 25);
//=================================================
layoutTrab.add(btnTraba2);
btnTraba2.setBackground(Color.LIGHT_GRAY);
btnTraba2.setBounds(65, 190, 120, 30);
layoutTrab.add(btnTraba3);
btnTraba3.setBackground(Color.LIGHT_GRAY);
btnTraba3.setBounds(65, 230, 120, 30);
layoutTrab.setBounds(170, 150, 250,280);
//===============FIM=TRABALHADOR===================
getContentPane().add(layoutPri);
getContentPane().add(layoutSub);
getContentPane().add(layoutChefe);
getContentPane().add(layoutTrab);
getContentPane().add(btnMoChefe1);
btnMoChefe1.setBackground(Color.LIGHT_GRAY);
btnMoChefe1.setBounds(300, 100, 150, 30);
getContentPane().add(btnMoTrab1);
btnMoTrab1.setBackground(Color.LIGHT_GRAY);
btnMoTrab1.setBounds(90, 100, 150, 30);
btnMoChefe1.addActionListener(this);
btnChefe2.addActionListener(this);
btnChefe3.addActionListener(this);
btnMoTrab1.addActionListener(this);
btnTraba2.addActionListener(this);
btnTraba3.addActionListener(this);
layoutChefe.setVisible(false);
layoutTrab.setVisible(false);
getContentPane().setLayout(null);
}
Administrador chef = new Administrador();
Administrador trab = new Administrador();
public void actionPerformed(ActionEvent evento){
//====================CHEFE================================
if(evento.getSource() == btnMoChefe1){
layoutTrab.setVisible(false);
layoutChefe.setVisible(true);}
if(evento.getSource() == btnChefe2){
String nome = txtChefe1.getText();
Float salario = Float.parseFloat(txtChefe2.getText());
Float salarioAdd =Float.parseFloat(txtChefe3.getText());
Chefe chefe = new Chefe(nome,salario,salarioAdd);
chef.add(chefe);
}
if(evento.getSource() == btnChefe3)
JOptionPane.showMessageDialog(null,chef.mostraChefe());
//=============TRABALHADOR=================================
if(evento.getSource() == btnMoTrab1){
layoutChefe.setVisible(false);
layoutTrab.setVisible(true);}
if(evento.getSource() == btnTraba2){
String nome = txtTraba1.getText();
Float salario = Float.parseFloat(txtTraba2.getText());
Trabalhador trabalhador = new Trabalhador(nome,salario);
trab.add(trabalhador);
}
if(evento.getSource() == btnTraba3)
JOptionPane.showMessageDialog(null,trab.mostraTrab());
}
}
Então Marcos como eu so meio iniciante na parte grafica eu não sei te dize bem =/
Obrigado pela ajudaaa ^^