Pessoal, Não estou conseguindo gravar os dados do meu formulário no arquivo txt.
importação java.awt.Color;
importação java.awt.EventQueue;
importação java.awt.Label;
importação java.awt.TextField;
importação java.awt.event.ActionEvent;
importação java.awt.event.ActionListener;
importação javax.swing.DefaultComboBoxModel;
importação javax.swing.ImageIcon;
importação javax.swing.JButton;
importação javax.swing.JCheckBox;
importação javax.swing.JComboBox;
importação javax.swing.JFrame;
importação javax.swing.JLabel;
importação javax.swing.JMenuBar;
importação javax.swing.JMenuItem;
importação javax.swing.JOptionPane;
importação javax.swing.UIManager;
PROJETOJAVA classe pública {
quadro JFrame privado;
/ **
* Inicie o aplicativo.
* /
main (String [] args) public static void {
EventQueue.invokeLater (new Runnable () {
public void run () {
experimentar {
PROJETOJAVA janela = new PROJETOJAVA ();
window.frame.setVisible (true);
} Catch (Exception e) {
e.printStackTrace ();
}
}
});
}
/ **
* Criar a aplicação.
* /
PROJETOJAVA pública () {
inicializar();
}
/ **
* Inicializar o conteúdo do quadro.
* /
private void initialize () {
ImageIcon Fundo = new ImageIcon (getClass () getResource ( "fundo.jpg").);
frame = new JFrame ();
. Frame.getContentPane () setBackground (Color.White);
frame.setBounds (100, 100, 1055, 503);
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar ();
frame.setJMenuBar (menuBar);
// NÃO INTERESSA
JMenuItem mntmArquivo = new JMenuItem ( "Arquivo");
menuBar.add (mntmArquivo);
// NAO
JMenuItem mntmAjuda = new JMenuItem ( "Ajuda");
menuBar.add (mntmAjuda);
// BOTÕES Implamentar
JButton botao1 = new JButton ( "Agendar");
botao1.setBounds (421, 406, 86, 23);
botao1.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent e) {
Se (e.getSource () == botao1) {
JOptionPane.showMessageDialog (null, "Obrigado, Consulta agendada com Sucesso");
}
}
});
botao1.setBackground (UIManager.getColor ( "Tree.selectionBackground"));
// Implementar
JButton botao2 = new JButton ( "Sair");
botao2.setBounds (539, 406, 66, 23);
botao2.setForeground (UIManager.getColor ( "ToolBar.dockingForeground"));
botao2.setBackground (UIManager.getColor ( "ToolBar.dockingForeground"));
botao2.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent e) {
Se (e.getSource () == botao2) {
JOptionPane.showMessageDialog (null, "Deseja Sair Desta Operação?", "Finalizar", JOptionPane.YES_NO_OPTION);
}
}
});
JLabel lblNome = new JLabel ( "Nome:");
lblNome.setBounds (52, 180, 50, 14);
frame.getContentPane () setLayout (null).;
. Frame.getContentPane () add (botao1);
Etiqueta label = new Label ( "E-mail");
label.setBounds (52, 231, 62, 22);
. Frame.getContentPane () adicionar (etiqueta);
. Frame.getContentPane () add (botao2);
frame.getContentPane () add (lblNome.);
JLabel lblCpf = new JLabel ( "Documentos");
lblCpf.setBounds (36, 274, 75, 14);
frame.getContentPane () add (lblCpf.);
JLabel lblTelefone = new JLabel ( "RG:");
lblTelefone.setBounds (421, 282, 46, 14);
frame.getContentPane () add (lblTelefone.);
JLabel lblNewLabel = new JLabel ( "Celular (*)");
lblNewLabel.setBounds (705, 231, 60, 14);
frame.getContentPane () add (lblNewLabel.);
// secretário
TextField textField = new TextField ();
textField.setBounds (117, 231, 174, 22);
frame.getContentPane () add (textField).;
// secretário
TextField textField_1 = new TextField ();
textField_1.setBounds (156, 282, 112, 22);
frame.getContentPane () add (textField_1.);
// secretário
TextField textField_2 = new TextField ();
textField_2.setBounds (473, 282, 127, 22);
frame.getContentPane () add (textField_2.);
// secretário
TextField textField_3 = new TextField ();
textField_3.setBounds (779, 231, 127, 22);
frame.getContentPane () add (textField_3.);
JLabel lblNewLabel_1 = new JLabel ( "");
lblNewLabel_1.setIcon (nova ImageIcon (PROJETOJAVA.class.getResource ( "/ im / hospital.jpg")));
lblNewLabel_1.setBounds (282, 11, 428, 145);
frame.getContentPane () add (lblNewLabel_1.);
// secretário
TextField textField_4 = new TextField ();
textField_4.setBounds (119, 180, 172, 22);
frame.getContentPane () add (textField_4.);
JLabel lblNewLabel_2 = new JLabel ( "Sexo: \ r \ n");
lblNewLabel_2.setBounds (382, 176, 46, 22);
frame.getContentPane () add (lblNewLabel_2.);
// secretário
JCheckBox chckbxNewCheckBox = new JCheckBox ( "Feminino \ r \ n");
chckbxNewCheckBox.setBounds (421, 176, 97, 23);
frame.getContentPane () add (chckbxNewCheckBox.);
// secretário
JCheckBox chckbxNewCheckBox_1 = new JCheckBox ( "Masculino");
chckbxNewCheckBox_1.setBounds (539, 176, 97, 23);
frame.getContentPane () add (chckbxNewCheckBox_1.);
// secretário
JComboBox comboBox = new JComboBox ();
comboBox.setBounds (809, 346, 97, 20);
comboBox.setModel (nova DefaultComboBoxModel (new String [] { "Pediatria", "Otorrinolaringologia", "Dermatologia", "Cardiologia", "Cl \ u00EDnica M \ u00E9dica", "Oftalmologia", "Mastologia", "Neurologia", " generalista "," Nefrologia "," Angiologia "}));
comboBox.setToolTipText ( "\ r \ n");
. Frame.getContentPane () add (comboBox);
JLabel lblNewLabel_3 = new JLabel ( "Dados Finais: \ r \ n");
lblNewLabel_3.setBounds (10, 326, 75, 17);
frame.getContentPane () add (lblNewLabel_3.);
// secretário
JComboBox comboBox_1 = new JComboBox ();
comboBox_1.setBounds (755, 177, 37, 20);
comboBox_1.setModel (novo DefaultComboBoxModel (new String [] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10 "," 11 "," 12 "," 13 "," 14 "," 15 "," 16 "," 17 "," 18 "," 19 "," 20 "," 21 "," 22 ", "23", "24", "25", "26", "27", "28", "29", "30", "31"}));
frame.getContentPane () add (comboBox_1.);
JLabel lblDataNasimento = new JLabel ( "Dados de Nascimento");
lblDataNasimento.setBounds (659, 180, 86, 14);
frame.getContentPane () add (lblDataNasimento.);
// secretário
JComboBox comboBox_2 = new JComboBox ();
comboBox_2.setBounds (828, 177, 37, 20);
comboBox_2.setModel (novo DefaultComboBoxModel (new String [] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10 "," 11 "," 12 "}));
frame.getContentPane () add (comboBox_2.);
// secretário
JComboBox comboBox_3 = new JComboBox ();
comboBox_3.setBounds (900, 177, 60, 20);
comboBox_3.setModel (nova DefaultComboBoxModel (new String [] { "2016", "2015", "2014", "2013", "2012", "2011", "2010", "2009", "2008", "2007 "," 2006 "," 2005 "," 2004 "," 2003 "," 2002 "," 2001 "," 2000 "," 1999 "," 1998 "," 1997 "," 1996 "," 1995 ", "1994", "1993", "1992", "1991", "1990", "1989", "1988", "1987", "1986", "1985", "1984", "1983", "1982 "," 1981 "," 1980 "," 1979 "," 1978 "," 1977 "," 1976 "," 1975 "," 1974 "," 1973 "," 1972 "," 1971 "," 1970 ", "1969", "1968", "1967", "1966", "1965", "1964", "1963", "1962", "1961", "1960", "1959", "1958", "1957 "," 1956 "," 1955 "," 1954 "," 1953 "," 1952 "," 1951 "," 1950 "," 1949 "," 1948 "," 1947 "," 1946 "," 1945 ", "1944", "1943", "1942", "1941", "1940", "1939", "1938", "1937", "1936", "1935", "1934", "1933", "1932 "," 1931 "," 1930 "," 1929 "," 1928 "," 1927 "," 1926 "," 1925 "," 1924 "," 1923 "," 1922 "," 1921 "," 1920 ", "1919", "1918", "1917", "1916", "1915", "1914", "1913", "1912", "1911", "1910", "1909", "1908", "1907 "," 1906 "," 1905 "," 1904 "," 1903 "," 1902 "," 1901 "}));
frame.getContentPane () add (comboBox_3.);
JLabel lblNewLabel_4 = new JLabel ( "Telefone");
lblNewLabel_4.setBounds (382, 231, 46, 14);
frame.getContentPane () add (lblNewLabel_4.);
// secretário
TextField textField_5 = new TextField ();
textField_5.setBounds (445, 231, 173, 22);
frame.getContentPane () add (textField_5.);
JLabel lblCpf_1 = new JLabel ( "CPF");
lblCpf_1.setBounds (121, 282, 46, 14);
frame.getContentPane () add (lblCpf_1.);
JLabel lblEspecialidade = new JLabel ( "Especialidade");
lblEspecialidade.setBounds (705, 349, 66, 14);
frame.getContentPane () add (lblEspecialidade.);
JLabel lblBairro = new JLabel ( "Bairro");
lblBairro.setBounds (694, 274, 46, 14);
frame.getContentPane () add (lblBairro.);
// secretário
TextField textField_6 = new TextField ();
textField_6.setBounds (764, 274, 142, 22);
frame.getContentPane () add (textField_6.);
JLabel lblPeriodoPreferencial = new JLabel ( "Periodo Preferencial:");
lblPeriodoPreferencial.setBounds (36, 349, 112, 14);
frame.getContentPane () add (lblPeriodoPreferencial.);
// secretário
JComboBox comboBox_4 = new JComboBox ();
comboBox_4.setBounds (167, 346, 90, 20);
comboBox_4.setModel (nova DefaultComboBoxModel (new String [] { "Indiferente", "Manh \ u00E3", "Tarde", "Noite"}));
frame.getContentPane () add (comboBox_4.);
JLabel lblTipoDePlano = new JLabel ( "Tipo de plano");
lblTipoDePlano.setBounds (465, 327, 77, 14);
frame.getContentPane () add (lblTipoDePlano.);
// secretário
JCheckBox chckbxConvnio = new JCheckBox ( "Conv \ u00EAnio");
chckbxConvnio.setBounds (382, 345, 97, 23);
frame.getContentPane () add (chckbxConvnio.);
// secretário
JCheckBox chckbxParticular = new JCheckBox ( "especial");
chckbxParticular.setBounds (521, 345, 97, 23);
frame.getContentPane () add (chckbxParticular.);
}
}