Cannot add JDateChooser to IntelliJ IDEA palette - java

I want to add the JDateChooser component from jcalendar to the designer palette in intellij-idea; but when I'm adding com.toedter:jcalendar:1.4 through Maven dependency or JAR, I'm getting an error:
class "com.toedter.calendar.Jdatechooser" cannot be instantiated:
index 0 out of bound for length 0
Same JAR file works in Netbeans GUI editor.
If anyone has an idea of how to add JDateChooser in IntelliJ IDEA then please share your answer.
Note: This is not a duplicate of questions about adding jcalendar as a library.

Try adding a JPanel and then setting it's layout to borderlayout in Layout Manager.
Then add the add to your Main Form.
JDateChooser dateChooser = new JDateChooser(); //initializing the calendar
jpCalendar.add(dateChooser); //adding the calendar component to JPanel

Related

Vaadin 8 grid editor doesn't work correctly

Vaadin 8 editor of grid doesn't work correctly when I double click on cell that I can edit.
I use the simple code for create grid and add for one column editor component.
VerticalLayout content = new VerticalLayout();
content.setMargin(false);
content.setSpacing(false);
content.setSizeFull();
setContent(content);
Grid<OrderModel> grid = new Grid(OrderModel.class);
grid.setItems(generate());
grid.setSizeFull();
grid.getEditor().setEnabled(true);
grid.getColumn("planningStatus").setEditorComponent(getCombobox());
Next I run app and start to scroll grid till column "planningStatus".
How it works:
So. What should I do or how I should fix it for correct open editor in grid?
Could your problem be related to issue reported here: https://github.com/vaadin/framework/issues/7746 ?
There exists now also add-on which fixes couple of known Editor cell sizing issues:

JDatePicker - How to change the Icon of the Button?

I'm looking for help in placing an Icon instead of the default three dots as shown in this picture.
But I really have no clue how I can do it. The Class DateLabelFormatter just does some String conversions to display the german calendar names.
UtilDateModel modelProjektEnde = new UtilDateModel();
JDatePanelImpl datePanelProjektEnde = new JDatePanelImpl(modelProjektEnde, dateLabelFormatter.getProperties());
dateProjektEnde = new JDatePickerImpl(datePanelProjektEnde, dateLabelFormatter);
simple use this.
myDateChooser.getCalendarButton().setIcon("calendar.png");
Explaination for starters my be unnecessary here but here we go anyway,
If you want a Calendar or DateChooser in your project. You can use
JDateChooser.
Follow steps.
Download JCalendar 1.4.jar library.
Add it to your projects library folder by right clicking on Libraries and select ADD JAR/FOLDER.
if you are using netbeans then right click on your pallete and select pallete manager.
Now select Add from Jar and choose your downloaded libaray and select calendar it's calendar components you want to use. JDateChooser in this case.
Drag and drop this from pallete or declare it in your code.
JDateChooser myDateChooser = new com.toedter.calendar.JDateChooser();
to customize the button icon you can use following code
myDateChooser.setIcon(new ImageIcon(getClass().getResource("/Icons/calendar.png")));
Replace the path string with your icon path.
To change the button background
myDateChooser.getCalendarButton().setBackground(Color.WHITE);
and use can also change foreground, fonts etc this way.

Eclipse - Externalizing strings with keys based on component name instead of numbers

I use Eclipse Luna 4.4.2
using the "externalize strings" wizard (from right click on the class in the package explorer) it replaces my original strings by another string pointing to the key in the property file.
For example, having this label defined in a class "myFrame" :
JLabel mylabel = new JLabel("original text");
after the wizard the result is:
JLabel mylabel = new JLabel(Messages.getString("myFrame.1")
I would prefer a behavior where the key would be constructed by the component name. It is what happen if I use the other wizard from the windowbuilder view. But this wizard has less options (you can't set to ignore..)
So this result would be better :
JLabel mylabel = new JLabel(Messages.getString("myFrame.mylabel.text")
or even something like
JLabel mylabel = new JLabel(Messages.myFrame_mylabel_text)
I spent a lot of time on searching and found this thread Configuring string externalization in Eclipse to use ${key} as field name
but it is old and I do not have the checkbox "use Eclipe's externalization mechanism" ?!
Also this thread says that the features have been implemented inside Eclipse http://blog.vogella.com/2013/08/12/eclipse-internationalization-part-44-new-features-by-dirk-fauth/
Did I miss some updates ? I installed te latest build of Eclipse-Mars, but it does not help..
Thank you for help !

Adding a JPanel manually in NetBeans 7.1

I am trying to add a JPanel manually to a JPanel that was created via the Graphic Designer.
Since i can't edit in the Generated code i have no idea if i can do that.
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
newBall2 = new BasketBall("BasketBall",20,400);
MainpaintPanel mp = new MainpaintPanel();
this.add(mp);
}
in this code the mp Panel is created successfully but it doesn't show where it's added.
i think it's related to the default Layout of the netBeans but it could be something else.
Thanks in Advance.
you could also try using the ".setVisible(true)" and "setLocationRelativeTo(component c)" methods of the panel

JTabbedPane component accessing

I use JTabbedPane in one of my Java GUI code. I use the following portion of code to instantiate and maintain the tabpane.
JTabbedPane tabpane = new JTabbedPane();
PageViewer pv = new PageViewer();
tabpane.addTab("tabttitle", new JScrollPane(pv));
PageViewer is an extended class of JEditorPane. I want to access and modify the currently selected tab's constituent PageViewer pv component. I tried the following lines of code with some values of ind.
JScrollPane jsp = (JScrollPane) tabpane.getComponentAt(tabpane.getSelectedIndex());
PageViewer pv2 = (PageViewer) jsp.getComponent(ind);
But for ind==0 compiler says "java.lang.ClassCastException: javax.swing.JViewport cannot be cast to menu_window.PageViewer".
For ind==1 it says "java.lang.ClassCastException: javax.swing.JScrollPane$ScrollBar cannot be cast to menu_window.PageViewer".
For ind==2 output is "java.lang.ClassCastException: javax.swing.JScrollPane$ScrollBar cannot be cast to menu_window.PageViewer".
And for ind>=3 error is "java.lang.ArrayIndexOutOfBoundsException: No such child: 3".
Now how do I do the desired job, if anyone knows please help.
Note: I use NetBeans 6.8 with Java 6 Standard Edition.
When you create a JScrollPane around a component, the scrollpane actually adds the component into an internal JViewPort. To get the original component from the scrollpane you can do this:
PageViewer pv2 = (PageViewer)jsp.getViewport().getView();

Categories