小编Dav*_*e F的帖子

在Gnome顶部栏中设置Java Swing应用程序标题的正确方法是什么?

我正在使用以下代码在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)

java swing gnome-3

5
推荐指数
1
解决办法
186
查看次数

尝试连接到“ smtp.office365.com”时出现MailKit.Security.SslHandshakeException

我正在尝试使用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)

c# email ssl mailkit

4
推荐指数
1
解决办法
2220
查看次数

如何设置从 DependencyObject 派生的类型的 DependencyProperty 的默认值

我正在创建一个不是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)

我有什么办法可以做到这一点吗?

wpf

3
推荐指数
1
解决办法
5568
查看次数

如何加载文本文件的内容并将其显示在 SwiftUI 文本视图中?

我正在使用 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)

ios swift swiftui

2
推荐指数
1
解决办法
1187
查看次数

标签 统计

c# ×1

email ×1

gnome-3 ×1

ios ×1

java ×1

mailkit ×1

ssl ×1

swift ×1

swiftui ×1

swing ×1

wpf ×1