Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8513053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:26:57+00:00 2026-06-11T04:26:57+00:00

I am working in ScalaFX Project. In this moment I am adapting classes from

  • 0

I am working in ScalaFX Project. In this moment I am adapting classes from javafx.scene.control.cell. In this package, methods with same signature are duplicated in many classes. e.g. StringConverter<T> converter(). To avoid unnecessary duplication of code (and to know how to use existential types), I created the following code:

// Defined in scalafx.util package. All classes in scalafx use this trait
package scalafx.util

trait SFXDelegate[+D <: Object] extends AnyRef {
  def delegate: D

  override def toString = "[SFX]" + delegate.toString

  override def equals(ref: Any): Boolean = {
    ref match {
      case sfxd: SFXDelegate[_] => delegate.equals(sfxd.delegate)
      case _ => delegate.equals(ref)
    }
  }

  override def hashCode = delegate.hashCode
}

// Package Object
package scalafx.scene.control

import javafx.{ util => jfxu }
import javafx.beans.{ property => jfxbp }
import javafx.scene.{ control => jfxsc }
import scalafx.Includes._
import scalafx.beans.property.ObjectProperty
import scalafx.util.SFXDelegate
import scalafx.util.StringConverter

package object cell {

  type Convertable[T] = {
    def converterProperty: jfxbp.ObjectProperty[jfxu.StringConverter[T]]
  }

  type JfxConvertableCell[T] = jfxsc.Cell[T] with Convertable[T]

  trait ConvertableCell[C <: JfxConvertableCell[T], T]
    extends SFXDelegate[C] {
    def converter: ObjectProperty[StringConverter[T]] = ObjectProperty(delegate.converterProperty.getValue)
    def converter_=(v: StringConverter[T]) {
      converter() = v
    }
  }

}

In JfxConvertableCell type I wanna say

My type is a javafx.scene.control.Cell of type T that has a method called converterProperty that returns a javafx.beans.property.ObjectProperty of type javafx.util.StringConverter[T].

While in ConvertableCell trait, my intention is say that delegate value (from SFXDelegate trait) must be of type JfxConvertableCell. The first class that I tried to create was the counter-part of CheckBoxListCell:

package scalafx.scene.control.cell

import javafx.scene.control.{cell => jfxscc}
import scalafx.scene.control.ListCell
import scalafx.util.SFXDelegate

class CheckBoxListCell[T](override val delegate: jfxscc.CheckBoxListCell[T] = new jfxscc.CheckBoxListCell[T])
  extends ListCell[T](delegate)
  with ConvertableCell[jfxscc.CheckBoxListCell[T], T]
  with SFXDelegate[jfxscc.CheckBoxListCell[T]] {

}

However in this moment I got this message from compiler:

type arguments [javafx.scene.control.cell.CheckBoxListCell[T],T] do not conform to trait ConvertableCell’s type parameter bounds [C <: scalafx.scene.control.cell.package.JfxConvertableCell[T],T]

Did I understand something wrong? CheckBoxListCell have the converterProperty method. Can’t we use types and existential types as a mold into which we fit our delegated classes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:26:58+00:00Added an answer on June 11, 2026 at 4:26 am

    The problem is in your definition of converterProperty. You define it as a parameterless method, while it is seen by scala as a method with an empty parameter list.
    Just doing this makes it compile properly:

    type Convertable[T] = {
      def converterProperty(): jfxbp.ObjectProperty[jfxu.StringConverter[T]]
    }
    

    While scala treats a parameterless method and a method with an empty parameter list as essentially the same thing as far as overriding is concerned (see scala spec @ 5.1.4), they are still different entites.
    And when interroperating with java code (which has no notion of parameterless method), a nullary method is seen as a method with an empty prameter list, not as a parameterless method, thus the structural types don’t match.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on calling a C function from my asm project. I'm trying to push
Working on a project at the moment and we have to implement soft deletion
Working on a project where a sequential set of methods must be run every
Working on a project, I have this issue where my array slicetable returns undefined
Working with H2 I get this error when I try to write a row
Working on the problems on Project Euler to try to learn Clojure. I'm on
Working on game where plates will be falling from top to bottom. Some plates
Working on a project using Entity Framework (4.3.1.0). I'm trying to figure out how
Working with cakePHP this is my situation: I have Users and Order s. Order
Working in Drupal today and simple cell spacing has been anything but simple for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.