Skip to content

Instantly share code, notes, and snippets.

@LucasAlfare
Created November 1, 2016 20:55
Show Gist options
  • Save LucasAlfare/b897b177a54704667202811b807c6770 to your computer and use it in GitHub Desktop.
Save LucasAlfare/b897b177a54704667202811b807c6770 to your computer and use it in GitHub Desktop.
Testando uma coisa aqui,,,
package main.aux;
/**
* Created by familia on 01/11/16.
*/
public class Utils {
public static final String SENHA = "123";
/*
Metal
Nimbus
CDE/Motif
GTK+
*/
}
package main.core;
import main.aux.Utils;
import main.telas.MainGui;
import main.telas.NovaFinancaGui;
import main.telas.SenhaGui;
import javax.swing.*;
import java.util.ArrayList;
/**
* Created by familia on 31/10/16.
*
* Classe responsável por controlar as principais ações que o programa desempenhará
*/
public class Core {
/*
* Instância da tela principal
*/
private MainGui mainGui;
/*
* Instância da tela de senha
*/
private SenhaGui senhaGui;
/*
* Instância da tela de nova finança
*/
private NovaFinancaGui novaFinancaGui;
/*
* ArrayList para armazenar objetos Financa
*/
private ArrayList<Financa> financas;
/*
* Variável final para armazenar a Senha
*/
private static final String SENHA = Utils.SENHA;
/*/
* Construtor sem parâmetro
*/
public Core(){
mainGui = new MainGui();
senhaGui = new SenhaGui(this);
novaFinancaGui = new NovaFinancaGui(this);
financas = new ArrayList<>();
setButtonsListeners();
}
/*
* Método para adicionar listeners a todos os botões necessários
* da classe da tela principal
*/
public void setButtonsListeners(){
/*
Botao "Nova Finança"
*/
mainGui.getAddFinanca().addActionListener(e -> novaFinancaGui.setVisible(true));
/*
Botao "Remover Selecionada"
*/
mainGui.getRemoveFinanca().addActionListener(e -> {
senhaGui.setCall(0);
senhaGui.getPass().setText("");
senhaGui.setVisible(true);
});
/*
Botao "Ocultar Selecionada"
*/
mainGui.getHideFinanca().addActionListener(e -> {
senhaGui.setCall(1);
senhaGui.getPass().setText("");
senhaGui.setVisible(true);
});
}
/*
* Método público para ser acessado pelas outras telas, servindo
* para remover o item da lista selecionado
*/
public void removerFinanca(String senha){
//Caso a senha esteja correta...
if (senha.equals(SENHA)){
//Caso haja algo selecionado na lista...
if (!mainGui.getLista().isSelectionEmpty()){
financas.remove(financas.get(mainGui.getLista().getSelectedIndex()));
atualizarTela();
JOptionPane.showMessageDialog(mainGui.getParent(), "Removido!");
}
} else {
JOptionPane.showMessageDialog(mainGui.getParent(), "SENHA INCORRETA");
}
}
public void ocultarFinanca(String senha){
if (senha.equals(SENHA)){
//TODO ocultar finança selecionada logic here...
JOptionPane.showMessageDialog(mainGui.getParent(), "Ocultado!");
} else {
JOptionPane.showMessageDialog(mainGui.getParent(), "SENHA INCORRETA");
}
}
/*
* Método público para ser acessado pelas outras telas, servindo
* para adicionar uma nova finança à lista
*/
public void addFinanca(Financa financa){
if (financa != null){
financas.add(financa);
atualizarTela();
JOptionPane.showMessageDialog(mainGui.getParent(), "Adicionado!");
} else {
JOptionPane.showMessageDialog(mainGui.getParent(), "Finança nula!! Faz de novo.");
}
}
/*
* Método privado para atualizar a lista, ressetando o model da mesma
*/
private void atualizarTela(){
this.mainGui.getLista().setModel(new AbstractListModel() {
String[] strings = financasToArray();
//String[] strings = financas.toArray(new String[financas.size()]);
public int getSize() {
return strings.length;
}
public Object getElementAt(int i) {
return strings[i];
}
});
}
/*
* Método privado para converter ArrayList<Fincanca> em String[]
*/
private String[] financasToArray(){
String[] r = new String[financas.size()];
for (int i = 0; i < r.length; i++){
r[i] = financas.get(i).toString();
}
return financas.size() > 0 ? r : new String[]{"[vazio]"};
}
public MainGui getMainGui() {
return mainGui;
}
}
package main.core;
import java.text.SimpleDateFormat;
public class Financa {
/*
* Data da finança
*/
private String data;
/*
* Valor da finança
*/
private double valor;
/*
* Nome da finança
*/
private String nome;
/*
* Descrição da finança
*/
private String descricao;
/*
* Construtor que recebe valor, nome e descrição para uma nova finança.
* Automaticamente define a data como a data atual.
*/
public Financa(double valor, String nome, String descricao) {
this.data = new SimpleDateFormat("dd/MM/yyyy").format(System.currentTimeMillis());
this.valor = valor;
this.nome = nome;
this.descricao = descricao;
}
/*
* Construtor que recebe data, valor, nome e descrição para uma nova finança.
*/
public Financa(String data, double valor, String nome, String descricao) {
this.data = data;
this.valor = valor;
this.nome = nome;
this.descricao = descricao;
}
public double getValor() {
return valor;
}
public void setValor(double valor) {
this.valor = valor;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
/*
* O método toString() é aqui invocado para traduzir em texto o objeto
* finança. Dessa forma o texto contém todos os parâmetros, mostrados
* em uma String formatada.
*/
@Override
public String toString() {
return "[" + data + "] " + valor + " - " + nome + " - " + descricao;
}
}
package main;
import main.core.Core;
import main.telas.MainGui;
import java.awt.*;
/**
* Created by familia on 31/10/16.
*/
public class Main {
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("GTK+".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | javax.swing.UnsupportedLookAndFeelException | IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MainGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
/*
* Inicia a tela principal
*/
EventQueue.invokeLater(() -> new Core().getMainGui().setVisible(true));
}
}
package main.telas;
import javax.swing.*;
/**
*
* @author familia on 31/10/16.
*/
public class MainGui extends javax.swing.JFrame {
/**
* Creates new form MainGui
*/
public MainGui() {
initComponents();
this.setLocationRelativeTo(null);
}
/*
* Inicia todos os componentes e posicionamentos da tela
*/
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
lista = new javax.swing.JList();
addFinanca = new javax.swing.JButton();
removeFinanca = new javax.swing.JButton();
editFinanca = new javax.swing.JButton();
hideFinanca = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
dinheiroDisponivel = new javax.swing.JLabel();
totalGasto = new javax.swing.JLabel();
totalInvestido = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
sairMenu = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
editarMontanteMenu = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Money Helper");
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Finanças"));
lista.setModel(new javax.swing.AbstractListModel() {
String[] strings = {"[vazio]"};
public int getSize() {
return strings.length;
}
public Object getElementAt(int i) {
return strings[i];
}
});
jScrollPane1.setViewportView(lista);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE)
);
addFinanca.setText("Adicionar nova");
removeFinanca.setText("Remover Selecionada");
editFinanca.setText("Editar Selecionada");
hideFinanca.setText("Ocultar Selecionada");
dinheiroDisponivel.setFont(new java.awt.Font("Ubuntu", 1, 18)); // NOI18N
dinheiroDisponivel.setForeground(new java.awt.Color(14, 191, 34));
dinheiroDisponivel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
dinheiroDisponivel.setText("<html>Dinheiro Disponível:<br />R$ 0,00");
dinheiroDisponivel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
totalGasto.setFont(new java.awt.Font("Ubuntu", 1, 18)); // NOI18N
totalGasto.setForeground(new java.awt.Color(215, 57, 57));
totalGasto.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
totalGasto.setText("<html>Total Gasto:<br />R$ 0,00");
totalGasto.setBorder(javax.swing.BorderFactory.createEtchedBorder());
totalInvestido.setFont(new java.awt.Font("Ubuntu", 1, 18)); // NOI18N
totalInvestido.setForeground(new java.awt.Color(66, 90, 221));
totalInvestido.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
totalInvestido.setText("Total Investido: R$ 0,00");
totalInvestido.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jMenu1.setText("File");
sairMenu.setText("Sair");
jMenu1.add(sairMenu);
jMenuBar1.add(jMenu1);
jMenu2.setText("Edit");
editarMontanteMenu.setText("Editar montante...");
jMenu2.add(editarMontanteMenu);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSeparator1)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(totalInvestido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(dinheiroDisponivel, javax.swing.GroupLayout.PREFERRED_SIZE, 283, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(totalGasto))
.addGroup(layout.createSequentialGroup()
.addComponent(addFinanca)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(removeFinanca)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(editFinanca)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(hideFinanca)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addFinanca)
.addComponent(removeFinanca)
.addComponent(editFinanca)
.addComponent(hideFinanca))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(dinheiroDisponivel, javax.swing.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE)
.addComponent(totalGasto))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(totalInvestido, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}
public JButton getAddFinanca() {
return addFinanca;
}
public JButton getRemoveFinanca() {
return removeFinanca;
}
public JButton getEditFinanca() {
return editFinanca;
}
public JButton getHideFinanca() {
return hideFinanca;
}
public JLabel getDinheiroDisponivel() {
return dinheiroDisponivel;
}
public JLabel getTotalGasto() {
return totalGasto;
}
public JLabel getTotalInvestido() {
return totalInvestido;
}
public JMenuItem getSairMenu() {
return sairMenu;
}
public JMenuItem getEditarMontanteMenu() {
return editarMontanteMenu;
}
public JList getLista() {
return lista;
}
// Variables declaration - do not modify
private javax.swing.JButton addFinanca;
private javax.swing.JButton removeFinanca;
private javax.swing.JButton editFinanca;
private javax.swing.JButton hideFinanca;
private javax.swing.JLabel dinheiroDisponivel;
private javax.swing.JLabel totalGasto;
private javax.swing.JLabel totalInvestido;
private javax.swing.JList lista;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem sairMenu;
private javax.swing.JMenuItem editarMontanteMenu;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
// End of variables declaration
}
package main.telas;
import main.core.Core;
import main.core.Financa;
import javax.swing.*;
/**
*
* @author familia
*/
public class NovaFinancaGui extends JFrame {
/*
* Instância para armazenar a classe de controle principal
*/
private Core core;
/**
* Creates new form NovaFinancaGui
*/
public NovaFinancaGui(Core core) {
this.core = core;
initComponents();
this.setLocationRelativeTo(null);
this.setListeners();
}
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
valor = new javax.swing.JTextField();
nome = new javax.swing.JTextField();
data = new javax.swing.JTextField();
jSeparator1 = new javax.swing.JSeparator();
jScrollPane1 = new javax.swing.JScrollPane();
descricao = new javax.swing.JTextArea();
jSeparator2 = new javax.swing.JSeparator();
add = new javax.swing.JButton();
fechar = new javax.swing.JButton();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Nova Finança");
jLabel1.setText("Valor:");
jLabel2.setText("Título:");
jLabel3.setText("Data:");
jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
descricao.setColumns(20);
descricao.setRows(5);
descricao.setBorder(javax.swing.BorderFactory.createTitledBorder("Descrição"));
jScrollPane1.setViewportView(descricao);
add.setText("Adicionar");
add.setHideActionText(true);
add.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
fechar.setText("Fechar");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator2)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(add, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(fechar, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addGap(18, 18, 18)
.addComponent(data))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(valor, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
.addComponent(nome))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jSeparator1)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(valor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(data, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(add)
.addComponent(fechar)))
);
pack();
}
public void setListeners(){
fechar.addActionListener(e -> this.dispose());
add.addActionListener(e -> mandarFinanca());
}
public void mandarFinanca(){
double val = Double.parseDouble(valor.getText());
String nom = nome.getText();
String desc = descricao.getText();
this.core.addFinanca(new Financa(val, nom, desc));
}
public JButton getFechar() {
return fechar;
}
public JButton getAdd() {
return add;
}
public JTextField getValor() {
return valor;
}
public JTextField getNome() {
return nome;
}
public JTextField getData() {
return data;
}
public JTextArea getDescricao() {
return descricao;
}
// Variables declaration - do not modify
private javax.swing.JButton add;
private javax.swing.JButton fechar;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JTextArea descricao;
private javax.swing.JTextField valor;
private javax.swing.JTextField nome;
private javax.swing.JTextField data;
// End of variables declaration
}
package main.telas;
import main.aux.Utils;
import main.core.Core;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
*
* @author familia
*/
public class SenhaGui extends javax.swing.JFrame {
private Core core;
private int call;
public SenhaGui(Core core) {
this.core = core;
initComponents();
setLocationRelativeTo(null);
setListeners();
pass.setText("");
}
public SenhaGui(Core core, int call) {
this.core = core;
this.call = call;
initComponents();
setLocationRelativeTo(null);
setListeners();
pass.setText("");
}
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
pass = new javax.swing.JPasswordField();
ok = new javax.swing.JButton();
cancelar = new javax.swing.JButton();
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Inserir Senha");
jLabel1.setText("Senha:");
ok.setText("Ok");
cancelar.setText("Cancelar");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(ok, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelar, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(2, 2, 2)
.addComponent(pass)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(ok)
.addComponent(cancelar))
.addContainerGap())
);
pack();
}
public void setListeners(){
cancelar.addActionListener(e -> this.dispose());
ok.addActionListener(e -> {
mandarSenha(pass.getText(), call);
if (pass.getText().equals(Utils.SENHA)){
this.dispose();
}
});
pass.addActionListener(e -> {
mandarSenha(pass.getText(), call);
if (pass.getText().equals(Utils.SENHA)){
this.dispose();
}
});
}
public void mandarSenha(String senha, int call){
switch (call){
case 0:
this.core.removerFinanca(senha);
break;
case 1:
this.core.ocultarFinanca(senha);
break;
}
}
public JButton getOk() {
return ok;
}
public JButton getCancelar() {
return cancelar;
}
public JPasswordField getPass() {
return pass;
}
public void setCall(int call) {
this.call = call;
}
// Variables declaration - do not modify
private javax.swing.JButton ok;
private javax.swing.JButton cancelar;
private javax.swing.JLabel jLabel1;
private javax.swing.JPasswordField pass;
// End of variables declaration
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment