/** Create the frame */ public DateTimer() { super(); setTitle("v14 CountDown"); getContentPane().setLayout(null); setBounds(100, 100, 500, 375); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel finishtimeLabel = new JLabel(); finishtimeLabel.setText("CountDown Time"); finishtimeLabel.setBounds(10, 36, 119, 15); getContentPane().add(finishtimeLabel); finishtime = new JFormattedTextField( new DateFormatter(new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa", Locale.ENGLISH))); finishtime.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) {} }); finishtime.setValue(new Date()); finishtime.setBounds(135, 34, 187, 19); getContentPane().add(finishtime); final JButton startButton = new JButton(); startButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { startCount(); } }); startButton.setText("Start!!!"); startButton.setBounds(334, 31, 111, 25); getContentPane().add(startButton); countLabel = new JLabel(); countLabel.setHorizontalAlignment(SwingConstants.CENTER); countLabel.setHorizontalTextPosition(SwingConstants.CENTER); countLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 14)); countLabel.setBorder(new LineBorder(Color.black, 1, false)); countLabel.setText("Countdown not Started"); countLabel.setBounds(10, 162, 435, 47); getContentPane().add(countLabel); final JLabel credits = new JLabel(); credits.setHorizontalAlignment(SwingConstants.RIGHT); credits.setText(""); credits.setBounds(253, 328, 237, 15); getContentPane().add(credits); }
public RestoreInterviewer(Interviewer interviewer, JLabel j, DefaultListModel listModel) { super("Przywróc do pracy ankietera"); addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { dispose(); // System.exit(0); } }); this.active = j; this.interviewer = interviewer; this.listModel = listModel; // this.workOutTime = workOutTime; setSize(300, 200); setLocation(400, 400); setResizable(false); rel = new JLabel("Data przywrócenia: "); DateFormat format = new SimpleDateFormat("dd--MM--yyyy"); jdate = new JFormattedTextField(format); anul = new JButton("Anuluj"); save = new JButton("Zapisz"); rel.setBounds(20, 10, 150, 40); jdate.setBounds(180, 10, 100, 40); anul.setBounds(20, 100, 100, 50); save.setBounds(180, 100, 100, 50); jdate.setValue(new Date()); JPanel inputPanel = new JPanel(); inputPanel.setLayout(null); inputPanel.add(rel); inputPanel.add(jdate); inputPanel.add(anul); inputPanel.add(save); addcon = this.getContentPane(); addcon.add(inputPanel); anul.addActionListener(this); save.addActionListener(this); setVisible(true); }
/** Create the frame. */ public ConsultarAdotanteFisicoCPFGUI() { setTitle("Consulta"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 645, 455); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel lblNewLabel = new JLabel("CPF:"); lblNewLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12)); lblNewLabel.setBounds(28, 202, 46, 14); contentPane.add(lblNewLabel); MaskFormatter mascaraCpf = null; try { mascaraCpf = new MaskFormatter("###.###.###-##"); mascaraCpf.setPlaceholderCharacter('_'); } catch (ParseException e1) { JOptionPane.showMessageDialog(null, "Digite um CPF válido!" + e1.getMessage(), "ERROR", 0); } JFormattedTextField jFormattedTextCpf = new JFormattedTextField(mascaraCpf); jFormattedTextCpf.setBounds(84, 200, 188, 20); contentPane.add(jFormattedTextCpf); JButton btnConsultarCpf = new JButton("Consultar"); btnConsultarCpf.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { consultaAdotanteFisico(jFormattedTextCpf); } /** * EFETUA A CONSULTA DE UMA ADOTANTE FISICO ATRAVÉS DO CPF E SETA NA GUI * * @param jFormattedTextCpf */ public void consultaAdotanteFisico(JFormattedTextField jFormattedTextCpf) { try { ConsultarAdotanteFisicoGUI consulta = new ConsultarAdotanteFisicoGUI(); PessoaFisicaService pessoaFisicaService = new PessoaFisicaService(); EnderecoService enderecoService = new EnderecoService(); pessoaFisica = pessoaFisicaService.consultarRepresentante(jFormattedTextCpf.getText()); Pessoa pessoa = pessoaFisica.getPessoa(); Endereco endereco = new Endereco(); int idEndereco = pessoaFisica.getPessoa().getEndereco().getId(); endereco = enderecoService.consultarEndereco(idEndereco); consulta.textNomeFisico.setText(pessoa.getNome()); consulta.textEmail.setText(pessoa.getEmail()); consulta.formattedTextFieldTelefoneFixo.setText(pessoa.getTelefoneFixo()); consulta.jFormattedTextTeljFormattedTextCelular.setText(pessoa.getTelefoneCelular()); consulta.comboGenero.setToolTipText(pessoaFisica.getGenero()); consulta.jFormattedTextCPF.setText(pessoaFisica.getCpf()); consulta.textRG.setText(pessoaFisica.getRg()); consulta.textRua.setText(endereco.getRua()); consulta.textBairro.setText(endereco.getBairro()); consulta.textCidade.setText(endereco.getCidade()); consulta.textEstado.setText(endereco.getEstado()); consulta.jFormattedTextCep.setText(endereco.getCep()); consulta.textNumero.setText(endereco.getNumero()); pessoa.setEndereco(endereco); consulta.pf = pessoaFisica; consulta.setVisible(true); dispose(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex, "ERROR", 0); } } }); btnConsultarCpf.setBounds(282, 199, 89, 23); contentPane.add(btnConsultarCpf); lblMostrarNome = new JLabel(""); lblMostrarNome.setFont(new Font("Microsoft YaHei", Font.BOLD, 14)); lblMostrarNome.setBounds(84, 238, 193, 23); contentPane.add(lblMostrarNome); JLabel lblAdooDePessoa = new JLabel("Consulta de Pessoa Fisica"); lblAdooDePessoa.setFont(new Font("Microsoft YaHei", Font.BOLD, 14)); lblAdooDePessoa.setBounds(28, 62, 193, 14); contentPane.add(lblAdooDePessoa); JButton btnVoltar = new JButton("Voltar"); btnVoltar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ConsultarPessoaGUI consultaPessoa = new ConsultarPessoaGUI(); consultaPessoa.setVisible(true); dispose(); ; } }); btnVoltar.setBounds(282, 382, 89, 23); contentPane.add(btnVoltar); JLabel label = new JLabel(""); ImagensGUI.imagemAdocaoFisico(label); label.setBounds(384, 62, 235, 343); contentPane.add(label); }
private void initGUI() { setLayout(new BorderLayout()); tabbedPane = new JTabbedPane(JTabbedPane.TOP); add(tabbedPane); { final JPanel panelIntroduction = new JPanel(); tabbedPane.addTab("Intro", null, panelIntroduction, null); panelIntroduction.setLayout(null); final JLabel lblCrownwearingNucleiTracker = new JLabel("Crown-Wearing Nuclei Segmenter"); lblCrownwearingNucleiTracker.setFont(BIG_FONT); lblCrownwearingNucleiTracker.setHorizontalAlignment(SwingConstants.CENTER); lblCrownwearingNucleiTracker.setBounds(10, 11, 268, 30); panelIntroduction.add(lblCrownwearingNucleiTracker); final JLabel labelIntro = new JLabel(INTRO_TEXT); labelIntro.setFont(SMALL_FONT.deriveFont(11f)); labelIntro.setBounds(10, 52, 268, 173); panelIntroduction.add(labelIntro); final JButton btnTestParamtersLive = new JButton("<html><div align=\"center\">Live test parameters</dic></html>"); btnTestParamtersLive.setBounds(10, 292, 103, 72); btnTestParamtersLive.setFont(FONT); liveLaunched = false; btnTestParamtersLive.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { if (liveLaunched) { stopLive(); btnTestParamtersLive.setText( "<html><div align=\"center\">Live test parameters</div></html>"); liveLaunched = false; } else { launchLive(); btnTestParamtersLive.setText( "<html><div align=\"center\">Stop live test</div></html>"); liveLaunched = true; } } }); panelIntroduction.add(btnTestParamtersLive); final String segFrameButtonText = "<html><CENTER>Segment current frame</center></html>"; final JButton segFrameButton = new JButton(segFrameButtonText); segFrameButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { new Thread("CWNT thread") { @Override public void run() { segFrameButton.setText("Segmenting..."); segFrameButton.setEnabled(false); try { launchSingleFrameSegmentation(); } finally { segFrameButton.setEnabled(true); segFrameButton.setText(segFrameButtonText); } } }.start(); } }); segFrameButton.setFont(FONT); segFrameButton.setBounds(175, 292, 103, 72); panelIntroduction.add(segFrameButton); labelDurationEstimate = new JLabel(); labelDurationEstimate.setBounds(10, 375, 268, 14); panelIntroduction.setFont(FONT); panelIntroduction.add(labelDurationEstimate); } final JPanel panelParams1 = new JPanel(); { tabbedPane.addTab("Param set 1", null, panelParams1, null); panelParams1.setLayout(null); final JLabel lblFiltering = new JLabel("1. Filtering"); lblFiltering.setFont(BIG_FONT); lblFiltering.setBounds(10, 11, 268, 29); panelParams1.add(lblFiltering); { final JLabel lblGaussianFilter = new JLabel("Gaussian filter \u03C3:"); lblGaussianFilter.setFont(SMALL_FONT); lblGaussianFilter.setBounds(10, 51, 268, 14); panelParams1.add(lblGaussianFilter); gaussFiltSigmaSlider = new DoubleJSlider(0, 5 * scale, (int) (maskingParams[0] * scale), scale); gaussFiltSigmaSlider.setBounds(10, 76, 223, 23); panelParams1.add(gaussFiltSigmaSlider); gaussFiltSigmaText = new JFormattedTextField(new Double(maskingParams[0])); gaussFiltSigmaText.setHorizontalAlignment(SwingConstants.CENTER); gaussFiltSigmaText.setBounds(243, 76, 35, 23); gaussFiltSigmaText.setFont(FONT); panelParams1.add(gaussFiltSigmaText); link(gaussFiltSigmaSlider, gaussFiltSigmaText); gaussFiltSigmaSlider.addChangeListener(step1ChangeListener); gaussFiltSigmaText.addKeyListener(step1KeyListener); } final JLabel lblAnisotropicDiffusion = new JLabel("2. Anisotropic diffusion"); lblAnisotropicDiffusion.setFont(BIG_FONT); lblAnisotropicDiffusion.setBounds(10, 128, 268, 29); panelParams1.add(lblAnisotropicDiffusion); { final JLabel lblNumberOfIterations = new JLabel("Number of iterations:"); lblNumberOfIterations.setFont(SMALL_FONT); lblNumberOfIterations.setBounds(10, 168, 268, 14); panelParams1.add(lblNumberOfIterations); aniDiffNIterText = new JFormattedTextField(new Integer((int) maskingParams[1])); aniDiffNIterText.setHorizontalAlignment(SwingConstants.CENTER); aniDiffNIterText.setFont(FONT); aniDiffNIterText.setBounds(243, 193, 35, 23); panelParams1.add(aniDiffNIterText); aniDiffNIterSlider = new DoubleJSlider(0, 10, (int) maskingParams[1], 1); aniDiffNIterSlider.setBounds(10, 193, 223, 23); panelParams1.add(aniDiffNIterSlider); link(aniDiffNIterSlider, aniDiffNIterText); aniDiffNIterSlider.addChangeListener(step2ChangeListener); aniDiffNIterText.addKeyListener(step2KeyListener); } { final JLabel lblGradientDiffusionThreshold = new JLabel("Gradient diffusion threshold \u03BA:"); lblGradientDiffusionThreshold.setFont(SMALL_FONT); lblGradientDiffusionThreshold.setBounds(10, 227, 268, 14); panelParams1.add(lblGradientDiffusionThreshold); aniDiffKappaText = new JFormattedTextField(new Double(maskingParams[2])); aniDiffKappaText.setHorizontalAlignment(SwingConstants.CENTER); aniDiffKappaText.setFont(FONT); aniDiffKappaText.setBounds(243, 252, 35, 23); panelParams1.add(aniDiffKappaText); aniDiffKappaSlider = new DoubleJSlider(1, 100, (int) maskingParams[2], 1); aniDiffKappaSlider.setBounds(10, 252, 223, 23); panelParams1.add(aniDiffKappaSlider); link(aniDiffKappaSlider, aniDiffKappaText); aniDiffKappaSlider.addChangeListener(step2ChangeListener); aniDiffKappaText.addKeyListener(step2KeyListener); } final JLabel lblDerivativesCalculation = new JLabel("3. Derivatives calculation"); lblDerivativesCalculation.setFont(BIG_FONT); lblDerivativesCalculation.setBounds(10, 298, 268, 29); panelParams1.add(lblDerivativesCalculation); { final JLabel lblGaussianGradient = new JLabel("Gaussian gradient \u03C3:"); lblGaussianGradient.setFont(FONT); lblGaussianGradient.setBounds(10, 338, 268, 14); panelParams1.add(lblGaussianGradient); gaussGradSigmaText = new JFormattedTextField(new Double(maskingParams[3])); gaussGradSigmaText.setFont(FONT); gaussGradSigmaText.setHorizontalAlignment(SwingConstants.CENTER); gaussGradSigmaText.setBounds(243, 363, 35, 23); panelParams1.add(gaussGradSigmaText); gaussGradSigmaSlider = new DoubleJSlider(0, 5 * scale, (int) (maskingParams[3] * scale), scale); gaussGradSigmaSlider.setBounds(10, 363, 223, 23); panelParams1.add(gaussGradSigmaSlider); link(gaussGradSigmaSlider, gaussGradSigmaText); gaussGradSigmaSlider.addChangeListener(step3ChangeListener); gaussGradSigmaText.addKeyListener(step3KeyListener); } } final JPanel panelParams2 = new JPanel(); { tabbedPane.addTab("Param set 2", panelParams2); panelParams2.setLayout(null); final JLabel lblMasking = new JLabel("4. Masking"); lblMasking.setFont(BIG_FONT); lblMasking.setBounds(10, 11, 268, 29); panelParams2.add(lblMasking); { final JLabel gammeLabel = new JLabel("\u03B3: tanh shift"); gammeLabel.setFont(SMALL_FONT); gammeLabel.setBounds(10, 51, 268, 14); panelParams2.add(gammeLabel); gammaSlider = new DoubleJSlider(-5 * scale, 5 * scale, (int) (maskingParams[4] * scale), scale); gammaSlider.setBounds(10, 76, 223, 23); panelParams2.add(gammaSlider); gammaText = new JFormattedTextField(new Double(maskingParams[4])); gammaText.setFont(FONT); gammaText.setBounds(243, 76, 35, 23); panelParams2.add(gammaText); link(gammaSlider, gammaText); gammaSlider.addChangeListener(step4ChangeListener); gammaSlider.addKeyListener(step4KeyListener); } { final JLabel lblNewLabel_3 = new JLabel("\u03B1: gradient prefactor"); lblNewLabel_3.setFont(SMALL_FONT); lblNewLabel_3.setBounds(10, 110, 268, 14); panelParams2.add(lblNewLabel_3); alphaSlider = new DoubleJSlider(0, 20 * scale, (int) (maskingParams[5] * scale), scale); alphaSlider.setBounds(10, 135, 223, 23); panelParams2.add(alphaSlider); alphaText = new JFormattedTextField(new Double(maskingParams[5])); alphaText.setFont(FONT); alphaText.setBounds(243, 135, 35, 23); panelParams2.add(alphaText); link(alphaSlider, alphaText); alphaSlider.addChangeListener(step4ChangeListener); alphaText.addKeyListener(step4KeyListener); } { final JLabel betaLabel = new JLabel("\u03B2: positive laplacian magnitude prefactor"); betaLabel.setFont(SMALL_FONT); betaLabel.setBounds(10, 169, 268, 14); panelParams2.add(betaLabel); betaSlider = new DoubleJSlider(0, 20 * scale, (int) (maskingParams[6] * scale), scale); betaSlider.setBounds(10, 194, 223, 23); panelParams2.add(betaSlider); betaText = new JFormattedTextField(new Double(maskingParams[6])); betaText.setFont(FONT); betaText.setBounds(243, 194, 35, 23); panelParams2.add(betaText); link(betaSlider, betaText); betaSlider.addChangeListener(step4ChangeListener); betaText.addKeyListener(step4KeyListener); } { final JLabel epsilonLabel = new JLabel("\u03B5: negative hessian magnitude"); epsilonLabel.setFont(SMALL_FONT); epsilonLabel.setBounds(10, 228, 268, 14); panelParams2.add(epsilonLabel); epsilonSlider = new DoubleJSlider(0, 20 * scale, (int) (scale * maskingParams[7]), scale); epsilonSlider.setBounds(10, 253, 223, 23); panelParams2.add(epsilonSlider); epsilonText = new JFormattedTextField(new Double(maskingParams[7])); epsilonText.setFont(FONT); epsilonText.setText("" + maskingParams[7]); epsilonText.setBounds(243, 253, 35, 23); panelParams2.add(epsilonText); link(epsilonSlider, epsilonText); epsilonSlider.addChangeListener(step4ChangeListener); epsilonText.addKeyListener(step4KeyListener); } { final JLabel deltaLabel = new JLabel("\u03B4: derivatives sum scale"); deltaLabel.setFont(SMALL_FONT); deltaLabel.setBounds(10, 287, 268, 14); panelParams2.add(deltaLabel); deltaText = new JFormattedTextField(new Double(maskingParams[8])); deltaText.setFont(FONT); deltaText.setText("" + maskingParams[8]); deltaText.setBounds(243, 312, 35, 23); panelParams2.add(deltaText); deltaSlider = new DoubleJSlider(0, 5 * scale, (int) (maskingParams[8] * scale), scale); deltaSlider.setBounds(10, 312, 223, 23); panelParams2.add(deltaSlider); link(deltaSlider, deltaText); deltaSlider.addChangeListener(step4ChangeListener); deltaText.addKeyListener(step4KeyListener); } final JLabel lblEquation = new JLabel( "<html>M = \u00BD ( 1 + <i>tanh</i> ( \u03B3 - ( \u03B1 G + \u03B2 L + \u03B5 H ) / \u03B4 ) )</html>"); lblEquation.setHorizontalAlignment(SwingConstants.CENTER); lblEquation.setFont(FONT.deriveFont(12f)); lblEquation.setBounds(10, 364, 268, 35); panelParams2.add(lblEquation); } { final JPanel panel = new JPanel(); tabbedPane.addTab("Param set 3", null, panel, null); panel.setLayout(null); final JLabel labelThresholding = new JLabel("5. Thresholding"); labelThresholding.setBounds(10, 11, 268, 28); labelThresholding.setFont(BIG_FONT); panel.add(labelThresholding); final JLabel labelThresholdFactor = new JLabel("Threshold factor:"); labelThresholdFactor.setFont(SMALL_FONT); labelThresholdFactor.setBounds(10, 50, 268, 14); panel.add(labelThresholdFactor); thresholdFactorSlider = new DoubleJSlider(0, 5 * scale, (int) (thresholdFactor * scale), scale); thresholdFactorSlider.setBounds(10, 75, 223, 23); panel.add(thresholdFactorSlider); thresholdFactorText = new JFormattedTextField(new Double(thresholdFactor)); thresholdFactorText.setFont(FONT); thresholdFactorText.setBounds(243, 75, 35, 23); panel.add(thresholdFactorText); link(thresholdFactorSlider, thresholdFactorText); thresholdFactorSlider.addChangeListener(step5ChangeListener); thresholdFactorText.addKeyListener(step5KeyListener); } }
/** Initialize the contents of the frame. */ @SuppressWarnings("deprecation") private void initialize() { frmIngresso = new JFrame(); frmIngresso.setTitle("Ingresso"); frmIngresso.setBounds(100, 100, 661, 295); frmIngresso.setDefaultCloseOperation(JFrame.DEFAULT_CURSOR); frmIngresso.getContentPane().setLayout(null); frmIngresso.setResizable(false); JLabel lblNomeDoEvento = new JLabel("Nome do Evento :"); lblNomeDoEvento.setBounds(42, 33, 108, 14); frmIngresso.getContentPane().add(lblNomeDoEvento); txtEvento = new JTextField(); txtEvento.setBounds(152, 30, 419, 20); frmIngresso.getContentPane().add(txtEvento); txtEvento.setColumns(10); JLabel lblIncio = new JLabel("In\u00EDcio :"); lblIncio.setBounds(42, 74, 46, 14); frmIngresso.getContentPane().add(lblIncio); txtDataInicio = new JTextField(); javax.swing.text.MaskFormatter data; try { data = new javax.swing.text.MaskFormatter("##/##/####"); txtDataInicio = new javax.swing.JFormattedTextField(data); } catch (ParseException e1) { e1.printStackTrace(); } txtDataInicio.setBounds(98, 71, 86, 20); frmIngresso.getContentPane().add(txtDataInicio); txtDataInicio.setColumns(10); JLabel lblFim = new JLabel("Fim : "); lblFim.setBounds(42, 105, 46, 14); frmIngresso.getContentPane().add(lblFim); txtDataFim = new JTextField(); javax.swing.text.MaskFormatter dataFim; try { dataFim = new javax.swing.text.MaskFormatter("##/##/####"); txtDataFim = new javax.swing.JFormattedTextField(dataFim); } catch (ParseException e1) { e1.printStackTrace(); } txtDataFim.setBounds(98, 102, 86, 20); frmIngresso.getContentPane().add(txtDataFim); txtDataFim.setColumns(10); JLabel lblHorrio = new JLabel("Hor\u00E1rio :"); lblHorrio.setBounds(282, 74, 58, 14); frmIngresso.getContentPane().add(lblHorrio); txtHorario = new JTextField(); javax.swing.text.MaskFormatter hora; try { hora = new javax.swing.text.MaskFormatter("##:##"); txtHorario = new javax.swing.JFormattedTextField(hora); } catch (ParseException e1) { e1.printStackTrace(); } txtHorario.setBounds(282, 94, 67, 20); frmIngresso.getContentPane().add(txtHorario); txtHorario.setColumns(10); JLabel lblExibioEspecial = new JLabel("Exibi\u00E7\u00E3o Especial "); lblExibioEspecial.setBounds(476, 74, 136, 14); frmIngresso.getContentPane().add(lblExibioEspecial); rdbtnSim = new JRadioButton("Sim"); rdbtnSim.setBounds(476, 96, 58, 23); frmIngresso.getContentPane().add(rdbtnSim); rdbtnNao = new JRadioButton("N\u00E3o"); rdbtnNao.setSelected(true); rdbtnNao.setBounds(556, 96, 56, 23); frmIngresso.getContentPane().add(rdbtnNao); ButtonGroup bg = new ButtonGroup(); bg.add(rdbtnNao); bg.add(rdbtnSim); JLabel lblQuantidadeDeIngresso = new JLabel("Qtd Ingresso :"); lblQuantidadeDeIngresso.setBounds(42, 163, 99, 14); frmIngresso.getContentPane().add(lblQuantidadeDeIngresso); txtQtdIngresso = new JTextField(); txtQtdIngresso.setBounds(139, 160, 67, 20); frmIngresso.getContentPane().add(txtQtdIngresso); txtQtdIngresso.setColumns(10); JLabel lblPreo = new JLabel("Pre\u00E7o :"); lblPreo.setBounds(279, 141, 46, 14); frmIngresso.getContentPane().add(lblPreo); JLabel lblSemana = new JLabel("Semana : R$"); lblSemana.setBounds(266, 163, 83, 14); frmIngresso.getContentPane().add(lblSemana); JLabel lblFimDeSem = new JLabel("Fim de Sem. : R$"); lblFimDeSem.setBounds(440, 163, 99, 14); frmIngresso.getContentPane().add(lblFimDeSem); dFormat = new DecimalFormat("#,###,###0.00"); formatter = new NumberFormatter(dFormat); formatter.setFormat(dFormat); formatter.setAllowsInvalid(false); txtSemana = new JFormattedTextField(); txtSemana.setFormatterFactory(new DefaultFormatterFactory(formatter)); txtSemana.setBounds(341, 160, 76, 20); frmIngresso.getContentPane().add(txtSemana); txtFds = new JFormattedTextField(); DecimalFormat df = new DecimalFormat("#,###,###0.00"); NumberFormatter nf = new NumberFormatter(df); nf.setFormat(df); nf.setAllowsInvalid(false); txtFds.setFormatterFactory(new DefaultFormatterFactory(nf)); txtFds.setBounds(536, 160, 76, 20); frmIngresso.getContentPane().add(txtFds); btnSalvar = new JButton("Salvar"); btnSalvar.setBounds(546, 223, 89, 23); frmIngresso.getContentPane().add(btnSalvar); btnVoltar = new JButton("Voltar"); btnVoltar.setBounds(10, 223, 89, 23); frmIngresso.getContentPane().add(btnVoltar); btnNovo = new JButton("Novo"); btnNovo.setBounds(288, 223, 89, 23); frmIngresso.getContentPane().add(btnNovo); JButton btnAlterar = new JButton("Alterar"); btnAlterar.setBounds(421, 223, 89, 23); frmIngresso.getContentPane().add(btnAlterar); btnVoltar.addActionListener(this); btnSalvar.addActionListener(this); btnNovo.addActionListener(this); }
Liqui(Connection LoginCN) { cn = LoginCN; liquiwindow = new JFrame("Liquistatus"); liquiwindow.setSize(800, 560); liquiwindow.setLocation(200, 200); liquiwindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); liquiwindow.setLayout(null); liquiwindow.setResizable(false); // schriftenfestlegungen fontTxtFields = new Font("Arial", Font.PLAIN, 16); fontCmbBoxes = new Font("Arial", Font.PLAIN, 16); fontLists = new Font("Arial", Font.PLAIN, 10); pnlAbrMonat = new JPanel(); pnlAbrMonat.setLayout(null); pnlAbrMonat.setBounds(30, 30, 150, 60); pnlAbrMonat.setBorder(new TitledBorder("Abrechnungsmonat")); // inhalt fuer Panel AbrMonat erstellen try { txtAbrMonat = new JFormattedTextField(new MaskFormatter("01-##-20##")); } catch (ParseException e1) { e1.printStackTrace(); } txtAbrMonat.setBounds(20, 25, 110, 25); txtAbrMonat.setHorizontalAlignment(JFormattedTextField.RIGHT); txtAbrMonat.setFont(fontTxtFields); txtAbrMonat.addKeyListener( new KeyListener() { @Override public void keyTyped(KeyEvent ke) {} @Override public void keyReleased(KeyEvent ke) { if (ke.getKeyCode() == KeyEvent.VK_ENTER && Pattern.matches("\\d{2}.\\d{2}.[1-9]{1}\\d{3}", txtAbrMonat.getText())) { txtHinweis.setText(""); // clear txtHinweis Field lstModelAllIncome.clear(); // clear form old values from the previos call cmbModelPerson.removeAllElements(); // clear befor put new elements in to it calculate_profit(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0)); putPersonNameToCmbPerson(); putIncomeToListAllIncome(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0)); // check if the actual liquimonth is already fix and it is so, then set the buttons, // who put and remove // incomes to and from persons, inactive if (is_liqui_fix(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0))) { btnAdd.setEnabled(false); btnRemove.setEnabled(false); } else { btnAdd.setEnabled(true); btnRemove.setEnabled(true); } } } @Override public void keyPressed(KeyEvent ke) {} }); // inhalte fuer das Panel AbrMonat auf selbiges legen pnlAbrMonat.add(txtAbrMonat); pnlRestwert = new JPanel(); pnlRestwert.setLayout(null); pnlRestwert.setBounds(30, 115, 150, 60); pnlRestwert.setBorder(new TitledBorder("Monatsrestwert")); // inhalt fuer Panel Restwert erstellen txtNutzBetr = new JFormattedTextField(new NumberFormatter(new DecimalFormat("#,##0.00"))); txtNutzBetr.setBounds(20, 25, 110, 25); txtNutzBetr.setHorizontalAlignment(JFormattedTextField.RIGHT); txtNutzBetr.setFont(fontTxtFields); txtNutzBetr.setText("0,00"); txtNutzBetr.addFocusListener( new FocusListener() { public void focusLost(FocusEvent fe) {} public void focusGained(FocusEvent fe) { txtNutzBetr.selectAll(); } }); // inhalte fuer das Panel AbrMonat auf selbiges legen pnlRestwert.add(txtNutzBetr); // Textfeld fuer Hinweise zum errechneten Betrag txtHinweis = new JTextArea(); txtHinweis.setBounds(195, 30, 230, 205); txtHinweis.setBorder(BorderFactory.createEtchedBorder()); txtHinweis.setEditable(false); // infos sollen nur vom Programm gesetzt werden // Bereich fuer die Einnahmenaufteilung anlegen pnlEinahmenAufteilung = new JPanel(); pnlEinahmenAufteilung.setLayout(null); pnlEinahmenAufteilung.setBounds(30, 240, 640, 300); pnlEinahmenAufteilung.setBorder(new TitledBorder("Einnahmenaufteilung")); // elemente fuer die Einnahmenaufteilung anlegen lblPerson = new JLabel("Person"); lblPerson.setBounds(20, 25, 110, 25); cmbModelPerson = new DefaultComboBoxModel<String>(); cmbPerson = new JComboBox<String>(cmbModelPerson); cmbPerson.setBounds(130, 25, 170, 25); cmbPerson.setFont(fontCmbBoxes); cmbPerson.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == 1) { // clear the List IncomePerPerson when Person is changed (to another or to nothing) lstModelIncomePerPerson.clear(); if (cmbPerson.getSelectedIndex() > 0) { // extract personen_id from selected Value String selectedValue = cmbPerson.getSelectedItem().toString(); Integer personen_id = Integer.valueOf( selectedValue.substring( selectedValue.indexOf("(") + 1, selectedValue.indexOf(")"))); // fill lstIncomePerPerson getIncomeForSelectedPerson( personen_id, BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0)); } } } }); // Scrollliste der gesammten Einnahmen lstModelAllIncome = new DefaultListModel<String>(); lstAllIncome = new JList<String>(lstModelAllIncome); lstAllIncome.setFont(fontLists); lstAllIncome.addMouseListener( new MouseListener() { @Override public void mouseReleased(MouseEvent e) {} @Override public void mousePressed(MouseEvent e) {} @Override public void mouseExited(MouseEvent e) {} @Override public void mouseEntered(MouseEvent e) {} @Override public void mouseClicked(MouseEvent e) { // do someone only when elements exist if (lstModelAllIncome.getSize() > 0) { String elementValue = lstModelAllIncome.getElementAt(lstAllIncome.getSelectedIndex()); lblBuchtext.setToolTipText( getBuchText( elementValue.substring( elementValue.indexOf("(") + 1, elementValue.indexOf(")")))); // chek if a splitted part of the transaktions_id of the selectet Value is already put // to a // person, if it is so, the checkbox split must checked and protect against unchecked if (existSplittedPartInIpp( elementValue.substring( elementValue.indexOf("(") + 1, elementValue.indexOf(")")))) { chkAufteilung.setSelected(true); chkAufteilung.setEnabled(false); } else { chkAufteilung.setSelected(false); chkAufteilung.setEnabled(true); } } } }); spAllIncome = new JScrollPane(lstAllIncome); spAllIncome.setBounds(20, 65, 100, 205); // scrollliste der einnahmen pro Person lstModelIncomePerPerson = new DefaultListModel<String>(); lstIncomPerPerson = new JList<String>(lstModelIncomePerPerson); lstIncomPerPerson.setFont(fontLists); spIncomePerPerson = new JScrollPane(lstIncomPerPerson); spIncomePerPerson.setBounds(220, 65, 100, 205); // checkbox fuer die Aufteilungskennzeichnung chkAufteilung = new JCheckBox("Split", false); chkAufteilung.setBounds(145, 70, 60, 30); // Buttons fuer das hinzufuegen und entfernen der Betraege zu den Personen btnAdd = new JButton(">>"); btnAdd.setBounds(145, 130, 60, 20); btnAdd.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { Integer AllIncomeSelectedIndex; Integer PersonSelectedIndex; // note important selected Index AllIncomeSelectedIndex = lstAllIncome.getSelectedIndex(); PersonSelectedIndex = cmbPerson.getSelectedIndex(); // move the selected field from lstAllIncome to lstIncomePerPerson if (AllIncomeSelectedIndex >= 0 && PersonSelectedIndex >= 1) { // note some selected Values String selectedValue = cmbPerson.getSelectedItem().toString(); Integer personen_id = Integer.valueOf( selectedValue.substring( selectedValue.indexOf("(") + 1, selectedValue.indexOf(")"))); // get Selected Value from the AllIncomeList String selectedAmountWithKey = lstModelAllIncome.getElementAt(AllIncomeSelectedIndex); // extract transaktions_id from the selected Amountvalue Integer transaktions_id = Integer.valueOf( selectedAmountWithKey.substring( selectedAmountWithKey.indexOf("(") + 1, selectedAmountWithKey.indexOf(")"))); String sAmount = selectedAmountWithKey.substring(0, selectedAmountWithKey.indexOf(" (")); // check if Amount have to split and get the Person_id who get the splited Amount if (chkAufteilung.isSelected()) { String AmountPart = JOptionPane.showInputDialog( "Bitte den Teilbetrag von " + sAmount + " eingeben:", sAmount); AmountPart = AmountPart.replace(",", "."); if (AmountPart.matches("^[0-9]+(\\.[0-9]{1,2})?$")) { lstModelIncomePerPerson.insertElementAt( AmountPart + " (" + transaktions_id + ")", lstModelIncomePerPerson.getSize()); // remove old Amount Value from List AllIncome lstModelAllIncome.remove(AllIncomeSelectedIndex); // calculate the diffrence between Old Amount and the AmountPart Float AmountAllIncomeNew = Float.valueOf(sAmount) - Float.valueOf(AmountPart); // put difference in the List AllIncome if it greater then zero if (AmountAllIncomeNew > 0) lstModelAllIncome.insertElementAt( AmountAllIncomeNew.toString() + " (" + transaktions_id + ")", lstModelAllIncome.getSize()); // put AmountPart in the IPP Table pushAmountToTableIPP(AmountPart, transaktions_id, personen_id, "true"); } else { JOptionPane.showMessageDialog( liquiwindow, "Eingabe ist kein gültiger Zahlwert! Der Gesamtbetrag wird genommen."); lstModelIncomePerPerson.insertElementAt( selectedAmountWithKey, lstModelIncomePerPerson.getSize()); lstModelAllIncome.remove(AllIncomeSelectedIndex); pushAmountToTableIPP(sAmount, transaktions_id, personen_id, "false"); } } else { lstModelIncomePerPerson.insertElementAt( selectedAmountWithKey, lstModelIncomePerPerson.getSize()); lstModelAllIncome.remove(AllIncomeSelectedIndex); pushAmountToTableIPP(sAmount, transaktions_id, personen_id, "false"); } } } }); btnRemove = new JButton("<<"); btnRemove.setBounds(145, 175, 60, 20); btnRemove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { Integer IncomePerPersonSelectedIndex; Integer PersonSelectedIndex; Boolean transaktions_id_is_in_elements = false; int eID = 0; // counter for the elements in the Enumeration to find an element with the same // transaktions_id // note important selected Indexes IncomePerPersonSelectedIndex = lstIncomPerPerson.getSelectedIndex(); PersonSelectedIndex = cmbPerson.getSelectedIndex(); // move the selected field from lstIncomePerPerson to lstAllIncome if (IncomePerPersonSelectedIndex >= 0 && PersonSelectedIndex >= 1) { String selectedPersonAmountWithKey = lstModelIncomePerPerson.getElementAt(IncomePerPersonSelectedIndex); // note the transaktions_id from the selectet Value at the right site String transaktions_id_right_site = selectedPersonAmountWithKey.substring( selectedPersonAmountWithKey.indexOf("(") + 1, selectedPersonAmountWithKey.indexOf(")")); // check if the transaktions_id from the element that remove from the // IncomPerPerson List at the right site, is alredy in the list AllIncome at the // left Site. If it is so, then we must add the amount of the elements at the left // side to the right // where the transaktions_id is the same Enumeration<String> e = lstModelAllIncome.elements(); while (e.hasMoreElements() && !transaktions_id_is_in_elements) { // note the actual Elemant in the Enumeration String actualElement = e.nextElement().toString(); // note the transaktions_id from the actual element at the left site String transaktions_id_left_site = actualElement.substring( actualElement.indexOf("(") + 1, actualElement.indexOf(")")); if (transaktions_id_right_site.equals(transaktions_id_left_site)) { // we need not look further and set transaktions_id_is_in_elements to true // that will break the while loop transaktions_id_is_in_elements = true; } else { transaktions_id_is_in_elements = false; eID++; } } if (transaktions_id_is_in_elements) { // if found an element with the same id in the left field, add the amount of the // removed // element at the right site, to the amount of the found element and put the result // at the end of the listAllIncome // note the two Amounts that have to add String AmountFromRightSite = selectedPersonAmountWithKey.substring( 0, selectedPersonAmountWithKey.indexOf(" (")); String AmountFromLeftSite = lstModelAllIncome .getElementAt(eID) .substring(0, lstModelAllIncome.getElementAt(eID).indexOf(" (")); Float newAmount = Float.valueOf(AmountFromRightSite) + Float.valueOf(AmountFromLeftSite); // remove the element at the right and the left site lstModelIncomePerPerson.remove(IncomePerPersonSelectedIndex); lstModelAllIncome.remove(eID); // put the new build Element to the left site lstModelAllIncome.insertElementAt( newAmount + " (" + transaktions_id_right_site + ")", lstModelAllIncome.getSize()); } else { // if not found, only put the removed Elemnt to the end of the List at the left site lstModelAllIncome.insertElementAt( selectedPersonAmountWithKey, lstModelAllIncome.getSize()); lstModelIncomePerPerson.remove(IncomePerPersonSelectedIndex); } // delete the moved Amount in the Table ipp for the selected Person String selectedValue = cmbPerson.getSelectedItem().toString(); Integer personen_id = Integer.valueOf( selectedValue.substring( selectedValue.indexOf("(") + 1, selectedValue.indexOf(")"))); deleteAmountFromTableIPP(selectedPersonAmountWithKey, personen_id); } } }); lblBuchtext = new JLabel("Buchungstext (Tooltip)"); lblBuchtext.setBounds(20, 275, 300, 20); btnCalcPercentualPortion = new JButton("Anteilberechnung"); btnCalcPercentualPortion.setBounds(330, 65, 160, 20); btnCalcPercentualPortion.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int personCount; double[] PersonAmount; double TotalPersonAmount = 0; // clear the infotextfield txtHinweisAufteilung.setText(""); // note the amount of person in the cmb box person // the first entry is not a person personCount = cmbModelPerson.getSize() - 1; // sum up the acounts of each person if there are one if (personCount > 0) { PersonAmount = new double[personCount]; double dResidualValue = Double.valueOf(txtNutzBetr.getText().replace(",", ".")); for (int PersonCounter = 1; PersonCounter <= personCount; PersonCounter++) { String selectedValue = cmbPerson.getItemAt(PersonCounter).toString(); Integer personen_id = Integer.valueOf( selectedValue.substring( selectedValue.indexOf("(") + 1, selectedValue.indexOf(")"))); PersonAmount[PersonCounter - 1] = getPersonAcountSumPerLiqui( personen_id, BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0)); TotalPersonAmount = roundScale2(TotalPersonAmount + PersonAmount[PersonCounter - 1]); } // hint the total sum of all person txtHinweisAufteilung.append("Gesammtsumme:\n"); txtHinweisAufteilung.append( Double.toString(TotalPersonAmount).replace(".", ",") + "\n"); // calc the proportion of the sums in percent, to the total Sum of all persons txtHinweisAufteilung.append( "Sparbetrag: " + Double.toString(dResidualValue).replace(".", ",") + "\n"); for (int PersonCounter = 0; PersonCounter < PersonAmount.length; PersonCounter++) { double percent = roundScale2((PersonAmount[PersonCounter] * 100) / TotalPersonAmount); double dValue = roundScale2((percent * dResidualValue) / 100); txtHinweisAufteilung.append( Double.toString(percent).replace(".", ",") + "% / " + Double.toString(dValue).replace(".", ",") + "\n"); } } } }); // Textfeld fuer Hinweise zum errechneten Betrag txtHinweisAufteilung = new JTextArea(); txtHinweisAufteilung.setBounds(330, 90, 180, 180); txtHinweisAufteilung.setBorder(BorderFactory.createEtchedBorder()); txtHinweisAufteilung.setEditable(false); // infos sollen nur vom Programm gesetzt werden // zuweisen der Elemente fuer das Panel Einnahmenaufteilung pnlEinahmenAufteilung.add(lblPerson); pnlEinahmenAufteilung.add(cmbPerson); pnlEinahmenAufteilung.add(spAllIncome); pnlEinahmenAufteilung.add(spIncomePerPerson); pnlEinahmenAufteilung.add(chkAufteilung); pnlEinahmenAufteilung.add(btnAdd); pnlEinahmenAufteilung.add(btnRemove); pnlEinahmenAufteilung.add(lblBuchtext); pnlEinahmenAufteilung.add(btnCalcPercentualPortion); pnlEinahmenAufteilung.add(txtHinweisAufteilung); liquiwindow.add(pnlAbrMonat); liquiwindow.add(pnlRestwert); liquiwindow.add(txtHinweis); liquiwindow.add(pnlEinahmenAufteilung); liquiwindow.setVisible(true); }
public diaAddRirView(Frame arg0, String arg1, boolean arg2) throws ParseException { super(arg0, arg1, arg2); // TODO Auto-generated constructor stub this.setSize(800, 640); this.setLocationRelativeTo(arg0); getContentPane().setLayout(new BorderLayout(0, 0)); m_tabbed = new JTabbedPane(JTabbedPane.TOP); getContentPane().add(m_tabbed, BorderLayout.CENTER); m_panelMetaData = new JPanel(); m_panelMetaData.setBorder( new TitledBorder( null, "Meta Donn\u00E9es et Import Pdf", TitledBorder.LEADING, TitledBorder.TOP, null, null)); JPanel m_pInfo = new JPanel(); m_panelRirInfo = new JPanel(); m_panelRirInfo.setToolTipText(""); m_tabbed.addTab("Informations (Partie 01)", null, m_panelRirInfo, null); m_panelRirInfo.setLayout(new BorderLayout(0, 0)); m_panelRirInfo02 = new JPanel(); m_tabbed.addTab("Informations (Partie 02)", null, m_panelRirInfo02, null); m_panelRirInfo02.setLayout(null); m_pMtp = new JPanel(); m_pMtp.setLayout(null); m_pMtp.setBorder( new TitledBorder( UIManager.getBorder("TitledBorder.border"), "Mtp", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); m_pMtp.setBounds(10, 11, 759, 123); m_panelRirInfo02.add(m_pMtp); m_lMarque = new JLabel("Marque:"); m_lMarque.setBounds(10, 17, 110, 14); m_pMtp.add(m_lMarque); m_lImmatriculation = new JLabel("Immatriculation:"); m_lImmatriculation.setBounds(10, 42, 110, 14); m_pMtp.add(m_lImmatriculation); m_lCouleur = new JLabel("Couleur:"); m_lCouleur.setBounds(10, 98, 110, 14); m_pMtp.add(m_lCouleur); m_tMarque = new JTextField(); m_tMarque.setColumns(10); m_tMarque.setBounds(120, 14, 110, 20); m_pMtp.add(m_tMarque); m_tImmatriculation = new JTextField(); m_tImmatriculation.setColumns(10); m_tImmatriculation.setBounds(120, 39, 110, 20); m_pMtp.add(m_tImmatriculation); m_bAddMtp = new JButton(""); m_bAddMtp.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png"))); m_bAddMtp.setAlignmentX(0.5f); m_bAddMtp.setBounds(250, 31, 65, 50); m_pMtp.add(m_bAddMtp); m_listMtp = new JList(); DefaultListModel mmtp = new DefaultListModel(); m_listMtp.setModel(mmtp); scrollPane_4 = new JScrollPane(m_listMtp); scrollPane_4.setBounds(379, 28, 370, 50); m_pMtp.add(scrollPane_4); m_cCouleurs = new comboCouleur(); m_cCouleurs.setBounds(120, 95, 110, 20); m_pMtp.add(m_cCouleurs); JLabel m_lType = new JLabel("Type:"); m_lType.setBounds(10, 73, 80, 14); m_pMtp.add(m_lType); m_cTypeMtp = new comboTypeMtp(); m_cTypeMtp.setBounds(120, 67, 110, 20); m_pMtp.add(m_cTypeMtp); JPanel m_pContact = new JPanel(); m_pContact.setBorder( new TitledBorder( null, "Contact", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); m_pContact.setBounds(10, 145, 759, 85); m_panelRirInfo02.add(m_pContact); m_pContact.setLayout(null); m_tContact = new JTextField(); m_tContact.setBounds(47, 35, 160, 20); m_pContact.add(m_tContact); m_tContact.setColumns(10); m_bAddContact = new JButton(""); m_bAddContact.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png"))); m_bAddContact.setAlignmentX(0.5f); m_bAddContact.setBounds(250, 21, 65, 50); m_pContact.add(m_bAddContact); m_listContact = new JList(); DefaultListModel mc = new DefaultListModel(); m_listContact.setModel(mc); JScrollPane scrollPane_5 = new JScrollPane(m_listContact); scrollPane_5.setBounds(379, 21, 370, 50); m_pContact.add(scrollPane_5); m_tabbed.addTab("Données à ajouter", null, m_panelMetaData, null); m_panelMetaData.setLayout(new BorderLayout(0, 0)); m_pMeta = new JPanel(); m_panelMetaData.add(m_pMeta, BorderLayout.CENTER); m_pMeta.setLayout(new BorderLayout(0, 0)); m_editorMeta = new JEditorPane(); scrollPane_6 = new JScrollPane(m_editorMeta); m_pMeta.add(scrollPane_6, BorderLayout.CENTER); m_pPdf = new JPanel(); m_pPdf.setBorder( new TitledBorder(null, "Doc Pdf", TitledBorder.LEADING, TitledBorder.TOP, null, null)); m_panelMetaData.add(m_pPdf, BorderLayout.SOUTH); GridBagLayout gbl_m_pPdf = new GridBagLayout(); gbl_m_pPdf.columnWidths = new int[] {171, 0, 0}; gbl_m_pPdf.rowHeights = new int[] {23, 0}; gbl_m_pPdf.columnWeights = new double[] {0.0, 0.0, Double.MIN_VALUE}; gbl_m_pPdf.rowWeights = new double[] {0.0, Double.MIN_VALUE}; m_pPdf.setLayout(gbl_m_pPdf); m_bLoadPdf = new JButton("Pdf"); GridBagConstraints gbc_m_bLoadPdf = new GridBagConstraints(); gbc_m_bLoadPdf.insets = new Insets(0, 0, 0, 5); gbc_m_bLoadPdf.fill = GridBagConstraints.BOTH; gbc_m_bLoadPdf.gridx = 0; gbc_m_bLoadPdf.gridy = 0; m_pPdf.add(m_bLoadPdf, gbc_m_bLoadPdf); m_lPdf = new JLabel(""); GridBagConstraints gbc_m_lPdf = new GridBagConstraints(); gbc_m_lPdf.gridx = 1; gbc_m_lPdf.gridy = 0; m_pPdf.add(m_lPdf, gbc_m_lPdf); m_pInfo.setBackground(Color.GRAY); m_pInfo.setBorder( new TitledBorder(null, "Information", TitledBorder.LEADING, TitledBorder.TOP, null, null)); m_panelRirInfo.add(m_pInfo, BorderLayout.NORTH); GridBagLayout gbl_m_pInfo = new GridBagLayout(); gbl_m_pInfo.columnWidths = new int[] {122, 151, 0, 0, 202, 0}; gbl_m_pInfo.rowHeights = new int[] {0, 0, 0}; gbl_m_pInfo.columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; gbl_m_pInfo.rowWeights = new double[] {0.0, 0.0, Double.MIN_VALUE}; m_pInfo.setLayout(gbl_m_pInfo); JLabel m_lNumero = new JLabel("Num\u00E9ro:"); GridBagConstraints gbc_m_lNumero = new GridBagConstraints(); gbc_m_lNumero.anchor = GridBagConstraints.WEST; gbc_m_lNumero.insets = new Insets(0, 0, 5, 5); gbc_m_lNumero.gridx = 0; gbc_m_lNumero.gridy = 0; m_pInfo.add(m_lNumero, gbc_m_lNumero); m_tNumero = new JFormattedTextField(new MaskFormatter(" ######/####")); m_tNumero.setFont(new Font("Tahoma", Font.BOLD, 12)); GridBagConstraints gbc_m_tNumero = new GridBagConstraints(); gbc_m_tNumero.fill = GridBagConstraints.HORIZONTAL; gbc_m_tNumero.insets = new Insets(0, 0, 5, 5); gbc_m_tNumero.gridx = 1; gbc_m_tNumero.gridy = 0; m_pInfo.add(m_tNumero, gbc_m_tNumero); m_tNumero.setColumns(10); JLabel m_lSource = new JLabel("Source:"); GridBagConstraints gbc_m_lSource = new GridBagConstraints(); gbc_m_lSource.anchor = GridBagConstraints.WEST; gbc_m_lSource.insets = new Insets(0, 0, 5, 5); gbc_m_lSource.gridx = 2; gbc_m_lSource.gridy = 0; m_pInfo.add(m_lSource, gbc_m_lSource); m_cSource = new comboSources(); GridBagConstraints gbc_m_cSource = new GridBagConstraints(); gbc_m_cSource.insets = new Insets(0, 0, 5, 0); gbc_m_cSource.fill = GridBagConstraints.HORIZONTAL; gbc_m_cSource.gridx = 4; gbc_m_cSource.gridy = 0; m_pInfo.add(m_cSource, gbc_m_cSource); JLabel m_lDate = new JLabel("Date:"); GridBagConstraints gbc_m_lDate = new GridBagConstraints(); gbc_m_lDate.anchor = GridBagConstraints.WEST; gbc_m_lDate.insets = new Insets(0, 0, 0, 5); gbc_m_lDate.gridx = 0; gbc_m_lDate.gridy = 1; m_pInfo.add(m_lDate, gbc_m_lDate); m_tDateRir = new JFormattedTextField(new MaskFormatter(" ##/##/####")); m_tDateRir.setFont(new Font("Tahoma", Font.BOLD, 12)); GridBagConstraints gbc_m_tDateRir = new GridBagConstraints(); gbc_m_tDateRir.insets = new Insets(0, 0, 0, 5); gbc_m_tDateRir.fill = GridBagConstraints.HORIZONTAL; gbc_m_tDateRir.gridx = 1; gbc_m_tDateRir.gridy = 1; m_pInfo.add(m_tDateRir, gbc_m_tDateRir); m_tDateRir.setColumns(10); JPanel m_pData = new JPanel(); m_panelRirInfo.add(m_pData, BorderLayout.CENTER); m_pData.setLayout(null); JPanel m_pQuartier = new JPanel(); m_pQuartier.setBorder( new TitledBorder( UIManager.getBorder("TitledBorder.border"), "Quartier", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); m_pQuartier.setBounds(10, 11, 759, 72); m_pData.add(m_pQuartier); m_pQuartier.setLayout(null); m_bAddQuartier = new JButton(""); m_bAddQuartier.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png"))); m_bAddQuartier.setBounds(250, 11, 65, 50); m_bAddQuartier.setAlignmentX(Component.CENTER_ALIGNMENT); m_pQuartier.add(m_bAddQuartier); m_listQuartier = new JList(); DefaultListModel ml = new DefaultListModel(); m_listQuartier.setModel(ml); JScrollPane scrollPane = new JScrollPane(m_listQuartier); scrollPane.setBounds(379, 11, 370, 50); m_pQuartier.add(scrollPane); m_comboQuartiers = new comboQuartiers(); m_comboQuartiers.setBounds(10, 24, 183, 20); m_pQuartier.add(m_comboQuartiers); m_pDrogue = new JPanel(); m_pDrogue.setBorder( new TitledBorder(null, "Drogue", TitledBorder.LEADING, TitledBorder.TOP, null, null)); m_pDrogue.setBounds(10, 97, 759, 72); m_pData.add(m_pDrogue); m_pDrogue.setLayout(null); m_comboDrogues = new comboDrogues(); m_comboDrogues.setBounds(10, 26, 183, 20); m_pDrogue.add(m_comboDrogues); m_bAddDrogue = new JButton(""); m_bAddDrogue.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png"))); m_bAddDrogue.setAlignmentX(0.5f); m_bAddDrogue.setBounds(250, 11, 65, 50); m_pDrogue.add(m_bAddDrogue); m_listDrogue = new JList(); DefaultListModel dl = new DefaultListModel(); m_listDrogue.setModel(dl); JScrollPane scrollPane_1 = new JScrollPane(m_listDrogue); scrollPane_1.setBounds(379, 11, 370, 50); m_pDrogue.add(scrollPane_1); m_pMethode = new JPanel(); m_pMethode.setLayout(null); m_pMethode.setBorder( new TitledBorder( UIManager.getBorder("TitledBorder.border"), "Methode", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); m_pMethode.setBounds(10, 180, 759, 72); m_pData.add(m_pMethode); m_bAddMethode = new JButton(""); m_bAddMethode.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png"))); m_bAddMethode.setSelectedIcon( new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png"))); m_bAddMethode.setAlignmentX(0.5f); m_bAddMethode.setBounds(250, 11, 65, 50); m_pMethode.add(m_bAddMethode); m_listMethode = new JList(); DefaultListModel dlm = new DefaultListModel(); m_listMethode.setModel(dlm); scrollPane_2 = new JScrollPane(m_listMethode); scrollPane_2.setBounds(379, 11, 370, 50); m_pMethode.add(scrollPane_2); m_comboMethodes = new comboMethodes(); m_comboMethodes.setBounds(10, 27, 183, 20); m_pMethode.add(m_comboMethodes); m_pPersonne = new JPanel(); m_pPersonne.setBorder( new TitledBorder(null, "Personne", TitledBorder.LEADING, TitledBorder.TOP, null, null)); m_pPersonne.setBounds(10, 263, 759, 123); m_pData.add(m_pPersonne); m_pPersonne.setLayout(null); JLabel m_lNom = new JLabel("Nom:"); m_lNom.setBounds(10, 17, 110, 14); m_pPersonne.add(m_lNom); JLabel m_lPrenom = new JLabel("Prenom:"); m_lPrenom.setBounds(10, 42, 110, 14); m_pPersonne.add(m_lPrenom); JLabel m_lSurnom = new JLabel("Surnom:"); m_lSurnom.setBounds(10, 67, 110, 14); m_pPersonne.add(m_lSurnom); JLabel m_lDateNaissance = new JLabel("Date de naissance:"); m_lDateNaissance.setBounds(10, 92, 110, 14); m_pPersonne.add(m_lDateNaissance); m_tNom = new JTextField(); m_tNom.setBounds(130, 17, 110, 20); m_pPersonne.add(m_tNom); m_tNom.setColumns(10); m_tPrenom = new JTextField(); m_tPrenom.setBounds(130, 42, 110, 20); m_pPersonne.add(m_tPrenom); m_tPrenom.setColumns(10); m_tSurnom = new JTextField(); m_tSurnom.setBounds(130, 67, 110, 20); m_pPersonne.add(m_tSurnom); m_tSurnom.setColumns(10); m_tDateNaissance = new JFormattedTextField(new MaskFormatter(" ## / ## / ####")); m_tDateNaissance.setBounds(130, 95, 110, 20); m_pPersonne.add(m_tDateNaissance); m_tDateNaissance.setColumns(10); m_bAddPersonne = new JButton(""); m_bAddPersonne.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png"))); m_bAddPersonne.setAlignmentX(0.5f); m_bAddPersonne.setBounds(250, 31, 65, 50); m_pPersonne.add(m_bAddPersonne); m_listPersonne = new JList(); DefaultListModel dlp = new DefaultListModel(); m_listPersonne.setModel(dlp); JScrollPane scrollPane_3 = new JScrollPane(m_listPersonne); scrollPane_3.setBounds(379, 28, 370, 50); m_pPersonne.add(scrollPane_3); m_pButton = new JPanel(); getContentPane().add(m_pButton, BorderLayout.SOUTH); m_pButton.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); m_bWriteRir = new JButton("Enregistrer"); m_bWriteRir.setBackground(Color.GREEN); m_pButton.add(m_bWriteRir); m_bAnnuler = new JButton("Annuler"); m_bAnnuler.setBackground(Color.CYAN); m_pButton.add(m_bAnnuler); // model try { model = new diaAddRirModel(); controller = new diaAddRirControl(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public TelaFolhadePagamento() throws DaoException { setResizable(false); setIconImage( Toolkit.getDefaultToolkit() .getImage(TelaFolhadePagamento.class.getResource("/br/com/images/logo_transp.png"))); setTitle("Folha de Pagamento"); int width = 800; int height = 600; Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - width) / 2; int y = (screen.height - height) / 3; setBounds(x, y, 821, 600); getContentPane().setLayout(null); final JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(UIManager.getColor("Button.background")); buttonPanel.setBounds(0, 0, 152, 562); getContentPane().add(buttonPanel); buttonPanel.setLayout(null); txtPesq = new JXSearchField(); txtPesq.addKeyListener(this); txtPesq.setPrompt("Nome funcionário"); txtPesq.setToolTipText("Digite o nome do funcionário para pesquisar"); txtPesq.setBounds(10, 76, 132, 20); buttonPanel.add(txtPesq); txtPesq.setColumns(10); JLabel lblPesquisar = new JLabel("Pesquisar"); lblPesquisar.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 13)); lblPesquisar.setBounds(40, 58, 79, 14); buttonPanel.add(lblPesquisar); formulario.setBounds(152, 0, 632, 562); getContentPane().add(formulario); formulario.setLayout(null); JPanel panel = new JPanel(); panel.setBorder( new TitledBorder( new TitledBorder( new LineBorder(new Color(0, 0, 0)), "", TitledBorder.LEADING, TitledBorder.TOP, null, null), "Pagamento", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); panel.setLayout(null); panel.setBounds(21, 33, 590, 290); formulario.add(panel); JPopupMenu popupMenu = new JPopupMenu(); addPopup(panel, popupMenu); JMenuItem mntmPesquisarFuncionrio = new JMenuItem("Pesquisar Funcion\u00E1rio"); mntmPesquisarFuncionrio.setIcon( new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/search.png"))); mntmPesquisarFuncionrio.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new ViewSelecionaFuncionario(1); } }); popupMenu.add(mntmPesquisarFuncionrio); JLabel lblNome = new JLabel("Nome:"); lblNome.setHorizontalAlignment(SwingConstants.RIGHT); lblNome.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblNome.setBounds(0, 89, 70, 18); panel.add(lblNome); JLabel lblSalrio = new JLabel("Sal\u00E1rio:"); lblSalrio.setHorizontalAlignment(SwingConstants.RIGHT); lblSalrio.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblSalrio.setBounds(0, 171, 70, 18); panel.add(lblSalrio); JLabel lblProfisso = new JLabel("Profiss\u00E3o:"); lblProfisso.setHorizontalAlignment(SwingConstants.RIGHT); lblProfisso.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblProfisso.setBounds(0, 129, 70, 18); panel.add(lblProfisso); JLabel lbln = new JLabel("N\u00BA:"); lbln.setHorizontalAlignment(SwingConstants.RIGHT); lbln.setFont(new Font("Arial Black", Font.PLAIN, 12)); lbln.setBounds(10, 45, 56, 18); panel.add(lbln); JButton btnSalvar = new JButton(""); btnSalvar.setIcon( new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/salvar.png"))); btnSalvar.setToolTipText("Salvar Alt+S"); btnSalvar.setMnemonic(KeyEvent.VK_S); btnSalvar.setBounds(504, 244, 56, 33); panel.add(btnSalvar); btnSalvar.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (validarFormulário()) { FolhaPagamento obj = new FolhaPagamento(); // obj.setSalarioFunc(Double.parseDouble(MascaraUtil.hideMascaraMoeda(textField_3))); obj.setSalarioFunc(Double.parseDouble(textField_3.getText())); obj.setComissaoFuncTotal(Double.parseDouble(textField_2.getText())); // obj.setBonusFunc(Double.parseDouble(MascaraUtil.hideMascaraMoeda(textField_4))); obj.setBonusFunc(Double.parseDouble(textField_4.getText())); // obj.setTotalFunc(Double.parseDouble(MascaraUtil.hideMascaraMoeda(textField_6))); obj.setTotalFunc(Double.parseDouble(textField_6.getText())); obj.setNomeFunc(textField_9.getText()); obj.setNumFunc(Integer.parseInt(textField.getText())); obj.setProfissaoFunc(textField_1.getText()); SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); try { obj.setDataInicio(df.parse(dateInicio.getEditor().getText())); obj.setDataFim(df.parse(dateFim.getEditor().getText())); } catch (ParseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } FolhadePagamentoDao objDAO = new FolhadePagamentoDao(); try { if (textField_5.getText().equals("")) { objDAO.inserirPagamento(obj); JOptionPane.showMessageDialog(formulario, "Dados salvos com sucesso!"); limpaFormulario(); } else { Integer matr = Integer.parseInt(textField_5.getText()); obj.setCodDep(matr); objDAO.atualizarPagamento(obj); JOptionPane.showMessageDialog(formulario, "Dados atualizados com sucesso!"); } atualizaLista(table, ""); } catch (DaoException e) { e.printStackTrace(); } } } }); JButton btnLimpar = new JButton(""); btnLimpar.setIcon( new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/limpar.png"))); btnLimpar.setToolTipText("Limpar Alt+L"); btnLimpar.setMnemonic(KeyEvent.VK_L); btnLimpar.setBounds(438, 244, 56, 33); panel.add(btnLimpar); btnLimpar.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { limpaFormulario(); } }); textField = new JTextField(); textField.setBounds(80, 45, 127, 20); panel.add(textField); textField.setColumns(10); textField_1 = new JTextField(); textField_1.setBounds(80, 129, 335, 20); panel.add(textField_1); textField_1.setColumns(10); // textField_3 = new JFormattedTextField(MascaraUtil.setMascara("R$####,##")); textField_3 = new JFormattedTextField(); // textField_3.setDocument(new Moeda()); textField_3.setBounds(80, 171, 70, 20); panel.add(textField_3); textField_3.setColumns(10); textField_5 = new JTextField(); textField_5.setVisible(false); textField_5.setText(""); panel.add(textField_5); textField_9 = new JTextField(); textField_9.setBounds(80, 89, 335, 20); panel.add(textField_9); textField_9.setColumns(10); dateInicio = new JXDatePicker(); dateInicio.getEditor().setToolTipText("Data ínicial para calcular a comissão!"); dateInicio.getEditor(); dateInicio.setFormats(new String[] {"dd/MM/yyyy"}); dateInicio.setBounds(258, 171, 97, 20); panel.add(dateInicio); dateFim = new JXDatePicker(); dateFim.getEditor().setToolTipText("Data final para calcular a comissão!"); dateFim.getEditor(); dateFim.setFormats(new String[] {"dd/MM/yyyy"}); dateFim.setBounds(392, 171, 97, 20); // panel.add(dateFim); JButton btnOk = new JButton(""); btnOk.setToolTipText("Procurar funcion\u00E1rio"); btnOk.setIcon( new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/pesquisar.png"))); btnOk.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // PESQUISAR NO BANCO DE DADOS O NÚMERO DO FUNCIONÁRIO String aux1; aux1 = textField.getText(); // if(aux.contains("^[a-Z]")){ //método para verificar se contém letras if (textField.getText().equals("")) { JOptionPane.showMessageDialog(null, "Digite um número!"); } else if (aux1.matches("^[0-9]*$")) { chamaFuncionario(Integer.parseInt(textField.getText())); } else { JOptionPane.showMessageDialog(null, "Digite apenas número!"); } } }); btnOk.setBounds(217, 44, 56, 23); panel.add(btnOk); JLabel lblComisso = new JLabel("Comiss\u00E3o:"); lblComisso.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblComisso.setBounds(0, 212, 80, 14); panel.add(lblComisso); JLabel lblBnus = new JLabel("B\u00F4nus:"); lblBnus.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblBnus.setBounds(185, 212, 50, 14); panel.add(lblBnus); JLabel lblTotal = new JLabel("Total:"); lblTotal.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblTotal.setBounds(24, 257, 46, 14); panel.add(lblTotal); textField_2 = new JTextField(); textField_2.setToolTipText("Comiss\u00E3o calculada"); textField_2.setBounds(80, 210, 70, 20); // textField_2.setDocument(new Moeda()); panel.add(textField_2); textField_2.setColumns(10); // textField_4 = new JFormattedTextField(MascaraUtil.setMascara("R$####,##")); textField_4 = new JTextField(); // textField_4.setDocument(new Moeda()); textField_4.setBounds(245, 210, 80, 20); panel.add(textField_4); textField_4.setColumns(10); // textField_6 = new JFormattedTextField(MascaraUtil.setMascara("R$####,##")); textField_6 = new JTextField(); // textField_6.setDocument(new Moeda()); textField_6.setBounds(80, 255, 70, 20); panel.add(textField_6); textField_6.setColumns(10); JButton btnCalcular = new JButton("Somar tudo"); btnCalcular.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // Calcular quanto o funcionário irá receber // bonus = 0.0; // textField 3(salario) e 4 (bonus) 2 (comissão) if (validarFormulárioCalculo()) { MonthDay inicio = new MonthDay(dateInicio.getDate()); MonthDay fim = new MonthDay(dateFim.getDate()); int mes = Months.monthsBetween(inicio, fim).getMonths(); if (mes >= 2) { salario = Double.parseDouble(textField_3.getText()) * mes; } else { // String aux = textField_4.getText().replace(",", ".").trim(); // bonus = Double.parseDouble(aux); bonus = Double.parseDouble(textField_4.getText()); salario = Double.parseDouble(textField_3.getText()); totalCom = Double.parseDouble(textField_2.getText()); salarioTotal = totalCom + bonus + salario; textField_6.setText(String.valueOf(salarioTotal)); textField_6.setEditable(false); } } } }); btnCalcular.setBounds(343, 209, 89, 23); panel.add(btnCalcular); JLabel lblIncioDoMs = new JLabel("In\u00EDcio do m\u00EAs:"); lblIncioDoMs.setFont(new Font("Arial Black", Font.PLAIN, 11)); lblIncioDoMs.setBounds(160, 174, 95, 14); panel.add(lblIncioDoMs); JLabel lblAt = new JLabel("at\u00E9"); lblAt.setFont(new Font("Arial Black", Font.PLAIN, 11)); lblAt.setBounds(365, 173, 28, 14); panel.add(lblAt); JButton btnCalcular_Com = new JButton("Calcular"); btnCalcular_Com.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { calcularComissao(); } catch (ParseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); btnCalcular_Com.setToolTipText("Calcular comiss\u00E3o"); btnCalcular_Com.setBounds(491, 170, 89, 23); panel.add(btnCalcular_Com); JLabel lblTodosOsCampos = new JLabel("Todos os campos s\u00E3o obrigat\u00F3rios!"); lblTodosOsCampos.setForeground(Color.RED); lblTodosOsCampos.setFont(new Font("Tahoma", Font.PLAIN, 12)); lblTodosOsCampos.setBounds(201, 263, 192, 14); panel.add(lblTodosOsCampos); JButton btnVoltar = new JButton(""); btnVoltar.setIcon( new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/voltar.png"))); btnVoltar.setToolTipText("Voltar"); btnVoltar.setBounds(21, 340, 89, 23); formulario.add(btnVoltar); formulario.setVisible(false); btnVoltar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { lista.setVisible(true); buttonPanel.setVisible(true); formulario.setVisible(false); } }); lista.setBounds(152, 0, 656, 562); getContentPane().add(lista); lista.setLayout(null); JLabel lblFuncionriosCadastrados = new JLabel("Pagamentos Efetuados"); lblFuncionriosCadastrados.setFont(new Font("Kalinga", Font.BOLD, 16)); lblFuncionriosCadastrados.setHorizontalAlignment(SwingConstants.CENTER); lblFuncionriosCadastrados.setBackground(Color.WHITE); lblFuncionriosCadastrados.setBounds(10, 11, 612, 29); lista.add(lblFuncionriosCadastrados); Button Novo = new Button("Adicionar"); Novo.setBounds(10, 530, 70, 22); lista.add(Novo); lista.setVisible(true); buttonPanel.setVisible(true); table = new JTable(); table.addMouseListener( new MouseListener() { @Override public void mouseReleased(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseClicked(MouseEvent arg0) { int linha = table.getSelectedRow(); int coluna = table.getSelectedColumn(); String matricula = (String) table.getValueAt(linha, 0); Integer mat = Integer.parseInt(matricula); if (coluna == 7) { int opcao; opcao = JOptionPane.showConfirmDialog( null, "Deseja excluir o registro de matricula: " + matricula, "Cuidado!!", JOptionPane.YES_NO_OPTION); if (opcao == JOptionPane.YES_OPTION) { try { folhaDao.excluirPagamento(mat); atualizaLista(table, ""); } catch (DaoException e) { // TODO Auto-generated catch block e.printStackTrace(); } JOptionPane.showMessageDialog(null, "Dados excluidos com sucesso!"); } } if (coluna == 5) { FolhaPagamento objFolha = new FolhaPagamento(); try { objFolha = folhaDao.consultarPagamentoID(mat); atualizaFormulario(objFolha); buttonPanel.setVisible(false); } catch (DaoException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // Gera a folha pra imprimir if (coluna == 6) { FolhaControle controle = new FolhaControle(); Funcionario objFunc = new Funcionario(); FolhaPagamento objFolha = new FolhaPagamento(); Integer qntd; String nome = (String) table.getValueAt(linha, 1); try { objFunc = funcDao.procurarFuncionarioNome(nome); objFolha = folhaDao.procurarDataPag(mat); qntd = folhaDao.quantidadePedido(objFunc.getNumFunc()); if (qntd == 0) { controle.gerarRelatorioFolhaSimples( objFunc.getNumFunc(), objFolha.getDataInicio(), objFolha.getDataFim()); } else controle.gerarRelatorioFolha( objFunc.getNumFunc(), objFolha.getDataInicio(), objFolha.getDataFim()); } catch (DaoException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setModel( new DefaultTableModel( new Object[][] {}, new String[] { "Nº", "Nome", "Profissão", "Salário", "Data Pagamento", "Editar", "Relatório", "Excluir" }) { private static final long serialVersionUID = 1L; @Override public boolean isCellEditable(int row, int col) { return false; } }); table.getColumnModel().getColumn(0).setPreferredWidth(35); table.getColumnModel().getColumn(0).setMinWidth(35); table.getColumnModel().getColumn(1).setPreferredWidth(170); table.getColumnModel().getColumn(1).setMinWidth(170); table.getColumnModel().getColumn(2).setPreferredWidth(80); table.getColumnModel().getColumn(2).setMinWidth(80); table.getColumnModel().getColumn(3).setPreferredWidth(50); table.getColumnModel().getColumn(3).setMinWidth(50); table.getColumnModel().getColumn(4).setPreferredWidth(100); table.getColumnModel().getColumn(4).setMinWidth(100); table.getColumnModel().getColumn(5).setPreferredWidth(40); table.getColumnModel().getColumn(5).setMinWidth(40); table.getColumnModel().getColumn(6).setPreferredWidth(50); table.getColumnModel().getColumn(6).setMinWidth(50); table.getColumnModel().getColumn(7).setPreferredWidth(40); table.getColumnModel().getColumn(7).setMinWidth(40); table.setBounds(39, 175, 530, 232); atualizaLista(table, ""); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(10, 51, 636, 473); lista.add(scrollPane); scrollPane.setViewportView(table); Novo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { lista.setVisible(false); formulario.setVisible(true); buttonPanel.setVisible(false); limpaFormulario(); try { atualizaLista(table, ""); } catch (DaoException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); }
/** Create the frame. */ public GIncidencia() { setIconImage( Toolkit.getDefaultToolkit() .getImage( GIncidencia.class.getResource("/javax/swing/plaf/basic/icons/JavaCup16.png"))); setResizable(false); setTitle(" Ingresar Nueva GIncidencia"); setBounds(100, 100, 887, 575); getContentPane().setLayout(null); lblMensListado2 = new JLabel(""); lblMensListado2.setFont(new Font("Tahoma", Font.PLAIN, 13)); lblMensListado2.setVisible(false); lblMensListado2.setBounds(349, 64, 346, 19); getContentPane().add(lblMensListado2); lblMensListado1 = new JLabel(""); lblMensListado1.setVisible(false); lblMensListado1.setFont(new Font("Tahoma", Font.PLAIN, 13)); lblMensListado1.setBounds(10, 64, 319, 19); getContentPane().add(lblMensListado1); panel = new JPanel(); panel.setVisible(false); panel.setBounds(10, 11, 319, 515); panel.setBackground(new Color(51, 102, 153)); panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); getContentPane().add(panel); panel.setLayout(null); btnListado = new JButton("LISTAR"); btnListado.setVisible(false); btnListado.setBackground(SystemColor.controlShadow); btnListado.addActionListener(this); btnListado.setIcon( new ImageIcon( GIncidencia.class.getResource("/com/sun/java/swing/plaf/motif/icons/Warn.gif"))); Incidencia = new JScrollPane(); Incidencia.setVisible(false); Incidencia.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null)); Incidencia.setBounds(339, 103, 522, 388); getContentPane().add(Incidencia); txtIncidencia = new JTextArea(); txtIncidencia.setFont(new Font("Arial", Font.PLAIN, 17)); txtIncidencia.setToolTipText(""); Incidencia.setViewportView(txtIncidencia); btnLimpiar = new JButton("LIMPIAR"); btnLimpiar.setVisible(false); btnBuscar = new JButton("BUSCAR"); btnBuscar.setVisible(false); btnNuevo = new JButton("NUEVO"); btnNuevo.setVisible(false); btnNuevo.setIcon( new ImageIcon( GIncidencia.class.getResource("/com/sun/java/swing/plaf/windows/icons/File.gif"))); btnNuevo.setBackground(SystemColor.controlShadow); btnNuevo.setBounds(339, 11, 228, 33); getContentPane().add(btnNuevo); btnNuevo.addActionListener(this); btnBuscar.setBackground(SystemColor.controlShadow); btnBuscar.setIcon( new ImageIcon( GIncidencia.class.getResource("/com/sun/java/swing/plaf/windows/icons/Directory.gif"))); btnBuscar.setBounds(339, 11, 228, 33); getContentPane().add(btnBuscar); btnBuscar.addActionListener(this); btnLimpiar.setIcon( new ImageIcon(GIncidencia.class.getResource("/javax/swing/plaf/metal/icons/sortDown.png"))); btnLimpiar.setBackground(SystemColor.controlShadow); btnLimpiar.setBounds(633, 11, 228, 33); getContentPane().add(btnLimpiar); btnLimpiar.addActionListener(this); btnRegistrar = new JButton("REGISTRAR"); btnRegistrar.setVisible(false); btnRegistrar.setIcon( new ImageIcon( GIncidencia.class.getResource( "/com/sun/javafx/webkit/prism/resources/mediaPlayDisabled.png"))); btnRegistrar.setBackground(SystemColor.controlShadow); btnRegistrar.setBounds(339, 55, 522, 37); getContentPane().add(btnRegistrar); btnRegistrar.addActionListener(this); btnModificar = new JButton("MODIFICAR"); btnModificar.setVisible(false); btnModificar.setIcon( new ImageIcon( GIncidencia.class.getResource( "/com/sun/javafx/scene/control/skin/caspian/dialog-more-details.png"))); btnModificar.setBackground(SystemColor.controlShadow); btnModificar.setBounds(339, 55, 522, 37); getContentPane().add(btnModificar); btnModificar.addActionListener(this); btnListado.setBounds(10, 11, 260, 37); getContentPane().add(btnListado); JSeparator separator = new JSeparator(); separator.setBounds(10, 111, 299, 7); panel.add(separator); JSeparator separator_1 = new JSeparator(); separator_1.setBounds(10, 294, 299, 14); panel.add(separator_1); JLabel lblNewLabel = new JLabel("CODIGO DE USUARIO:"); lblNewLabel.setForeground(Color.WHITE); lblNewLabel.setBounds(10, 36, 172, 14); panel.add(lblNewLabel); JLabel lblCodigo = new JLabel("CODIGO DE INCIDENCIA: "); lblCodigo.setForeground(Color.WHITE); lblCodigo.setBounds(10, 11, 172, 14); panel.add(lblCodigo); txtCodigo = new JTextField(); txtCodigo.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtCodigo.setHorizontalAlignment(SwingConstants.RIGHT); txtCodigo.setBackground(SystemColor.controlShadow); txtCodigo.setEditable(false); txtCodigo.setBounds(203, 9, 106, 17); panel.add(txtCodigo); txtCodigo.setColumns(10); txtCodUsu = new JTextField(); txtCodUsu.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtCodUsu.setHorizontalAlignment(SwingConstants.RIGHT); txtCodUsu.setBackground(SystemColor.controlShadow); txtCodUsu.setEditable(false); txtCodUsu.setColumns(10); txtCodUsu.setBounds(203, 34, 106, 17); panel.add(txtCodUsu); JLabel lblCodigoDeEspecialista = new JLabel("CODIGO DE ESPECIALISTA:"); lblCodigoDeEspecialista.setForeground(Color.WHITE); lblCodigoDeEspecialista.setBounds(10, 61, 172, 14); panel.add(lblCodigoDeEspecialista); JLabel lblCodigoDeTipo = new JLabel("CODIGO DE TIPO DE INCIDENCIA:"); lblCodigoDeTipo.setForeground(Color.WHITE); lblCodigoDeTipo.setBounds(10, 86, 188, 14); panel.add(lblCodigoDeTipo); JLabel lblDescripcion = new JLabel("DESCRIPCION:"); lblDescripcion.setForeground(Color.WHITE); lblDescripcion.setBounds(10, 115, 110, 14); panel.add(lblDescripcion); JLabel lblComentariosObservaciones = new JLabel("COMENTARIOS / OBSERVACIONES:"); lblComentariosObservaciones.setForeground(Color.WHITE); lblComentariosObservaciones.setBounds(10, 198, 188, 28); panel.add(lblComentariosObservaciones); JLabel lblTiempoEstimadoDe = new JLabel("TIEMPO ESTIMADO DE SOLUCION:"); lblTiempoEstimadoDe.setForeground(Color.WHITE); lblTiempoEstimadoDe.setBounds(10, 309, 203, 14); panel.add(lblTiempoEstimadoDe); txtTiempoEstimado = new JTextField(); txtTiempoEstimado.addKeyListener(this); txtTiempoEstimado.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtTiempoEstimado.setHorizontalAlignment(SwingConstants.RIGHT); txtTiempoEstimado.setColumns(10); txtTiempoEstimado.setBounds(215, 306, 94, 17); panel.add(txtTiempoEstimado); JLabel lblTiempoRealDe = new JLabel("TIEMPO REAL DE SOLUCION:"); lblTiempoRealDe.setForeground(Color.WHITE); lblTiempoRealDe.setBounds(10, 337, 172, 14); panel.add(lblTiempoRealDe); txtTiempoReal = new JTextField(); txtTiempoReal.addKeyListener(this); txtTiempoReal.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtTiempoReal.setHorizontalAlignment(SwingConstants.RIGHT); txtTiempoReal.setColumns(10); txtTiempoReal.setBounds(215, 334, 94, 17); panel.add(txtTiempoReal); JLabel lblFechaDeRegistro = new JLabel("FECHA DE REGISTRO:"); lblFechaDeRegistro.setForeground(Color.WHITE); lblFechaDeRegistro.setBounds(10, 365, 172, 14); panel.add(lblFechaDeRegistro); txtFecRegistro = new JTextField(); txtFecRegistro.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtFecRegistro.setHorizontalAlignment(SwingConstants.RIGHT); txtFecRegistro.setBackground(SystemColor.controlShadow); txtFecRegistro.setEditable(false); txtFecRegistro.setColumns(10); txtFecRegistro.setBounds(181, 362, 128, 17); panel.add(txtFecRegistro); JLabel lblFechaDeInicio = new JLabel("FECHA DE INICIO DE ATENCION:"); lblFechaDeInicio.setForeground(Color.WHITE); lblFechaDeInicio.setBounds(10, 393, 188, 14); panel.add(lblFechaDeInicio); try { MaskFormatter mascara = new MaskFormatter("##-##-####"); mascara.setPlaceholderCharacter(' '); txtFecInicio = new JFormattedTextField(mascara); txtFecInicio.setHorizontalAlignment(SwingConstants.RIGHT); txtFecInicio.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtFecInicio.setBounds(215, 390, 100, 17); panel.add(txtFecInicio); } catch (Exception e) { e.printStackTrace(); } JLabel lblFechaDeFin = new JLabel("FECHA FINAL DE ATENCION:"); lblFechaDeFin.setForeground(Color.WHITE); lblFechaDeFin.setBounds(10, 421, 172, 14); panel.add(lblFechaDeFin); try { MaskFormatter mascara = new MaskFormatter("##-##-####"); mascara.setPlaceholderCharacter(' '); txtFecFinal = new JFormattedTextField(mascara); txtFecFinal.setHorizontalAlignment(SwingConstants.RIGHT); txtFecFinal.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtFecFinal.setBounds(215, 418, 100, 17); panel.add(txtFecFinal); } catch (Exception e) { e.printStackTrace(); } JLabel lblEstado = new JLabel("ESTADO:"); lblEstado.setForeground(Color.WHITE); lblEstado.setBounds(10, 449, 86, 14); panel.add(lblEstado); cboEstado = new JComboBox(); cboEstado.setFont(new Font("Tahoma", Font.PLAIN, 13)); cboEstado.setBackground(UIManager.getColor("Button.background")); cboEstado.setModel( new DefaultComboBoxModel(new String[] {"Registrada", "Iniciada", "Cancelada", "Cerrada"})); cboEstado.setBounds(137, 446, 172, 20); panel.add(cboEstado); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBounds(10, 129, 299, 69); panel.add(scrollPane_1); txtDescripcion = new JTextArea(); txtDescripcion.addKeyListener(this); txtDescripcion.setFont(new Font("Arial", Font.PLAIN, 19)); scrollPane_1.setViewportView(txtDescripcion); JScrollPane scrollPane_2 = new JScrollPane(); scrollPane_2.setBounds(10, 220, 299, 69); panel.add(scrollPane_2); txtObservacion = new JTextArea(); txtObservacion.addKeyListener(this); txtObservacion.setFont(new Font("Arial", Font.PLAIN, 19)); scrollPane_2.setViewportView(txtObservacion); cboEspecialista = new JComboBox(); cboEspecialista.setFont(new Font("Tahoma", Font.PLAIN, 13)); cboEspecialista.setBounds(203, 58, 106, 20); cboEspecialista.addItem(""); panel.add(cboEspecialista); cboTipoInc = new JComboBox(); cboTipoInc.setFont(new Font("Tahoma", Font.PLAIN, 13)); cboTipoInc.setBounds(203, 83, 106, 20); cboTipoInc.addItem(""); panel.add(cboTipoInc); btnImprimir = new JButton("IMPRIMIR"); btnImprimir.addActionListener(this); btnImprimir.setIcon( new ImageIcon(GIncidencia.class.getResource("/sun/print/resources/orientLandscape.png"))); btnImprimir.setBounds(633, 493, 228, 33); getContentPane().add(btnImprimir); Listado = new JScrollPane(TablaIncidencias); Listado.setVisible(false); Listado.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null)); JViewport viewport = new JViewport(); Listado.setRowHeaderView(viewport); Listado.setBounds(10, 99, 861, 347); getContentPane().add(Listado); TablaIncidencias = new JTable(); TablaIncidencias.setFont(new Font("Tahoma", Font.PLAIN, 13)); TablaIncidencias.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); Listado.setViewportView(TablaIncidencias); columnas(); tamañoColumnas(); llenaCampos(); }
private void jbInit() throws Exception { this.setJMenuBar(menuBar); this.getContentPane().setLayout(layoutMain); panelCenter.setLayout(null); this.setTitle("Facturas Taxi. Mariano y Conchi"); menuFile.setText("Archivo"); menuFileExit.setText("Salir"); menuFileExit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { fileExit_ActionPerformed(ae); } }); menuHelp.setText("Ayuda"); menuHelpAbout.setText("Sobre"); menuHelpAbout.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { helpAbout_ActionPerformed(ae); } }); statusBar.setText(""); buttonOpen.setToolTipText("Abrir Ficha Cliente"); buttonOpen.setIcon(imageOpen); buttonOpen.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { abrirFicheroExpediente(); } }); buttonClose.setToolTipText("Guardar Ficha Cliente"); buttonClose.setIcon(imageClose); buttonClose.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (validarMinimosRellenos()) { preguntarGuardar(); } } }); buttonHelp.setToolTipText("About"); buttonHelp.setIcon(imageHelp); jPanel1.setBounds(new Rectangle(-5, 0, 530, 165)); jPanel1.setLayout(null); jTable1.setShowGrid(true); jScrollPane1.setBounds(new Rectangle(0, 135, 490, 135)); jScrollPane1.setBounds(new Rectangle(125, 135, 2, 2)); jButton1.setText("Imprimir"); jButton1.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { imprimirjButton_mouseClicked(e); } }); insertarjButton.setText("Insertar Fila"); insertarjButton.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { insertarjButton_mouseClicked(e); } }); ponerTextoLabel(jLabelNombreCompanyia, nombreCompanyiajTextField1, "Nombre Compañía"); jLabelNombreCompanyia.setBounds(new Rectangle(10, 5, 95, 20)); nombreCompanyiajTextField1.setBounds( jLabelNombreCompanyia.getX() + jLabelNombreCompanyia.getWidth(), jLabelNombreCompanyia.getY(), 270, jLabelNombreCompanyia.getHeight()); ponerTextoLabel(jLabelNumeroFactura, numeroFacturajTextField1, "Nº Factura"); jLabelNumeroFactura.setBounds( new Rectangle( nombreCompanyiajTextField1.getX() + nombreCompanyiajTextField1.getWidth() + SEPARACION_X, nombreCompanyiajTextField1.getY(), 60, jLabelNombreCompanyia.getHeight())); numeroFacturajTextField1.setBounds( new Rectangle( jLabelNumeroFactura.getX() + jLabelNumeroFactura.getWidth(), nombreCompanyiajTextField1.getY(), 65, jLabelNombreCompanyia.getHeight())); ponerTextoLabel(jLabelDireccion, direccionCompnanyia, "Dirección"); jLabelDireccion.setBounds( new Rectangle( jLabelNombreCompanyia.getX(), jLabelNombreCompanyia.getHeight() + SEPARACION_Y, 155, jLabelNombreCompanyia.getHeight())); // direccionCompnanyia.setBounds(new // Rectangle(nombreCompanyiajTextField1.getX(), jLabelDireccion.getY(), // 350, 40)); scrollPane.setBounds(nombreCompanyiajTextField1.getX(), jLabelDireccion.getY(), 155, 60); ponerTextoLabel(jLabel6Ciudad, ciudadjTextField, "Ciudad"); jLabel6Ciudad.setBounds( new Rectangle( jLabelDireccion.getX(), scrollPane.getY() + scrollPane.getHeight() + SEPARACION_Y, 50, jLabelNombreCompanyia.getHeight())); ciudadjTextField.setBounds( new Rectangle( jLabel6Ciudad.getX() + jLabel6Ciudad.getWidth(), jLabel6Ciudad.getY(), 110, jLabelNombreCompanyia.getHeight())); ponerTextoLabel(jLabel7CP, codigoPostaljTextField, "CP"); jLabel7CP.setBounds( new Rectangle( ciudadjTextField.getX() + ciudadjTextField.getWidth() + SEPARACION_X, ciudadjTextField.getY(), 45, jLabelNombreCompanyia.getHeight())); codigoPostaljTextField.setBounds( new Rectangle( jLabel7CP.getX() + jLabel7CP.getWidth(), jLabel7CP.getY(), 85, jLabelNombreCompanyia.getHeight())); ponerTextoLabel(jLabelFecha, fechajTextField, "Fecha de Facturación"); jLabelFecha.setBounds( new Rectangle( codigoPostaljTextField.getX() + codigoPostaljTextField.getWidth() + SEPARACION_X, codigoPostaljTextField.getY(), 110, jLabelNombreCompanyia.getHeight())); fechajTextField.setBounds( new Rectangle( jLabelFecha.getX() + jLabelFecha.getWidth(), jLabelFecha.getY(), 70, jLabelNombreCompanyia.getHeight())); ponerTextoLabel(jLabel8Telefono, telefonojTextField, "Teléfono"); jLabel8Telefono.setBounds( new Rectangle( jLabel6Ciudad.getX(), jLabel6Ciudad.getY() + jLabel6Ciudad.getHeight() + SEPARACION_Y, jLabel6Ciudad.getWidth(), jLabel6Ciudad.getHeight())); telefonojTextField.setBounds( new Rectangle( jLabel8Telefono.getX() + jLabel8Telefono.getWidth(), jLabel8Telefono.getY(), ciudadjTextField.getWidth(), jLabelNombreCompanyia.getHeight())); // telefonojTextField.setDocument( new VentanaPrincipal(13)); ponerTextoLabel(jLabelCIF, cifjTextField2, "CIF/NIF"); jLabelCIF.setBounds( new Rectangle( telefonojTextField.getX() + telefonojTextField.getWidth() + SEPARACION_X, jLabel8Telefono.getY(), 45, jLabelNombreCompanyia.getHeight())); cifjTextField2.setBounds( new Rectangle( jLabelCIF.getX() + jLabelCIF.getWidth(), jLabelCIF.getY(), codigoPostaljTextField.getWidth(), jLabelNombreCompanyia.getHeight())); jScrollPaneTabla.setBounds( new Rectangle( jLabel8Telefono.getX(), jLabelCIF.getY() + jLabelCIF.getHeight() + SEPARACION_Y, 505, 175)); insertarjButton.setBounds( new Rectangle( 200, jScrollPaneTabla.getY() + jScrollPaneTabla.getHeight() + SEPARACION_Y, 130, 20)); this.setSize(new Dimension(531, 451)); menuFile.add(menuFileExit); menuBar.add(menuFile); menuHelp.add(menuHelpAbout); menuBar.add(menuHelp); this.getContentPane().add(statusBar, BorderLayout.SOUTH); toolBar.add(buttonOpen); toolBar.add(buttonClose); toolBar.add(buttonHelp); toolBar.add(jButton1, null); this.getContentPane().add(toolBar, BorderLayout.NORTH); this.getContentPane().add(panelCenter, BorderLayout.CENTER); jPanel1.add(jLabel8Telefono, null); jPanel1.add(codigoPostaljTextField, null); jPanel1.add(jLabel7CP, null); jPanel1.add(jLabel6Ciudad, null); jPanel1.add(ciudadjTextField, null); jPanel1.add(jScrollPane1, null); jPanel1.add(cifjTextField2, null); jPanel1.add(jLabelCIF, null); jPanel1.add(fechajTextField, null); jPanel1.add(jLabelFecha, null); jPanel1.add(numeroFacturajTextField1, null); jPanel1.add(jLabelNumeroFactura, null); jPanel1.add(jLabelNombreCompanyia, null); jPanel1.add(nombreCompanyiajTextField1, null); jPanel1.add(jLabelDireccion, null); // jTable1 // _panelScroll.add(jTable1); // jPanel1.add(scrollPane, new GridBagConstraints(3, 0, 1, 1, 1.0, 1.0, // GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, // 140, 70), 0, 0)); // scrollPane.setBounds(nombreCompanyiajTextField1.getX(), 30, 155, 40); jPanel1.add(scrollPane, null); jPanel1.add(telefonojTextField, null); panelCenter.add(jScrollPane1, null); jScrollPaneTabla.getViewport().add(jTable1, null); panelCenter.add(insertarjButton, null); panelCenter.add(jScrollPaneTabla, null); panelCenter.add(jPanel1, null); ajustarCamposTable(jTable1); }
public CadFornecedor() throws DaoException { setResizable(false); setIconImage( Toolkit.getDefaultToolkit() .getImage(CadFornecedor.class.getResource("/br/com/images/logo_sys.png"))); setTitle("Cadastro de Fornecedores"); // setIconImage(Toolkit.getDefaultToolkit().getImage(CadFuncionario.class.getResource("/br/com/images/cadForm.jpg"))); int width = 800; int height = 600; setModal(true); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - width) / 2; int y = (screen.height - height) / 3; setBounds(x, y, 821, 600); getContentPane().setLayout(null); final JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(UIManager.getColor("Button.background")); buttonPanel.setBounds(0, 0, 152, 562); getContentPane().add(buttonPanel); buttonPanel.setLayout(null); JLabel lblPesquisar = new JLabel("Pesquisar"); lblPesquisar.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 13)); lblPesquisar.setBounds(40, 66, 75, 14); buttonPanel.add(lblPesquisar); txtPesq = new JXSearchField(); txtPesq.addKeyListener(this); txtPesq.setFont(new Font("Tahoma", Font.PLAIN, 11)); txtPesq.setPrompt("Nome do fornecedor"); txtPesq.setToolTipText("Digite o nome do fornecedor"); txtPesq.setBounds(0, 84, 152, 20); buttonPanel.add(txtPesq); txtPesq.setColumns(10); formulario.setBounds(152, 0, 632, 562); getContentPane().add(formulario); formulario.setLayout(null); JPanel panel = new JPanel(); panel.setBorder( new TitledBorder( new TitledBorder( new LineBorder(new Color(0, 0, 0)), "", TitledBorder.LEADING, TitledBorder.TOP, null, null), "Dados pessoais", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); panel.setLayout(null); panel.setBounds(21, 35, 590, 288); formulario.add(panel); JLabel lblnome = new JLabel("*Nome:"); lblnome.setHorizontalAlignment(SwingConstants.RIGHT); lblnome.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblnome.setBounds(12, 31, 70, 18); panel.add(lblnome); JLabel lbltelefone = new JLabel("*Telefone:"); lbltelefone.setHorizontalAlignment(SwingConstants.RIGHT); lbltelefone.setFont(new Font("Arial Black", Font.PLAIN, 12)); lbltelefone.setBounds(12, 60, 70, 18); panel.add(lbltelefone); JLabel lblrua = new JLabel("*Rua:"); lblrua.setHorizontalAlignment(SwingConstants.RIGHT); lblrua.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblrua.setBounds(12, 89, 70, 18); panel.add(lblrua); JLabel lbln = new JLabel("*N\u00BA:"); lbln.setHorizontalAlignment(SwingConstants.RIGHT); lbln.setFont(new Font("Arial Black", Font.PLAIN, 12)); lbln.setBounds(356, 89, 50, 18); panel.add(lbln); JLabel lblbairro = new JLabel("*Bairro:"); lblbairro.setHorizontalAlignment(SwingConstants.RIGHT); lblbairro.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblbairro.setBounds(12, 147, 70, 18); panel.add(lblbairro); JLabel lblcidade = new JLabel("*Cidade:"); lblcidade.setHorizontalAlignment(SwingConstants.RIGHT); lblcidade.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblcidade.setBounds(12, 176, 70, 18); panel.add(lblcidade); JLabel lblcep = new JLabel("*CEP:"); lblcep.setHorizontalAlignment(SwingConstants.RIGHT); lblcep.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblcep.setBounds(12, 205, 70, 18); panel.add(lblcep); JButton button = new JButton(""); button.setToolTipText("Salvar Alt+S"); button.setMnemonic(KeyEvent.VK_S); button.setIcon(new ImageIcon(CadFornecedor.class.getResource("/br/com/images/salvar.png"))); button.setBounds(491, 242, 63, 35); panel.add(button); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (validarFormulário()) { Fornecedor obj = new Fornecedor(); obj.setTelFornec(textField_2.getText()); obj.setRuaFornec(textField_4.getText()); obj.setNumEndFornec(textField_6.getText()); obj.setBairroFornec(textField_7.getText()); obj.setCidadeFornec(textField_8.getText()); obj.setNomeFornec(textField.getText()); obj.setCepFornec(textField_3.getText()); obj.setComplFornec(textField_9.getText()); FornecedorDao objDAO = new FornecedorDao(); try { if (textField_5.getText().equals("")) { objDAO.inserirFornecedores(obj); JOptionPane.showMessageDialog(formulario, "Dados salvos com sucesso!"); limpaFormulario(); } else { Integer matr = Integer.parseInt(textField_5.getText()); obj.setNumFornec(matr); objDAO.atualizarFornecedor(obj); JOptionPane.showMessageDialog(formulario, "Dados atualizados com sucesso!"); } atualizaLista(table, ""); } catch (DaoException e) { e.printStackTrace(); } } } }); JButton button_1 = new JButton(""); button_1.setIcon(new ImageIcon(CadFornecedor.class.getResource("/br/com/images/limpar.png"))); button_1.setMnemonic(KeyEvent.VK_L); button_1.setToolTipText("Limpar Alt+L"); button_1.setBounds(418, 242, 63, 35); panel.add(button_1); button_1.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { limpaFormulario(); } }); textField = new JTextField(); textField.setBounds(92, 31, 389, 20); panel.add(textField); textField.setColumns(10); try { textField_2 = new JFormattedTextField(MascaraUtil.setMaskTelefoneInTf(textField_2)); } catch (ParseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } textField_2.setBounds(92, 60, 127, 20); panel.add(textField_2); textField_2.setColumns(10); try { textField_3 = new JFormattedTextField(MascaraUtil.setMaskCepInTf(textField_3)); } catch (ParseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } textField_3.setBounds(92, 205, 127, 20); panel.add(textField_3); textField_3.setColumns(10); textField_4 = new JTextField(); textField_4.setBounds(92, 89, 254, 20); panel.add(textField_4); textField_4.setColumns(10); textField_6 = new JTextField(); textField_6.setBounds(411, 89, 70, 20); panel.add(textField_6); textField_6.setColumns(10); textField_7 = new JTextField(); textField_7.setBounds(92, 147, 254, 20); panel.add(textField_7); textField_7.setColumns(10); textField_8 = new JTextField(); textField_8.setBounds(92, 176, 254, 20); panel.add(textField_8); textField_8.setColumns(10); textField_5 = new JTextField(); textField_5.setVisible(false); textField_5.setText(""); panel.add(textField_5); JLabel lblTodosOsCampos = new JLabel("*Campos obrigat\u00F3rios!"); lblTodosOsCampos.setForeground(new Color(255, 0, 0)); lblTodosOsCampos.setFont(new Font("Tahoma", Font.PLAIN, 12)); lblTodosOsCampos.setBounds(122, 257, 206, 14); panel.add(lblTodosOsCampos); JLabel lblComplemento = new JLabel("Compl.:"); lblComplemento.setHorizontalAlignment(SwingConstants.RIGHT); lblComplemento.setFont(new Font("Arial Black", Font.PLAIN, 12)); lblComplemento.setBounds(12, 118, 70, 18); panel.add(lblComplemento); textField_9 = new JTextField(); textField_9.setBounds(91, 116, 255, 20); panel.add(textField_9); textField_9.setColumns(10); JButton btnVoltar = new JButton(""); btnVoltar.setIcon(new ImageIcon(CadFornecedor.class.getResource("/br/com/images/voltar.png"))); btnVoltar.setToolTipText("Voltar"); btnVoltar.setBounds(21, 340, 89, 23); formulario.add(btnVoltar); lista.setBounds(152, 0, 656, 562); getContentPane().add(lista); lista.setLayout(null); JLabel lblFuncionriosCadastrados = new JLabel("Fornecedores Cadastrados"); lblFuncionriosCadastrados.setFont(new Font("Kalinga", Font.BOLD, 16)); lblFuncionriosCadastrados.setHorizontalAlignment(SwingConstants.CENTER); lblFuncionriosCadastrados.setBackground(Color.WHITE); lblFuncionriosCadastrados.setBounds(10, 11, 612, 29); lista.add(lblFuncionriosCadastrados); Button Novo = new Button("Adicionar"); Novo.setBounds(10, 530, 70, 22); lista.add(Novo); lista.setVisible(true); table = new JTable(); table.addMouseListener( new MouseListener() { @Override public void mouseReleased(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseClicked(MouseEvent arg0) { int linha = table.getSelectedRow(); int coluna = table.getSelectedColumn(); String matricula = (String) table.getValueAt(linha, 0); Integer mat = Integer.parseInt(matricula); if (coluna == 4) { int opcao; opcao = JOptionPane.showConfirmDialog( null, "Deseja excluir o fornecedor de matricula: " + matricula, "Cuidado!!", JOptionPane.YES_NO_OPTION); if (opcao == JOptionPane.YES_OPTION) { try { fornecDao.excluirFornecedores(mat); atualizaLista(table, ""); } catch (DaoException e) { // TODO Auto-generated catch block e.printStackTrace(); } JOptionPane.showMessageDialog(null, "Dados excluídos com sucesso!"); } } if (coluna == 3) { Fornecedor objFornec = new Fornecedor(); try { objFornec = fornecDao.consultarFornecedorID(mat); atualizaFormulario(objFornec); buttonPanel.setVisible(false); } catch (DaoException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setModel( new DefaultTableModel( new Object[][] {}, new String[] {"Número", "Nome", "Telefone", "Editar", "Excluir"}) { private static final long serialVersionUID = 1L; @Override public boolean isCellEditable(int row, int col) { return false; } }); table.getColumnModel().getColumn(0).setPreferredWidth(55); table.getColumnModel().getColumn(0).setMinWidth(55); table.getColumnModel().getColumn(1).setPreferredWidth(220); table.getColumnModel().getColumn(1).setMinWidth(220); table.getColumnModel().getColumn(2).setPreferredWidth(80); table.getColumnModel().getColumn(2).setMinWidth(80); table.getColumnModel().getColumn(3).setPreferredWidth(70); table.getColumnModel().getColumn(3).setMinWidth(70); table.getColumnModel().getColumn(4).setPreferredWidth(60); table.getColumnModel().getColumn(4).setMinWidth(60); table.setBounds(39, 175, 530, 232); atualizaLista(table, ""); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(10, 51, 636, 473); lista.add(scrollPane); scrollPane.setViewportView(table); Novo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { lista.setVisible(false); formulario.setVisible(true); buttonPanel.setVisible(false); limpaFormulario(); try { atualizaLista(table, ""); } catch (DaoException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); formulario.setVisible(false); btnVoltar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { lista.setVisible(true); formulario.setVisible(false); buttonPanel.setVisible(true); } }); }