Collapsing borders in JavaFX 8

Hey there! I'm having a little issue with JavaFX 8 components. I'm trying to make them sit next to each other with borders, but it's not quite working out. Is there a way to make them blend together and share one border?

import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;

public class SettingsList {

    private VBox root;

    private String[] settingsList = new String[]{"set1", "set2", "set3"};

    public SettingsList(){

    }

    public Parent getControl(){
        root = new VBox();
        root.setAlignment(Pos.CENTER);
        root.getStylesheets().add(getClass().getResource("settingList.css").toExternalForm());
        for(String settingName: settingsList){
            Label settingLabel = new Label(settingName);
            settingLabel.getStyleClass().add("setting-label");
            root.getChildren().add(settingLabel);
        }

        return root;
    }
}

Answer №1

As far as I know, there is no built-in equivalent to border-collapse. You can handle the first one separately:

boolean isFirst = true ; 
for(String itemName: itemList){
    Label itemLabel = new Label(itemName);
    itemLabel.getStyleClass().add("item-label");
    if (isFirst) {
        itemLabel.getStyleClass().add("first-item");
    }
    isFirst = false ;
    root.getChildren().add(itemLabel);
}

Then, in the CSS file:

.item-label {
    -fx-label-padding: 10 ;
    -fx-border-color: black ;
    -fx-border-width: 0 1 1 1 ;
}
.item-label.first-item {
    -fx-border-width: 1 ;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

struggling to adjust image dimensions using bootstrap styling

Currently, I am in the process of creating a Carousel image slider using bootstrap. However, I am facing an issue with changing the height of the images within the carousel. Whenever I try to adjust the height, it ends up affecting both the width and heigh ...

Why does the JSON Java put() method return a String instead of void? put() isn't functioning properly! Fru

import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; clas ...

Getting rid of the excess white space below the footer caused by concealed elements

In my design, I have three columns. The rightmost column is filled with 'Divs' containing collapsed information that can be scrolled through using the mouse wheel. The overflow in the center is hidden. The width of all three columns is set to 760 ...

Two elements occupy the rest of the vertical space

In the center, there is a div with content inside. I want the top and bottom divs to occupy the remaining space. Similar to this example <div class="container"> <div class="top"> </div> <div class="middle"> C ...

retrieve the parent frame's request URL

I am faced with the task of writing a JSP code that retrieves the getRequestURL() of the parent frame (the URL shown in the address bar) from a child frame. However, when I attempt to do this, I only obtain the URL of the child frame. Is there anyone who ...

Basic color scheme

I'm attempting to change the background color behind a partially transparent .png div. The CSS class that modifies the div is ".alert". Manually editing the .alert class background color works perfectly, and now I want to automate this on a 1-second c ...

How can I send a current variable through PHP?

I have a pressing deadline and I need some guidance before moving forward. Can someone please advise if what I'm attempting is feasible or if there's a quicker solution? I encountered some problems with an accordion menu, so as a temporary fix, ...

Transparent static navbar displayed above header image

Scenario I managed to develop a transparent navbar that is superimposed on top of a header image with an SVG curve attached to it. To create the transparent navbar, I modified some classes associated with it by removing bg-light. By adding the class fix ...

Spring Controller error handler for handling JSON responses

I have successfully implemented an exception handler for DataNotExistException: @ExceptionHandler(DataNotExistException.class) @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Data not exist") public void handleDataNotExistException() { } My go ...

Developing a JSON object for an HTTP POST request

I am attempting to send a JSON string to the post method to retrieve flight information. I have an example JSON that I need to modify for different requests. { "request": { "passengers": { "adultCount": 1 }, "slice": [ { ...

Ensuring JS consistently monitors changes in value

Is there an equivalent of (void update) in Unity that is called every frame in Web Development (using JavaScript)? "I want it to continuously check if certain values have changed and then update them accordingly." let governmentprice = parseFloat(select ...

Optimizing web content for iOS Safari with min-height media queries

I'm currently working on a Bootstrap-based photo browser that needs to have a responsive 4:3 aspect ratio. To achieve this, I have implemented the following approach: #carousel { width: 320px; height: 240px; ... } Additionally, I utilize media ...

Design a unique border for a div element that extends a top-border all the way through the header and a bottom-border that

I am trying to achieve the design displayed in this mockup: Here is my current progress: https://codepen.io/raney24/pen/VOmjBY .header-border { width: 100%; margin-bottom: 10px; border-left: red solid 1px; border-right: red solid 1px; border- ...

Looking for a way to customize it using @emotion/styled? Dealing with the deprecated makeStyles from MUI problem?

I have been working on setting up my styling using @emotion since makestyles were removed in React 18. Despite making changes as per my research, I am not seeing any updates reflected on my page. The expected result looks like this: https://i.stack.imgur. ...

The full execution of Jquery show() does not pause until it finishes

Here is the sequence I want to achieve: Show a div element with the CSS class yellow Execute a function for about 5 seconds Remove the yellow class and add the green CSS class "state Ok" However, when running my code, the div container does not appear u ...

Display the remainder of an image's height within a div container

Here is the code snippet I am working with: HTML: <div id="mapWrapper" style="height: 624px;"> <div class="box" id="map"> <h1>Campus</h1> <p>Description Campus Map.</p> <img src="abc.png" ...

Grid X Transformation 3: Dynamically alter grid cell background based on value (no need for CSS classes)

While working with GXT2, it was possible to dynamically change a cell's background color using the GridCellRenderer's render method. However, in GXT3, this feature no longer exists. The suggested approach is to utilize a GridViewConfig and overri ...

What is the method for combining two enums in Java?

I've been working on a selenium webdriver project where I have enums for both the environments I'm testing my app in and the app itself. The issue I'm facing is figuring out how to use the environment enum inside the app enum to open the app ...

Having trouble with clicking on an icon link within a list

Seeking assistance with creating a social media icon/link list for the first time on this platform. Any help is appreciated! <div class="social-links"> <ul> <li class="m-link"> <a href="&q ...

The process of mapping and unmapping a Map using Jersey

There are many instances where a Map is passed as an object in a class and annotated with a customized XMLJavaAdapter for marshalling/unmarshalling the data. However, my goal is to directly pass a Map as the requestedEntity in a POST request and receive th ...