i want to display error massages inside the jdesktop pane in java i have not done anything yet and am a beginner sorry for the broken English
i tried using JDialog but comes up on top of everything thisnthe code am using to call the JDialog
private boolean showAdmin_T() {
admin_priv obj = new admin_priv(fram, true);
fram.getRootPane().getGlassPane().setVisible(true);
obj.showMessage();
return obj.isOk();
}
i created a separate JDialog but it only opens outside the JDesktop pane here is the code for the Jdialog
package com.mutale.posapplication.dialogs;
import com.mutale.posapplication.scroll.ScrollBarCustom;
import com.mutale.posapplication.swing.icons.GoogleMaterialDesignIcons;
import com.mutale.posapplication.swing.icons.IconFontSwing;
import java.awt.Color;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;
import org.jdesktop.animation.timing.Animator;
import org.jdesktop.animation.timing.TimingTarget;
import org.jdesktop.animation.timing.TimingTargetAdapter;
public class error_disply extends javax.swing.JDialog {
private String icon;
public boolean isOk() {
return ok;
}
public void setOk(boolean ok) {
this.ok = ok;
}
private boolean ok;
private final Animator animator;
private boolean show = true;
public error_disply(java.awt.Frame parent, boolean modal,String icon1) {
super(parent, modal);
initComponents();
icon = "1";
panel(error_ScrollPane);
lbMessage.setLineWrap(true);
lbMessage.setWrapStyleWord(true);
setOpacity(0f);
if(icon.equals(icon1)){ lbIcon.setIcon(IconFontSwing.buildIcon(GoogleMaterialDesignIcons.STORAGE, 60, new Color(254, 86, 96), new Color(113, 74, 67)));
}else{
lbIcon.setIcon(IconFontSwing.buildIcon(GoogleMaterialDesignIcons.REPORT_PROBLEM, 40, new Color(254, 86, 96), new Color(113, 74, 67)));
}
getContentPane().setBackground(Color.WHITE);
TimingTarget target = new TimingTargetAdapter() {
@Override
public void timingEvent(float fraction) {
if (show) {
setOpacity(fraction);
} else {
setOpacity(1f - fraction);
}
}
@Override
public void end() {
if (show == false) {
setVisible(false);
}
}
};
animator = new Animator(200, target);
animator.setResolution(0);
animator.setAcceleration(0.5f);
}
public void showMessage(String message) {
lbMessage.setText(message);
animator.start();
setVisible(true);
}
public final void panel(JScrollPane scroll) {
scroll.getViewport().setBackground(Color.WHITE);
scroll.setVerticalScrollBar(new ScrollBarCustom());
JPanel p = new JPanel();
p.setBackground(Color.WHITE);
scroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, p);
scroll.setBorder(new EmptyBorder(0, 0, 0, 0));
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
lbIcon = new javax.swing.JLabel();
cancele = new com.mutale.posapplication.swings.Button();
error_ScrollPane = new javax.swing.JScrollPane();
lbMessage = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setUndecorated(true);
setResizable(false);
jPanel1.setBackground(new java.awt.Color(255, 255, 255));jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 0, 0), 2)); lbIcon.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
cancele.setBackground(new java.awt.Color(202, 5, 5));
cancele.setText("X");
cancele.setToolTipText("close");
cancele.setColorGradient(new java.awt.Color(202, 5, 5));
cancele.setEnabled(false);
cancele.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
cancele.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
canceleMousePressed(evt);
}
});
lbMessage.setEditable(false);
lbMessage.setColumns(3);
lbMessage.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
lbMessage.setRows(4);
lbMessage.setAutoscrolls(false);
lbMessage.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
error_ScrollPane.setViewportView(lbMessage);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lbIcon, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cancele, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(error_ScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(cancele, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lbIcon, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(1, 1, 1)
.addComponent(error_ScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE))
); cancele.getAccessibleContext().setAccessibleParent(cancele);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
private void canceleMousePressed(java.awt.event.MouseEvent evt) {
ok = true;
closeMenu();
}
private void closeMenu() {
if (animator.isRunning()) {
animator.stop();
}
show = false;
animator.start();
}
// Variables declaration - do not modify
private com.mutale.posapplication.swings.Button cancele;
private javax.swing.JScrollPane error_ScrollPane;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lbIcon;
private javax.swing.JTextArea lbMessage;
// End of variables declaration
}