package network.temp;
import java.awt.FlowLayout;
import javax.swing.JButton;
public class Move extends javax.swing.JDialog {
public Move(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setName("Form"); // NOI18N
jPanel1.setName("jPanel1"); // NOI18N
jPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jPanel1MouseClicked(evt);
}
});
jPanel1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(java.awt.event.MouseEvent evt) {
jPanel1MouseDragged(evt);
}
public void mouseMoved(java.awt.event.MouseEvent evt) {
jPanel1MouseMoved(evt);
}
});
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(network.NetworkApp.class).getContext().getResourceMap(Move.class);
jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
jButton1.setName("jButton1"); // NOI18N
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(jButton1)
.addContainerGap(272, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(63, 63, 63)
.addComponent(jButton1)
.addContainerGap(214, Short.MAX_VALUE))
); 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.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
); pack();
}
private void jPanel1MouseDragged(java.awt.event.MouseEvent evt) {
}
private void jPanel1MouseMoved(java.awt.event.MouseEvent evt) {
}
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
JButton b=new JButton("按钮");
this.getContentPane().add(b);//当点击鼠标时在窗口上动态增加一个按钮
this.getContentPane().validate();
this.getContentPane().repaint();
} private void jPanel1MouseClicked(java.awt.event.MouseEvent evt) {
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
Move dialog = new Move(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
} // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JPanel jPanel1;
// End of variables declaration//GEN-END:variables}
这个是用netbeans的桌面应用系统建立的一个文件,使用的是netbeans默认的布局管理GroupLayout,当点击jButton1按钮的时候,想动态的添加一个按钮到窗口上,可为什么总也显示不出来呢?
* 根据客户端Locale得到本地化字符串.<br>
* @see {@link org.springframework.context.MessageSource#getMessage(String, Object[], Locale)}
* @param code 资源Key
* @param args 参数
* @return 根据客户端Locale得到的本地化字符串
*/
public static String resolveMessage(final String code, final Object... args)
{
MessageSource messageSource = getMessageSource(); if (messageSource == null)
{
LOGGER.error("cannot get messageSource");
return code;
} Locale locale = getClientLocale();
// LOGGER.debug("resolving message for locale: " + locale); return messageSource.getMessage(code, args, locale);
}
* 根据客户端Locale得到本地化字符串.<br>
* @see {@link org.springframework.context.MessageSource#getMessage(String, Object[], Locale)}
* @param code 资源Key
* @param locale 本地化对象,如果传入null值,默认为server端的本地化对象
* @param args 参数
* @return 根据客户端Locale得到的本地化字符串
*/
public static String resolveMessage(final String code, final Locale locale, final Object... args)
{
MessageSource messageSource = getMessageSource(); if (messageSource == null)
{
LOGGER.error("cannot get messageSource");
return code;
} Locale targetLocale = locale == null ? Locale.getDefault() : locale;
// LOGGER.debug("resolving message for locale: " + targetLocale); return messageSource.getMessage(code, args, targetLocale);
} /**
* 获取客户端的locale.<br>
* @return 客户端的locale
*/
public static Locale getClientLocale()
{
return LocaleContextHolder.getLocale();
}
Timer timer = new Timer();
timer.setParent(comp);
timer.addEventListener("onTimer", new EventListener(){ public void onEvent(final Event arg0) throws Exception
{
Timer timer =(Timer) arg0.getTarget();
timer.setDelay(flush_time);
showPic();
timer.setRepeats(true);
timer.setRunning(true); }});