- This topic has 9 replies, 3 voices, and was last updated 17 years ago by infotechmadhu.
-
AuthorPosts
-
infotechmadhuMemberHi,
I am trying to pop up swing calendar in a Jpanel.it works fine when i give
.add(component) inside initComponents()calendar = new JCalendar();
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 170, Short.MAX_VALUE).add(calendar);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 120, Short.MAX_VALUE).add(calendar));But when i goahead and change my form design ,the previously added code disappears(i.e).add(calendar) disappears.
Please let me know if there is any other way to add components.
Thanks
Loyal WaterMemberWhat version of MyEclipse are you working with ? Go to MyEclipse > Installation Summary > Installation Details and paste the information here for me.
Can you list the exact steps that you followed.
infotechmadhuMemberHi
Thanks for the reply.here is the installation details*** Date:
Tuesday, November 13, 2007 8:51:42 AM EST** System properties:
OS=WindowsXP
OS version=5.1
Java version=1.5.0_11*** MyEclipse details:
MyEclipse Enterprise Workbench
Version: 6.0.1 GA
Build id: 6.0.1-GA-200710*** Eclipse details:
MyEclipse Enterprise WorkbenchVersion: 6.0.1 GA
Build id: 6.0.1-GA-200710Eclipse Platform
Version: 3.3.1.R33x_r20070911-_19UEkpF-B7Uh2hKy75y
Build id: M20070921-1145Eclipse RCP
Version: 3.3.1.R33x_r20070802-8y8eE8sEV3Fz0z0GlHJrXvTAUS
Build id: M20070921-1145Eclipse Java Development Tools
Version: 3.3.1.r331_v20070629-7o7jE72EDlXAbqAcnbmyg1rf8RIL
Build id: M20070921-1145Eclipse Plug-in Development Environment
Version: 3.3.1.R33x_r20070802-7N7M3D1VIA_52JsDFsEC
Build id: M20070921-1145Eclipse Project SDK
Version: 3.3.1.R33x_r20070802-7M7J78_mu1mnlRa7A4Ns52XeZ6D0
Build id: M20070921-1145Eclipse Graphical Editing Framework
Version: 3.3.1.v20070814
Build id: 20070814-1555Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-showsplash
-launcher
C:\MyEclipse 6.0\eclipse\eclipse.exe
-name
Eclipse
–launcher.library
C:\MyEclipse 6.0\eclipse\plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.0.1.R33x_v20070828\eclipse_1020.dll
-startup
C:\MyEclipse 6.0\eclipse\plugins\org.eclipse.equinox.launcher_1.0.1.R33x_v20070828.jar
-exitdata
e68_68
-vm
C:\MyEclipse 6.0\jre\bin\javaw.exeSteps to pop up calendar:
(1)calling a calendar class thats is already available.
private JCalendar calendar;
calendar = new JCalendar();(2)tried to add the calendar to a panel.
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 170, Short.MAX_VALUE).add(calendar);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 120, Short.MAX_VALUE).add(calendar));Thanks
infotechmadhuMemberHi,
it would be gr8 if you can tell me where i can find good tutorial for pre-int/post-init code.Thanks
Riyad KallaMemberAs you mentioned you can place customized initialization code into the initCOmponents method only by using the pre/post init properties of the component you are initializing. What I prefer to do is just put my custom init code in the constructor after the call to initComponents().
infotechmadhuMemberHey thanks for the reply.
is it possible to add component to a panel outside initcomponent()?
i tried adding them as jPanel1.add(calendar);Please let me know if there is any good tutorial for matisse form using myeclipse.so far i have just found one basic tutorial.
Thanks
Riyad KallaMemberis it possible to add component to a panel outside initcomponent()?
Yes absolutely. The initComponent is a special method that is regenerated from the form file each time you change/save. But if you want to write your own method, like customInitComponents() and add your custom code there, that’s perfectly fine. Just be sure to call it after initCOmponents since that sets up all the other components in the UI.
As far as the tutorial goes, we currently just provide the 1. Is there a specific thing you wanted to learn about? Maybe I can help?
Also we are starting to provide webinars for MyEclipse (Free), that M4M is a great topic we could cover for a future one.
infotechmadhuMemberThanks..but when i try adding component it throws me an error.
i created a method called cutominit() and added my calendar component in a panel..but the calendar fails to pop up.
here is the code:Please let me know if i am doing anything wrong.public class AddCalendar extends javax.swing.JFrame {
private JCalendar calendar;/** Creates new form AddCalendar */
public AddCalendar() {
calendar = new JCalendar();
initComponents();
CustomInit();
}private void CustomInit() {
// TODO Auto-generated method stub
jPanel1.add(calendar);
}/** 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.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate=”collapsed” desc=” Generated Code “>
private void initComponents() {
jPanel1 = new javax.swing.JPanel();setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(
jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING).add(0, 171,
Short.MAX_VALUE));
jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING).add(0, 143,
Short.MAX_VALUE));org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING).add(
layout.createSequentialGroup().add(90, 90, 90).add(jPanel1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(139, Short.MAX_VALUE)));
layout.setVerticalGroup(layout.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING).add(
layout.createSequentialGroup().add(79, 79, 79).add(jPanel1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(78, Short.MAX_VALUE)));
pack();
}// </editor-fold>//GEN-END:initComponents/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new AddCalendar().setVisible(true);
}
});
}//GEN-BEGIN:variables
// Variables declaration – do not modify
private javax.swing.JPanel jPanel1;
// End of variables declaration//GEN-END:variables}
Riyad KallaMemberSorry I can’t help here, besides not having working code to trouble shoot, I have no idea what the calendar’s behavior is coded to do. For example, do you have to set it’s size? mark it visible? give it a default date and time? etc. etc.
infotechmadhuMemberBasically just want an example to add dynamic components to panel outside initcomponents().
For now,i have added the calendat componet as custom component and it works fine…Also it would be gr8 if you can give guide me to add pre-init/post-init and cutom code creation.
-
AuthorPosts