maven不会在Ubuntu上编译我的JavaFx项目

时间:2014-07-07 11:29:08

标签: maven ubuntu javafx

我会很乐意帮助你。

长篇故事。我最近开始使用Ubuntu,从窗口切换,我一直在开发我的JavaFx项目。我的Ubuntu是14.04。我注意到我没有Java / JDK安装目录中的JavaFx文件,所以我认为这是我的JavaFx项目没有编译的原因,所以我卸载它并手动安装最新的JDK发行版,根据他们的文档与JavaFx捆绑在一起。但是在安装之后,我认为我还没有JavaFx。但是,这确实可以编译:

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
 * Simple demonstration of JavaFX text support.
 * 
 * @author Dustin
 */
public class JavaFxText extends Application
{
   /**
    * Start demonstration of JavaFX text capabilities.
    * 
    * @param stage Stage for JavaFX application.
    * @throws Exception Exception in JavaFX application.
    */
   @Override
   public void start(final Stage stage) throws Exception
   {
      stage.setTitle("Simplistic Example of JavaFX 2.0 Text Capabilities");
      final Group rootGroup = new Group();
      final Scene scene =
     new Scene(rootGroup, 800, 400, Color.BEIGE);

      final Text text1 = new Text(25, 25, "(2007) JavaFX based on F3");
      text1.setFill(Color.CHOCOLATE);
      text1.setFont(Font.font(java.awt.Font.SERIF, 25));
      rootGroup.getChildren().add(text1);

      final Text text2 = new Text(25, 50, "(2010) JavaFX Script Deprecated");
      text2.setFill(Color.DARKBLUE);
      text2.setFont(Font.font(java.awt.Font.SANS_SERIF, 30));
      rootGroup.getChildren().add(text2);

      final Text text3 = new Text(25, 75, "(2011) JavaFX to be Open Sourced!");
      text3.setFill(Color.TEAL);
      text3.setFont(Font.font(java.awt.Font.MONOSPACED, 35));
      rootGroup.getChildren().add(text3);

      final Text text4 = new Text(25, 125, "(2011) JavaFX to be Standardized");
      text4.setFill(Color.CRIMSON);
      text4.setFont(Font.font(java.awt.Font.DIALOG, 40));
      final Effect glow = new Glow(1.0);
      text4.setEffect(glow);
      rootGroup.getChildren().add(text4);

      final Text text5 = new Text(25, 175, "(Now) Time for JavaFX 2.0!");
      text5.setFill(Color.DARKVIOLET);
      text5.setFont(Font.font(java.awt.Font.SERIF, FontWeight.EXTRA_BOLD, 45));
      final Light.Distant light = new Light.Distant();
      light.setAzimuth(-135.0);
      final Lighting lighting = new Lighting();
      lighting.setLight(light);
      lighting.setSurfaceScale(9.0);
      text5.setEffect(lighting);
      rootGroup.getChildren().add(text5);

      final Text text6 = new Text(25, 225, "JavaFX News at JavaOne!");
      text6.setFill(Color.DARKGREEN);
      text6.setBlendMode(BlendMode.COLOR_BURN);
      text6.setFont(Font.font(java.awt.Font.DIALOG_INPUT, FontWeight.THIN, 45));
      final Reflection reflection = new Reflection();
      reflection.setFraction(1.0);
      text6.setEffect(reflection);
      rootGroup.getChildren().add(text6);

      stage.setScene(scene);
      stage.show();
   }

   /**
    * Main JavaFX application launching method.
    * 
    * @param arguments Command-line arguments: none expected.
    */
   public static void main(final String[] arguments)
   {
      Application.launch(arguments);
   }
}

请注意我纯粹是从Ubuntu终端运行,没有IDE。

这些是我的Java / maven规范:

Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.8.0_05, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_05/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-24-generic", arch: "i386", family: "unix"

但是,我的主要任务是编译我的maven JavaFx项目,该项目不起作用。

JFXtras Agenda项目可能是一个很好的例子,因为我的项目太大而无法在此发布。

这是我得到的错误:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project agenda: Compilation failure

详细错误报告:

[INFO] Compiling 1 source file to /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,50] > expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,51] ';' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,53] illegal start of expression
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,121] > expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,122] ';' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,124] illegal start of expression
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,125] ';' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,126] illegal start of expression
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[60,109] > expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[60,110] ')' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[60,115] -> expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[63,43] ';' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[63,78] ';' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[60,112] not a statement
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[72,10] ';' expected
[INFO] 15 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.148s
[INFO] Finished at: Mon Jul 07 16:29:36 EAT 2014
[INFO] Final Memory: 8M/90M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project agenda: Compilation failure: Compilation failure:
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,50] > expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,51] ';' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,53] illegal start of expression
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,121] > expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,122] ';' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,124] illegal start of expression
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,125] ';' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[27,126] illegal start of expression
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[60,109] > expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[60,110] ')' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[60,115] -> expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[63,43] ';' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[63,78] ';' expected
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[60,112] not a statement
[ERROR] /media/rev-buntu/2490D3BE90D39520/Dev/java/workingDir/live/agenda/src/main/java/jfxtras/samples/controls/agenda/AgendaSample1.java:[72,10] ';' expected
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project agenda: Compilation failure
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 

这是代码:

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>jfxtras.samples.controls.agenda</groupId>
  <artifactId>agenda</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>agenda</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
    <testSourceDirectory>src/test/java/junit</testSourceDirectory>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>

    <testResources>
        <testResource>
            <directory>src/test/java/selenium</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </testResource>
    </testResources>

        <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>jfxtras.samples.controls.agenda</mainClass>
                        <classpathPrefix>dependency-jars/</classpathPrefix>
                    </manifest>
                </archive>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.8</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <includeGroupIds>log4j</includeGroupIds>
                        <outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
    </build>

  <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
    </dependency>

    <dependency>
        <groupId>org.jfxtras</groupId>
        <artifactId>jfxtras-agenda</artifactId>
        <version>8.0-r1</version>
    </dependency>

  </dependencies>
</project>

java main:

package jfxtras.samples.controls.agenda;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;

import javafx.geometry.HPos;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.Priority;
import javafx.stage.Stage;
import javafx.util.Callback;
import jfxtras.labs.samples.JFXtrasLabsSampleBase;
import jfxtras.scene.control.CalendarTextField;
import jfxtras.scene.control.agenda.Agenda;
import jfxtras.scene.layout.GridPane;

public class AgendaSample1 extends JFXtrasLabsSampleBase
{
    public AgendaSample1() {
    agenda = new Agenda();

    // setup appointment groups
    final Map<string, agenda.appointmentgroup=""> lAppointmentGroupMap = new TreeMap<string, agenda.appointmentgroup="">();
    lAppointmentGroupMap.put("group00", new Agenda.AppointmentGroupImpl().withStyleClass("group0"));
    lAppointmentGroupMap.put("group01", new Agenda.AppointmentGroupImpl().withStyleClass("group1"));
    lAppointmentGroupMap.put("group02", new Agenda.AppointmentGroupImpl().withStyleClass("group2"));
    lAppointmentGroupMap.put("group03", new Agenda.AppointmentGroupImpl().withStyleClass("group3"));
    lAppointmentGroupMap.put("group04", new Agenda.AppointmentGroupImpl().withStyleClass("group4"));
    lAppointmentGroupMap.put("group05", new Agenda.AppointmentGroupImpl().withStyleClass("group5"));
    lAppointmentGroupMap.put("group06", new Agenda.AppointmentGroupImpl().withStyleClass("group6"));
    lAppointmentGroupMap.put("group07", new Agenda.AppointmentGroupImpl().withStyleClass("group7"));
    lAppointmentGroupMap.put("group08", new Agenda.AppointmentGroupImpl().withStyleClass("group8"));
    lAppointmentGroupMap.put("group09", new Agenda.AppointmentGroupImpl().withStyleClass("group9"));
    lAppointmentGroupMap.put("group10", new Agenda.AppointmentGroupImpl().withStyleClass("group10"));
    lAppointmentGroupMap.put("group11", new Agenda.AppointmentGroupImpl().withStyleClass("group11"));
    lAppointmentGroupMap.put("group12", new Agenda.AppointmentGroupImpl().withStyleClass("group12"));
    lAppointmentGroupMap.put("group13", new Agenda.AppointmentGroupImpl().withStyleClass("group13"));
    lAppointmentGroupMap.put("group14", new Agenda.AppointmentGroupImpl().withStyleClass("group14"));
    lAppointmentGroupMap.put("group15", new Agenda.AppointmentGroupImpl().withStyleClass("group15"));
    lAppointmentGroupMap.put("group16", new Agenda.AppointmentGroupImpl().withStyleClass("group16"));
    lAppointmentGroupMap.put("group17", new Agenda.AppointmentGroupImpl().withStyleClass("group17"));
    lAppointmentGroupMap.put("group18", new Agenda.AppointmentGroupImpl().withStyleClass("group18"));
    lAppointmentGroupMap.put("group19", new Agenda.AppointmentGroupImpl().withStyleClass("group19"));
    lAppointmentGroupMap.put("group20", new Agenda.AppointmentGroupImpl().withStyleClass("group20"));
    lAppointmentGroupMap.put("group21", new Agenda.AppointmentGroupImpl().withStyleClass("group21"));
    lAppointmentGroupMap.put("group22", new Agenda.AppointmentGroupImpl().withStyleClass("group22"));
    lAppointmentGroupMap.put("group23", new Agenda.AppointmentGroupImpl().withStyleClass("group23"));
    for (String lId : lAppointmentGroupMap.keySet())
    {
        Agenda.AppointmentGroup lAppointmentGroup = lAppointmentGroupMap.get(lId);
        lAppointmentGroup.setDescription(lId);
        agenda.appointmentGroups().add(lAppointmentGroup);
    }

    // accept new appointments
    agenda.createAppointmentCallbackProperty().set(new Callback<agenda.calendarrange, agenda.appointment="">()
    {
        @Override
        public Agenda.Appointment call(Agenda.CalendarRange calendarRange)
        {
            return new Agenda.AppointmentImpl()
                    .withStartTime(calendarRange.getStartCalendar())
                    .withEndTime(calendarRange.getEndCalendar())
                    .withSummary("new")
                    .withDescription("new")
                    .withAppointmentGroup(lAppointmentGroupMap.get("group01"));
        }
    });

    // initial set
    Calendar lFirstDayOfWeekCalendar = getFirstDayOfWeekCalendar(agenda.getLocale(), agenda.getDisplayedCalendar());
    int lFirstDayOfWeekYear = lFirstDayOfWeekCalendar.get(Calendar.YEAR);
    int lFirstDayOfWeekMonth = lFirstDayOfWeekCalendar.get(Calendar.MONTH);
    int FirstDayOfWeek = lFirstDayOfWeekCalendar.get(Calendar.DATE);
    Calendar lToday = agenda.getDisplayedCalendar();
    int lTodayYear = lToday.get(Calendar.YEAR);
    int lTodayMonth = lToday.get(Calendar.MONTH);
    int lTodayDay = lToday.get(Calendar.DATE);
    agenda.appointments().addAll(
    /*
     *  . . . .
     *  . . . .
     *  A . . .  8:00
     *  A B C .  8:30
     *  A B C D  9:00
     *  A B . D  9:30
     *  A . . D 10:00
     *  A E . D 10:30
     *  A . . D 11:00
     *  . . . D 11:30
     *  . . . D 12:00
     *  F . . D 12:30
     *  F H . D 13:00
     *  . . . . 13:30
     *  G . . . 14:00
     *  . . . . 14:30
     *
     */
    new Agenda.AppointmentImpl()
            .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 8, 00))
            .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 11, 30))
            .withSummary("A")
            .withDescription("A much longer test description")
            .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 8, 30))
        .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 10, 00))
        .withSummary("B")
        .withDescription("A description 2")
        .withAppointmentGroup(lAppointmentGroupMap.get("group08"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 8, 30))
        .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 9, 30))
        .withSummary("C")
        .withDescription("A description 3")
        .withAppointmentGroup(lAppointmentGroupMap.get("group09"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 9, 00))
        .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 13, 30))
        .withSummary("D")
        .withDescription("A description 4")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 10, 30))
        .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 11, 00))
        .withSummary("E")
        .withDescription("A description 4")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 12, 30))
        .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 13, 30))
        .withSummary("F")
        .withDescription("A description 4")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 13, 00))
        .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 13, 30))
        .withSummary("H")
        .withDescription("A description 4")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 14, 00))
        .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 14, 45))
        .withSummary("G")
        .withDescription("A description 4")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 8, 10))
        .withEndTime(null)
        .withSummary("K asfsfd dsfsdfs fsfds sdgsds dsdfsd ")
        .withDescription("A description 4")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 19, 00))
        .withEndTime(null)
        .withSummary("L asfsfd dsfsdfs fsfds sdgsds dsdfsd ")
        .withDescription("A description 4")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 15, 00))
        .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 16, 00))
        .withSummary("I")
        .withDescription("A description 4")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 15, 30))
        .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 16, 00))
        .withSummary("J")
        .withDescription("A description 4")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
        // -----
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 20, 30))
        .withEndTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay, 20, 31))
        .withSummary("S")
        .withDescription("Too short")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
        // -----
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay))
        .withSummary("all day1")
        .withDescription("A description")
        .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
        .withWholeDay(true)
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay))
        .withSummary("all day2")
        .withDescription("A description")
        .withAppointmentGroup(lAppointmentGroupMap.get("group08"))
        .withWholeDay(true)
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay))
        .withSummary("all day3")
        .withDescription("A description3")
        .withAppointmentGroup(lAppointmentGroupMap.get("group09"))
        .withWholeDay(true)
    ,     new Agenda.AppointmentImpl()
        .withStartTime(new GregorianCalendar(lTodayYear, lTodayMonth, lTodayDay + 1))
        .withSummary("all day")
        .withDescription("A description3")
        .withAppointmentGroup(lAppointmentGroupMap.get("group03"))
        .withWholeDay(true)
    );
    }
    final Agenda agenda;

    @Override
    public String getSampleName() {
    return this.getClass().getSimpleName();
    }

    @Override
    public String getSampleDescription() {
    return "Basic Agenda usage";
    }

    @Override
    public Node getPanel(Stage stage) {
    return agenda;
    }

    @Override
    public Node getControlPanel() {
    // the result
    GridPane lGridPane = new GridPane();
    lGridPane.setVgap(2.0);
    lGridPane.setHgap(2.0);

    // setup the grid so all the labels will not grow, but the rest will
    ColumnConstraints lColumnConstraintsAlwaysGrow = new ColumnConstraints();
    lColumnConstraintsAlwaysGrow.setHgrow(Priority.ALWAYS);
    ColumnConstraints lColumnConstraintsNeverGrow = new ColumnConstraints();
    lColumnConstraintsNeverGrow.setHgrow(Priority.NEVER);
    lGridPane.getColumnConstraints().addAll(lColumnConstraintsNeverGrow, lColumnConstraintsAlwaysGrow);
    int lRowIdx = 0;

    // week
    {
        lGridPane.add(new Label("Week of"), new GridPane.C().row(lRowIdx).col(0).halignment(HPos.RIGHT));
        CalendarTextField lCalendarTextField = new CalendarTextField();
        lGridPane.add(lCalendarTextField, new GridPane.C().row(lRowIdx).col(1));
        lCalendarTextField.calendarProperty().bindBidirectional(agenda.displayedCalendar());
    }
    lRowIdx++;

    // done
    return lGridPane;
    }

    @Override
    public String getJavaDocURL() {
    return "http://jfxtras.org/doc/8.0/jfxtras-agenda/" + Agenda.class.getName().replace(".", "/") + ".html";
    }

    public static void main(String[] args) {
    launch(args);
    }


    /**
     * get the calendar for the first day of the week
     */
    static private Calendar getFirstDayOfWeekCalendar(Locale locale, Calendar c)
    {
    // result
    int lFirstDayOfWeek = Calendar.getInstance(locale).getFirstDayOfWeek();
    int lCurrentDayOfWeek = c.get(Calendar.DAY_OF_WEEK);
    int lDelta = 0;
    if (lFirstDayOfWeek <= lCurrentDayOfWeek)
    {
        lDelta = -lCurrentDayOfWeek + lFirstDayOfWeek;
    }
    else
    {
        lDelta = -lCurrentDayOfWeek - (7-lFirstDayOfWeek);
    }
    c = ((Calendar)c.clone());
    c.add(Calendar.DATE, lDelta);
    return c;
    }

}

0 个答案:

没有答案