Граница кнопки только с одной стороны, Ограничить пользователя для изменения размера HBox внутри SplitPane, Кнопка остановки текста, мерцающая при наведении курсора мыши - PullRequest
0 голосов
/ 08 июня 2019

Я использую конструктор сцен и NetBeans 11. У меня три проблемы.Изображения включены для лучшего понимания моей проблемы.

  1. Когда я запускаю свой проект калькулятора, пользователь может изменить размер textField, который находится внутри HBox.На нем появляется стрелка изменения размера, и я могу прокрутить ее вверх и изменить ее размер.Я не хочу изменять его размер после запуска проекта.

  2. При наведении курсора мыши на кнопку текст внутри автоматически сжимается и становится маленьким.Я хочу, чтобы текст остался в своем первоначальном размере.Я не знаю, почему это происходит.Я не смог найти этот код ни в одном из моих файлов.

  3. Я хочу иметь рамку только справа от кнопки, которая является дочерней по отношению к gridPane.Когда я использую -fx-border- (свойство CSS), отображается граница с четырех сторон кнопки.Я хочу, чтобы это было только на одной стороне.

Изменить размер изображения стрелки https://imgur.com/eY0pnz3

Изображение после изменения размера https://imgur.com/jRIbVTN

Проблема сжатия текста https://imgur.com/r30ya97

Эффект одной боковой границы https://imgur.com/wj6uver

Я хочу, чтобы вместо красных линий, показанных с помощью CSS *, была линия белого глянцевого эффекта

Вот мой код fxml

.<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.MenuButton?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="563.0" prefWidth="342.0" stylesheets="@../styles/Styles.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <SplitPane dividerPositions="0.5" orientation="VERTICAL" prefHeight="200.0" prefWidth="342.0" AnchorPane.bottomAnchor="363.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
        <items>
            <HBox fx:id="hboxView" maxHeight="-Infinity" prefHeight="49.0" prefWidth="341.0">
               <children>
                  <MenuButton fx:id="optionView" alignment="BOTTOM_CENTER" mnemonicParsing="false" prefHeight="46.0" prefWidth="47.0" stylesheets="@../styles/Styles.css" HBox.hgrow="ALWAYS">
                    <items>
                      <MenuItem fx:id="opt_std" mnemonicParsing="false" text="Standard" />
                      <MenuItem fx:id="opt_sci" mnemonicParsing="false" text="Scientifics" />
                    </items>
                  </MenuButton>
               </children>
            </HBox>
            <HBox prefHeight="100.0" prefWidth="200.0">
               <children>
                  <TextField fx:id="textView" editable="false" prefHeight="141.0" prefWidth="342.0" HBox.hgrow="ALWAYS" />
               </children>
            </HBox>
        </items>
      </SplitPane>
      <GridPane fx:id="gridView" layoutX="-2.0" layoutY="227.0" prefHeight="363.0" prefWidth="342.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="199.8">
        <columnConstraints>
          <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
          <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
        </columnConstraints>
        <rowConstraints>
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
          <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
          <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
          <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
        </rowConstraints>
         <children>
            <Button fx:id="minus" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="70.0" text="-" textAlignment="CENTER" GridPane.columnIndex="4" GridPane.rowIndex="1">
               <font>
                  <Font size="22.0" />
               </font>
               <graphic>

               </graphic>
            </Button>
            <Button fx:id="plus" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="70.0" prefWidth="71.0" text="+" textAlignment="CENTER" GridPane.columnIndex="4">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="cancel" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="69.0" text="X" textAlignment="CENTER" GridPane.columnIndex="3">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="allClear" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="74.0" text="AC" textAlignment="CENTER" GridPane.columnIndex="3" GridPane.rowIndex="1">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="four" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="70.0" text="4" textAlignment="CENTER" GridPane.columnIndex="2" GridPane.rowIndex="1">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="nine" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="75.0" prefWidth="68.0" text="9" textAlignment="CENTER" GridPane.columnIndex="2">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="five" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="70.0" text="5" textAlignment="CENTER" GridPane.columnIndex="1" GridPane.rowIndex="1">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="six" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="71.0" text="6" textAlignment="CENTER" GridPane.rowIndex="1">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="Eight" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="75.0" prefWidth="68.0" text="8" textAlignment="CENTER" GridPane.columnIndex="1">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="percentage" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="73.0" text="\%" textAlignment="CENTER" GridPane.columnIndex="3" GridPane.rowIndex="3">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="decimal" alignment="CENTER" contentDisplay="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="68.0" text="." textAlignment="CENTER" GridPane.columnIndex="2" GridPane.rowIndex="3">
               <font>
                  <Font size="32.0" />
               </font>
            </Button>
            <Button fx:id="zero" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="70.0" text="0" textAlignment="CENTER" GridPane.columnIndex="1" GridPane.rowIndex="3">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="squareRoot" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="67.0" text="sqrt" textAlignment="CENTER" GridPane.rowIndex="3">
               <font>
                  <Font size="20.0" />
               </font>
            </Button>
            <Button fx:id="divide" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="74.0" text="/" textAlignment="CENTER" GridPane.columnIndex="4" GridPane.rowIndex="2">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="equal" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="70.0" text="=" textAlignment="CENTER" GridPane.columnIndex="3" GridPane.rowIndex="2">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="one" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="72.0" text="1" textAlignment="CENTER" GridPane.columnIndex="2" GridPane.rowIndex="2">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="two" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="69.0" text="2" textAlignment="CENTER" GridPane.columnIndex="1" GridPane.rowIndex="2">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="three" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="68.0" text="3" textAlignment="CENTER" GridPane.rowIndex="2">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="mul" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="72.0" text="*" textAlignment="CENTER" GridPane.columnIndex="4" GridPane.rowIndex="3">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="sin" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="70.0" text="Sin" textAlignment="CENTER" GridPane.rowIndex="4">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="73.0" text="x^2" textAlignment="CENTER" GridPane.columnIndex="4" GridPane.rowIndex="4" fx:id="xSquare">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="74.0" text="1/x" textAlignment="CENTER" GridPane.columnIndex="3" GridPane.rowIndex="4" fx:id="xInverse">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="tan" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="74.0" prefWidth="68.0" text="Tan" textAlignment="CENTER" GridPane.columnIndex="2" GridPane.rowIndex="4">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="cos" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="70.0" prefWidth="68.0" text="Cos" textAlignment="CENTER" GridPane.columnIndex="1" GridPane.rowIndex="4">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="seven" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="75.0" prefWidth="68.0" text="7" textAlignment="CENTER">
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
         </children>
      </GridPane>
   </children>
</AnchorPane>

Вот мой код CSS

.button {
    -fx-font-weight: bold;
}

#optionView
{
    -fx-border-width: 1.4;
    -fx-border-color: black;
    -fx-background-color:rgb( 244, 208, 63 );
    -fx-background-size: 30,30;
    -fx-background-repeat: no-repeat;
    -fx-background-position:left,center;
    -fx-background-image: url(option.png);
}
#hboxView
{
 -fx-background-color: rgb(42,71,71);   
}
#gridView
{
    -fx-background-color:white;

}
#optionView:hover
{
    -fx-background-color: rgb( 88, 214, 141 );
}
#optionView:pressed
{
    -fx-background-color: rgb( 88, 214, 141 );
}

#opt_std
{
    -fx-font-weight: bold;  
}
#opt_sci
{
    -fx-font-weight: bold;
}

#textView
{
    -fx-text-fill: white;
    -fx-font-weight:bold;
    -fx-background-color:  rgb(42,71,71) ;    
}
.button{
    -fx-background-radius: 0;
}
#one
{

    -fx-text-fill:White;


    -fx-background-color:rgb(42,71,71);
}

#two
{

    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#three
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#four
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#five
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#six
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#seven
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#Eight
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#nine
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#ten
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#cancel
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#allClear
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}

#equal
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#squareRoot
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#zero
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#decimal
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#percentage
{
    -fx-text-fill:White;
    -fx-background-color:rgb(42,71,71);
}
#plus
{
    -fx-text-fill:rgb( 243, 156, 18 );
    -fx-background-color:rgb(42,71,71);
}
#minus
{
    -fx-text-fill:rgb( 243, 156, 18 );
    -fx-background-color:rgb(42,71,71);
}
#divide
{
    -fx-text-fill:rgb( 243, 156, 18 );
    -fx-background-color:rgb(42,71,71);
}
#sin
{
    -fx-text-fill:rgb( 243, 156, 18 );
    -fx-background-color:rgb(42,71,71);
}
#cos
{
    -fx-text-fill:rgb( 243, 156, 18 );
    -fx-background-color:rgb(42,71,71);
}
#tan
{
    -fx-text-fill:rgb( 243, 156, 18 );
    -fx-background-color:rgb(42,71,71);
}
#xInverse
{
    -fx-text-fill:rgb( 243, 156, 18 );
    -fx-background-color:rgb(42,71,71);
}
#xSquare
{
    -fx-text-fill:rgb( 243, 156, 18 );
    -fx-background-color:rgb(42,71,71);
}
#mul
{
    -fx-text-fill:rgb( 243, 156, 18 );
    -fx-background-color:rgb(42,71,71);

}

Пожалуйста, обратитесь ко всем изображениям

...