É possível criar JButton
em um formato "quadrado", sem os cantos arredondados quando eles já estão no JFrame
? Alguém tem algum exemplo?
Não uso nenhum laf específico, e sim o default do netbeans.
Os JButtons
não tem nada de diferente, são como na imagem (não sei se ajuda muito). Tentei tirar do JPanel
, mas não muda em nada. Aí tem alguns eventos nos JButtons como mouse clicked, por exemplo. Os componentes já estão no JFrame, não uso nenhum código para criação, como nos exemplos citados aqui.
package view;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
/**
*
* @author Rodrigo
*/
public class Empresa extends javax.swing.JFrame {
/**
* Creates new form Empresa
*/
public Empresa() {
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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel5 =
new JPanel(){
public void paintComponent (Graphics g){
Image img =Toolkit.getDefaultToolkit().getImage(
Principal.class.getResource("/images/ws_abstract_gray_bar.png"));
g.drawImage(img, 0,0, this.getWidth(),this.getHeight(),this);
}
};
jLBuscarRegistro = new javax.swing.JLabel();
jTBuscarRegistro = new javax.swing.JTextField();
jBLimpar = new javax.swing.JButton();
jBusacarRegistro = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel5.setBackground(new java.awt.Color(153, 153, 153));
jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(0, 153, 153), null));
jPanel5.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLBuscarRegistro.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jLBuscarRegistro.setForeground(new java.awt.Color(255, 255, 255));
jLBuscarRegistro.setText("Buscar:");
jLBuscarRegistro.setPreferredSize(new java.awt.Dimension(20, 15));
jPanel5.add(jLBuscarRegistro, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, 111, 36));
jTBuscarRegistro.setToolTipText("Insira qualquer infromação ");
jTBuscarRegistro.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 102)));
jPanel5.add(jTBuscarRegistro, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 10, 111, 36));
jBLimpar.setForeground(new java.awt.Color(0, 102, 102));
jBLimpar.setText("Limpar");
jBLimpar.setBorder(null);
jBLimpar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jBLimparActionPerformed(evt);
}
});
jPanel5.add(jBLimpar, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 10, 111, 36));
jBusacarRegistro.setForeground(new java.awt.Color(0, 102, 102));
jBusacarRegistro.setIcon(new javax.swing.ImageIcon("D:\\NetBeansProjects\\SGInf\\src\\main\\resources\\images\\help.png")); // NOI18N
jBusacarRegistro.setBorder(null);
jBusacarRegistro.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jBusacarRegistroActionPerformed(evt);
}
});
jPanel5.add(jBusacarRegistro, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 10, 111, 36));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 492, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 472, Short.MAX_VALUE)
.addContainerGap()))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(117, 117, 117)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
.addGap(118, 118, 118)))
);
pack();
}// </editor-fold>
private void jBLimparActionPerformed(java.awt.event.ActionEvent evt) {
jTBuscarRegistro.setText("");
}
private void jBusacarRegistroActionPerformed(java.awt.event.ActionEvent evt) {
JOptionPane.showMessageDialog(null, "Insira informações");
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
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 ex) {
java.util.logging.Logger.getLogger(Empresa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Empresa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Empresa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Empresa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Empresa().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jBLimpar;
private javax.swing.JButton jBusacarRegistro;
private javax.swing.JLabel jLBuscarRegistro;
private javax.swing.JPanel jPanel5;
private javax.swing.JTextField jTBuscarRegistro;
// End of variables declaration
}