Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Teste;
- // Bibliotecas
- import java.awt.Color;
- public class A extends javax.swing.JFrame
- {
- // Construtor
- public A()
- {
- initComponents();// Inicializando componentes
- config();// Configurações
- }
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- lblMensagem = new javax.swing.JLabel();
- btnClick = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setTitle("OLÁ");
- setResizable(false);
- lblMensagem.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
- lblMensagem.setForeground(new java.awt.Color(0, 0, 153));
- lblMensagem.setText("Aqui vai aparecer a mensagem");
- lblMensagem.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
- btnClick.setForeground(new java.awt.Color(255, 0, 0));
- btnClick.setText("Clique em Mim");
- btnClick.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnClickActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(lblMensagem, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addGap(75, 75, 75)
- .addComponent(btnClick)))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap(20, Short.MAX_VALUE)
- .addComponent(lblMensagem, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(btnClick, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(23, 23, 23))
- );
- pack();
- }// </editor-fold>
- private void btnClickActionPerformed(java.awt.event.ActionEvent evt) {
- // Mudança de texto no Lable
- lblMensagem.setText(String.format("Olá, Mundo !!!"));
- }
- // Método Principal
- public static void main(String args[])
- {
- try
- {
- for(javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
- {
- if("Nimbus".equals(info.getName()))
- {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- }
- catch(ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex)
- {
- java.util.logging.Logger.getLogger(A.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- java.awt.EventQueue.invokeLater(() -> {
- new A().setVisible(true);
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton btnClick;
- private javax.swing.JLabel lblMensagem;
- // End of variables declaration
- // Método: Configurações
- private void config()
- {
- // Frame
- this.setTitle("Olá");// Título
- this.setLocationRelativeTo(null);// Centralizado
- this.getContentPane().setBackground(Color.green);// Tela com fundo verde
- }
- }
Add Comment
Please, Sign In to add comment