Retorno de nomes (com gráficos)
Publicado por André (última atualização em 11/09/2009)
[ Hits: 4.712 ]
Homepage: http://127.0.0.1
Aplicação criada no NetBeans, usei gráficos. O que ele faz? Este software possui 2 jbuttons, o "Exibir Mensagem" e o "Encerrar", um JtextField e um JLabel.
O JLabel usamos apenas para deixar escrito: "Escreva aqui o seu nome"
O JButton "Exibir Mensagem" exibe o nome digitado (o nome digitado foi ...) e o "Encerrar" obviamente fecha o programa.
import javax.swing.JOptionPane; /* * TelaPrincipal.java * * Created on 6 de Setembro de 2009, 17:01 */ /** * * @author Juninho */ public class TelaPrincipal extends javax.swing.JFrame { /** Creates new form TelaPrincipal */ public TelaPrincipal() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code "> private void initComponents() { txNome = new javax.swing.JTextField(); lbPreencha = new javax.swing.JLabel(); btMensagem = new javax.swing.JButton(); btEncerrar = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Usando o NetBeans :)"); lbPreencha.setFont(new java.awt.Font("MS Sans Serif", 1, 11)); lbPreencha.setText("Digite seu nome "); btMensagem.setText("Exibir Mensagem"); btMensagem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btMensagemActionPerformed(evt); } }); btEncerrar.setText("Encerrar"); btEncerrar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btEncerrarActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(txNome, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 278, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(layout.createSequentialGroup() .add(38, 38, 38) .add(lbPreencha)) .add(layout.createSequentialGroup() .addContainerGap() .add(btMensagem, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 197, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(btEncerrar))) .addContainerGap(36, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(lbPreencha) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(txNome, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(btMensagem) .add(btEncerrar)) .addContainerGap(33, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void btEncerrarActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: System.exit(0); } private void btMensagemActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: JOptionPane.showMessageDialog(null, "O nome digitado foi : "+ txNome.getText(), "Mensagem", JOptionPane.INFORMATION_MESSAGE); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new TelaPrincipal().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton btEncerrar; private javax.swing.JButton btMensagem; private javax.swing.JLabel lbPreencha; private javax.swing.JTextField txNome; // End of variables declaration }
Começando a trabalhar com arrays
Nenhum comentário foi encontrado.
Como agendar um backup automático do PostgreSQL no Cron evitando o problema de senha
Como preparar o Vim/Neovim para corrigir ortografia em português
Dark Web e Malwares na internet, quanto custa?
Configuração básica do Conky para mostrar informações sobre a sua máquina no Desktop
Como verificar o hash de um arquivo baixado da Internet e como criar um hash
Debian 12 - IPTABLES - removendo NFTABLES
OverWatch 2 - Abrindo portas do jogo no Iptables.
Como instalar o adaptador wifi USB Intelbras ACtion A1200 no Linux Mint
Como normalizar seus arquivos MP3 para que fiquem no mesmo volume
Instalação do Programa Imposto de Renda Pessoa Física 2023 [RESOLVIDO]... (6)
Instalando e compilando o GCC/G++ erro (4)
[C/C++] BRT - Bulk Renaming Tool
[Shell Script] Criação de Usuarios , Grupo e instalação do servidor de arquivos samba
[Shell Script] Tire screenshots com Scrot facilmente com Zscrot
[Shell Script] DioPSI - Script multidistro para instalar programas
[Shell Script] ARS Vídeos - Cortador de vídeos e webcam shooter