Getting an error with an image URL in JavaFX - javafx

I saved my PNG folder in same folder which contains the main class
and used that PNG file in an image tag in sample.fxml and tried to display it, which worked fine.
But when I try to map it to a string in main, it shows an error.
I have uploaded the image to show my PNG folder on the left panel.
Sample.fxml
<ImageView fx:id="user1" fitHeight="150.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" x="150.0" y="50.0">
<image>
<Image url="#PNG/AceClub.png"/>
</image>
</ImageView>
Main.java
for(int i=0;i<suit.length;i++) {
// ImageStore.cardimagedeck.put(rank[j]+suit[i],new Image("#PNG/"+rank[j]+suit[i]+".png"));
for(int j=0;j<rank.length;j++) {
javafx.scene.image.Image image=new Image("#PNG/AceClub.png");
ImageStore.cardimagedeck.put(rank[j] + suit[i], image);
}
}
Error:
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
at javafx.graphics/javafx.scene.image.Image.validateUrl(Image.java:1107)
at javafx.graphics/javafx.scene.image.Image.<init>(Image.java:617)
at Card/sample.Main.loadimages(Main.java:35)
at Card/sample.Main.start(Main.java:18)
application screenshot

Related

Picker in React-native

Just started learning React-native.
I'm getting stuck on the picker component.
Picker not working on react-native": "0.68.2
I installed it --> npm i #react-native-picker/picker
Imported --> import {Picker} from '#react-native-picker/picker';
But still getting error message
#react-native-picker/picker could not be found within the project or in these directories: node_modules ..\node_modules
Tried a simple program to list languages, not working!
class testingPicker extends Component {
state = {
language:'a'
}
render(){
return(
<View>
<Picker
style={{width:'100%'}}
>
{/* Adding options to picker */}
<Picker.Item label="A" value="a"/>
<Picker.Item label="B" value="b"/>
</Picker>
</View>
)
}
}
export default testingPicker;
User "react-native-picker-select" library for picker in react native
For more details Visit
https://blog.logrocket.com/how-to-use-react-native-picker-select/

resolve-url-loader error when using image in jsx files in React Application

I'm rewriting old code and I want to move image definition from .css files ( background: url('./../images/something.svg') ) to .jsx and also I'm removing webpack and want to use only react-script. When I move the image to .jsx file that I first import the image import something from '../../../images/something.png'; and then I use it <img src={something} alt="Something" /> after this I'm getting error Module build failed (from ./node_modules/resolve-url-loader/index.js): Error: resolve-url-loader: error processing CSS file://C:\dev\my-project\src\images\something.png:1:1: Unknown word or Unclosed string in the end
When you import images to jsx file your syntax will look like this
import img from '../../../images/something.png'
const App = () => {
return(
<>
<img src={img}/>
</>
);
}
when you import you add image to "variable" at this case it's img
As you import footer in this line import footer from '../../../images/something.png';, you must use footer as a variable in the attribute's value of img tag because it specifies the path to the image.
For example,
Code must be
<img src={footer} alt="Something" />
Instead of
<img src={something} alt="Something" />

nextjs Image property null

I have a component with dynamic content like so :
<Image width="680" height="400" src={post.imgsrc} alt={post.title} />
I keep having the same error even if I have added the width/height :
Image with src "/imgs/paintings/2022/2.jpg" must use "width" and "height" properties or "layout='fill'" property.
I don't know why, and I wonder why I have to specify width and height since my pictures have different sizes...
One thing to mention is that you can import the images if they are local, if you want that you do not need to use width, height, or fill.
They get provided automatically
Example from the docs:
import profilePic from '../public/me.png'
import Image from 'next/image'
import profilePic from '../public/me.png'
function Home() {
return (
<>
<h1>My Homepage</h1>
<Image
src={profilePic}
alt="Picture of the author"
// width={500} automatically provided
// height={500} automatically provided
// blurDataURL="data:..." automatically provided
// placeholder="blur" // Optional blur-up while loading
/>
<p>Welcome to my homepage!</p>
</>
)
}
This also explains why remote images do need these properties.

How to fix Xamarin.Forms iOS color disparity on TitleBar image VS TitleBar background when Android does not have this issue

I have an Image (that is the size of a banner) that has a background color #F6D401 and needs to go to TopBar, for branding.
in App.xaml I set:
<Application.Resources>
<ResourceDictionary>
<Color x:Key="Primary">#f6d401</Color>
<Color x:Key="TextColor">#5a5a5a</Color>
Then in AppShell.xaml
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="Shell.ForegroundColor" Value="{StaticResource Primary}" />
Then on pages:
<Shell.TitleView>
<Image
HorizontalOptions="Center"
VerticalOptions="Center"
Source="logo.png" />
</Shell.TitleView>
On Android I get a background banner and all the colors the same color, which is exactly what I want and what is expected.
on iOS, however, colors do not seem to match
I am assuming there is a default setting on iOS somewhere that is doing this, that needs to be changed.
How do I make banner and icon colors to match?
Please add UINavigationBar.Appearance.Translucent = false; to AppDelegate.cs
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
UINavigationBar.Appearance.Translucent = false;
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
Here is running screenshot.

Xamarin Forms Shell titlebar color not set correctly in dark theme

I have a xamarin forms shell application. I set the titlebar color with this style:
<Color x:Key="BackgroundColorDark">#121212</Color>
<Color x:Key="BackgroundColorLight">#EFF2F5</Color>
<Color x:Key="TextPrimaryColor_Dark">#FFFFFF</Color>
<Color x:Key="TextPrimaryColor_Light">#323130</Color>
<Style x:Key="BaseStyle"
TargetType="Element"
ApplyToDerivedTypes="True">
<Setter Property="Shell.BackgroundColor"
Value="{AppThemeBinding Dark={StaticResource BackgroundColorDark}, Light={StaticResource BackgroundColorLight}}" />
<Setter Property="Shell.ForegroundColor"
Value="{AppThemeBinding Dark={StaticResource TextPrimaryColor_Dark}, Light={StaticResource TextPrimaryColor_Light}}" />
<Setter Property="Shell.DisabledColor"
Value="#B4000000" />
<Setter Property="Shell.UnselectedColor"
Value="#CC0000" />
<Setter Property="Shell.NavBarHasShadow"
Value="false"/>
</Style>
In light theme this works as expected and it is the same as the background:
But in dark theme it seems the title bar has a different color:
Since it looks as if the title bar is translucent I tried to explicitly deactivate that with the ios specific setting on the navigation page but that didn't work.
ios:NavigationPage.IsNavigationBarTranslucent="true"
How can I apply the background color in dark theme correctly?
Xamarin Forms Version: 4.8.0.1269
Source Code Repository: https://github.com/NPadrutt/MoneyFox.Windows/tree/mobile-redesign
In the iOS.project, you can set UINavigationBar.Appearance.Translucent = false; in FinishedLaunching method to remove the default alpha.
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental");
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
UINavigationBar.Appearance.Translucent = false;
return base.FinishedLaunching(app, options);
}
}

Resources