我正在使用以下代码在Gnome 3的顶部栏中设置我的Java Swing应用程序的标题.但是,当我运行它时,我会收到代码下方显示的警告.有没有更好的方法在代码中设置应用程序标题?请注意,这不是关于设置窗口标题本身的问题.
try
{
Toolkit toolkit = Toolkit.getDefaultToolkit();
Field awtAppClassNameField = toolkit.getClass().getDeclaredField("awtAppClassName");
awtAppClassNameField.setAccessible(true);
awtAppClassNameField.set(toolkit, "FNDice");
}
catch (NoSuchFieldException | IllegalAccessException e)
{
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
以下是我在运行应用程序时看到的警告.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.gmail.fishnet37222.fndice.App (file:/home/dave/IdeaProjects/fndice/target/classes/) to field sun.awt.X11.XToolkit.awtAppClassName
WARNING: Please consider reporting this to the maintainers of com.gmail.fishnet37222.fndice.App
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用MailKit通过“ smtp.office365.com”发送电子邮件。这是我正在使用的代码。
using (var client = new SmtpClient(new ProtocolLogger("smtp.log")))
{
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect("smtp.office365.com", 587, SecureSocketOptions.SslOnConnect);
client.Authenticate(new SaslMechanismNtlmIntegrated());
Debug.WriteLine(client.IsAuthenticated);
client.Send(message);
client.Disconnect(true);
}
Run Code Online (Sandbox Code Playgroud)
SaslMechanismNtlmIntegrated
我从GitHub上的此评论获得的课程。
每当我运行此代码时,我都会得到一个SslHandshakeException
。
以下是例外的详细信息:
MailKit.Security.SslHandshakeException
HResult=0x80131500
Message=An error occurred while attempting to establish an SSL or TLS connection.
One possibility is that you are trying to connect to a port which does not support SSL/TLS.
The other possibility is that the SSL certificate presented by the server is not …
Run Code Online (Sandbox Code Playgroud) 我正在创建一个不是UserControl的自定义 WPF 控件。此自定义控件有两个属性(UnselectedAppearance 和 SelectedAppearance)。这两个属性具有相同的类型(外观),均派生自 DependencyObject。Appearance 类本身有几个 DependencyProperties。我想知道为每个外观属性设置默认值的正确方法。我尝试过如下代码,但是当我尝试在设计器中使用自定义控件时,会引发异常。
public static readonly DependencyProperty UnselectedAppearanceProperty = DependencyProperty.Register("UnselectedAppearance", typeof(Appearance), typeof(FNDie), new PropertyMetadata(new Appearance()));
Run Code Online (Sandbox Code Playgroud)
我有什么办法可以做到这一点吗?
我正在使用 SwiftUI 创建一个新的 iOS 应用程序,并且需要在文本视图中显示文本文件的内容。我知道如何加载文件的内容并将它们存储在字符串变量中。我的问题是找到放置该代码的正确位置,以便在创建文本视图时可以引用它。下面是托管相关文本视图的视图的代码。
struct LicenseView: View {
var body: some View {
Text("") // How do I populate this with the contents of a text file?
.navigationBarTitle("License")
.navigationBarItems(trailing: Button("Check In"){})
}
}
Run Code Online (Sandbox Code Playgroud)