Retorno de nomes (com gráficos)
Publicado por André (última atualização em 11/09/2009)
[ Hits: 4.971 ]
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 }
Nenhum coment�rio foi encontrado.
Comparação entre os escalonadores BFQ e MQ-Deadline (acesso a disco) no Arch e Debian
Conciliando o uso da ZRAM e SWAP em disco na sua máquina
Servidor de Backup com Ubuntu Server 24.04 LTS, RAID e Duplicati (Dell PowerEdge T420)
Visualizar câmeras IP ONVIF no Linux sem necessidade de instalar aplicativos
Converter os repositórios Debian para o novo formato com as chaves
Instalando Spotify no Debian 13
Realizar overclock no Miyoo Mini (plus ou normal)
linux mint reconhece microfone de lapela como fone de ouvido sem micro... (5)
E aí? O Warsaw já está funcionando no Debian 13? (2)
Dúvidas sobre a originalidade de conteúdos online (12)