Olá pessoal!
Eu peguei esse código da internet. Soh que eu não preciso que quando a JDialog seja criado, ele seja criado com um Scroll. Mas não tô sabendo como fazer isso. Vcs podem tentar me ajudar?
public class NewJDialog extends javax.swing.JDialog {
public NewJDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
java.awt.Image i;
int width = 200;
int height = 200;
int[] pixels = new int[width * height];
int c;
double radianConversion = Math.PI / 180.0;
for (int index = 0, y = 0; y < height; y++) {
c = ((0xff)
& (byte) (Math.abs(Math.sin((y + height) * radianConversion)) * 255));
for (int x = 0; x < width; x++) {
pixels[index++] = ((0xff << 24) | (c << 16) | (c << 8) | c);
}
}
i = createImage (new MemoryImageSource (width, height, pixels, 0, width));
setFont(new Font("TimesRoman", Font.BOLD | Font.ITALIC, 32));
}
@Override
public void paint(Graphics g) {
g.drawString("JavaWorld", 30, 80);
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
NewJDialog dialog = new NewJDialog(new javax.swing.JFrame(), true);
dialog.setSize(250,200);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
}