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.
Related
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
I would like to make .txt-files accessible for my VaadinApp on a GlassfishServer.
Lets say I have a .txt-file, its content is 12345.
Now, when I click a button on my Vaadin StartPage, I would like to show the Data that has been written into this .txt-file.
I know how Java Input/Output is working but I have no clue how to make those files accessible for my VaadinApplication running on Glassfish 4.1.2.
Is there a folder I can put the .txt-file in, or how would I access the file?
Thanks
There is component named Label is available in Vaadin.
So that, the values which needs to be shown on the screen can be set as a caption/value for that object.
This can be done either through constructor or setter in that object.We will set the value through the setter as we need to display the value, once the button is clicked. That can be done like this.
Label sampleLabel = new Label();
sampleLabel.setContentMode(com.vaadin.shared.ui.ContentMode.HTML);
Now we will see how this can be added to the label, when a button is clicked.
Button sampleButton = new Button("Click");
sampleButton.addClickListener(event -> sampleLabel.setValue(<call the method that reads data from the text file>));
I hope this will be helpful.
Note: Basically you can place the file anywhere in the system.
But most preferred way.
If you are using maven to build the project, place the files in the resource folder.(src/main/resources)
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 !
I am creating a javafx program in which i need to open a new fxml file in new tab dynamically.
I want that When user click on button a new tab is opened with new fxml file.
I Had no idea I can add tab as per design as much as i need but i want to do it dynamically when user click on button then only a new tab open.
I had also seen Questing but not working for me.
Please help me.
Thank you.
You can add tabs dynamically with
myTabPane.getTabs().add(myNewTab);
Create a new Tab with new Tab(), load your FXML and call
myNewTab.setContent(loadedFxmlRoot);
You can add tabs using this code, you need to confirm if your tabPane has this tab or no, else your program invokes SizeOfBounds exception.
if (!MessagePane.getTabs().contains(AllMessageTab)) {
MessagePane.getTabs().add(AllMessageTab);
}
SingleSelectionModel<Tab> selectionModel = MessagePane.getSelectionModel();
selectionModel.select(AllMessageTab);
AllMessageTab.setContent(_YourContentNodeHere);
I have a Liferay project with Vaadin portlet.
I want to add icon to my buttons.
Button search = new Button("Search");
search.setIcon(new ThemeResource("img/silk/add.png"));
But dont know where i gonna put it? Now i put it in docroot directory.
UPDATE
No i try this.
Button search = new Button("Search");
search.setIcon(new ThemeResource("LifeRayVaadin-portlet/icons/add.png"));
But when i redeploy project in console get
09:34:05,773 WARN [404_jsp:109] /html/VAADIN/themes/liferay/LifeRayVaadin-portlet/icons/add.png
So your portlet is looking for the icons in /html/VAADIN/themes/liferay/LifeRayVaadin-portlet/icons/add.png.
You could create a directory icons under VAADIN and call:
search.setIcon(new ThemeResource("../../icons/add.png"));
ThemeResource without any path will look for the file in VAADIN/themes/yourtheme/ path and thus ../../ will get you (in this case) to /VAADIN/. I personally would never hardcode the name of a theme or a portlet in a project, because when it changes you have to go through every reference and change them.
You can put your images in $PORTLET-NAME/docroot/icons directory and call them using the Path
/$PORTLET-NAME$/icons/add.png
in your case it will be
Button search = new Button("Search");
search.setIcon(new ThemeResource("/$PORLTET-NAME$/icons/add.png"));