Retorno de nomes (com gráficos)
Publicado por André (última atualização em 11/09/2009)
[ Hits: 5.084 ]
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.
Cirurgia para acelerar o openSUSE em HD externo via USB
Void Server como Domain Control
Modo Simples de Baixar e Usar o bash-completion
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
Como automatizar sua instalação do Ubuntu para desenvolvimento de software.
Consertando o áudio com som ruim no Pipewire
Como implementar Raid (0, 1, 5, 6, 10 e 50)
fusermount3 no Ubuntu 25.10 - mantenha o perfil do AppArmor
[Resolvido] dlopen(): error loading libfuse.so.2 AppImages require FUSE to run.
Servidor Ubuntu 24.04 HD 500 não tenho espaço na \home\adminis... (2)
Como programar um sistema de controle para distribuições linux em c? (3)









