- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在为自定义源服务器浏览器制作一个 GUI,并改进过滤功能。
这就是我所拥有的so far .
但是,当我 resize ...
当我调整窗口大小时,我希望 L4D2“过滤器面板”调整大小到容器的当前最大宽度。我还希望能够在列中添加更多此类面板(例如框布局提供的面板)。
Boxlayout 使面板出现在列中,但它对它们的宽度没有任何作用。我想我可能需要重写过滤器面板的首选大小方法,以便它们可以检索父容器的大小,但我不确定如何执行此操作。
我应该如何解决这个问题?
编辑:这是一个描述问题的示例程序。
import javax.swing.*;
import java.awt.*;
public class guiExampleProblem {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final MyWindows wnd = new MyWindows("guiExampleProblem");
wnd.setVisible(true);
}
});
}
}
class MyWindows extends JFrame {
public MyWindows(String text) {
super(text);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
JPanel containerPanel1 = new JPanel();
JPanel containerPanel2 = new JPanel();
JPanel containerPanel3 = new JPanel();
containerPanel1.setBackground(Color.BLACK);
containerPanel2.setBackground(Color.RED);
containerPanel3.setBackground(Color.GREEN);
mainPanel.add(containerPanel1);
mainPanel.add(containerPanel2);
mainPanel.add(containerPanel3);
this.add(mainPanel);
pack();
}
}
调整窗口大小时,我希望面板仅沿 x 轴扩展,并在 y 轴上保持恒定高度,但在示例中,面板在 x y 轴上扩展。
最佳答案
我设法通过重写“过滤器面板”getPreferedSize 方法来获得所需的功能,以便它们检索父容器宽度并使用它。以下是示例形式的代码:
import javax.swing.*;
import java.awt.*;
public class guiExampleProblem {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final MyWindows wnd = new MyWindows("guiExampleProblem");
wnd.setVisible(true);
}
});
}
}
class MyWindows extends JFrame {
public MyWindows(String text) {
super(text);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new FlowLayout());
JPanel containerPanel1 = new JPanel() {
@Override
public Dimension getPreferredSize() {
return new Dimension(this.getParent().getWidth(),60);
}
};
JPanel containerPanel2 = new JPanel() {
@Override
public Dimension getPreferredSize() {
return new Dimension(this.getParent().getWidth(),60);
}
};
JPanel containerPanel3 = new JPanel() {
@Override
public Dimension getPreferredSize() {
return new Dimension(this.getParent().getWidth(),60);
}
};
containerPanel1.setBackground(Color.BLACK);
containerPanel2.setBackground(Color.RED);
containerPanel3.setBackground(Color.GREEN);
mainPanel.add(containerPanel1);
mainPanel.add(containerPanel2);
mainPanel.add(containerPanel3);
this.add(mainPanel);
pack();
}
}
关于JavaGUI : Box layout with width fit to container?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21282795/
如果没有 Google Fit 应用程序,是否可以使用 Google Fit API? 我想使用 Google Fit API 来计算步数,但是可以在不安装 Google Fit 应用程序的情况下完成
我的应用程序中实现的代码曾经有效,数据已正确插入/显示在 Google Fit 中,但现在不起作用。 我还测试了 BasicHistoryApi 但它不起作用。( https://github.com
我正在努力显示与 Google Fit 应用程序相同的 Activity 历史记录。我在 session 方面做得很好,但我无法正确掌握自动记录的 Activity 。就像示例中的这两个顶级行走一样。
我在使用 Google Fit Api 获取行进距离时遇到问题。我对计步器使用了类似的方法并且有效。它只是说听众已注册。 大部分代码来自 Github 示例。 有什么问题吗? public class
我正在使用此代码尝试检索过去 14 小时内执行的步骤。 YApp myApp = (mYApp) ctx; mGoogleApiClient = myApp.getMyUser();
使用 google fit api 时是否有配额和请求限制?我想使用 google fit api,我很好奇使用它时是否有限制。 最佳答案 您可以在 Google Developer Console
使用 google fit api 时是否有配额和请求限制?我想使用 google fit api,我很好奇使用它时是否有限制。 最佳答案 您可以在 Google Developer Console
无论是使用 fit$loadings 还是使用 fit$Vaccounted 检查它们,我都得到不同的方差值,这些值由因子分析中的因子解释。我正在使用带有 fa() 函数的 psych 包。如果它们应
如果我进入 google api Playground,我会执行以下步骤: 第 1 步:选择并授权 API。我选择两个范围 https://www.googleapis.com/auth/fitnes
我正在执行 https://developers.google.com/fit/android/get-started 中提到的步骤实现一个简单的健身 Android 应用程序。 但是当我想这样做的时
在过去的 6 个月里,我一直在将我的体重输入 Google Fit,现在我想把我的数据拿出来。 访问 Google Fit REST API 不是问题。然而,在所有可访问的数据中找到我的体重数据让我很
我最近尝试尝试使用 Google Fit 应用程序并尝试了 Google Fit developer site 中给出的步骤.并使用了 Android 示例中给出的代码 BasicSensorApi在
我正在创建可以使用 google fit api 的应用程序。 我想获得 google fit 中可用的所有事件( Action )。这里是 google fit 中的事件列表 Reference 。
我尝试了随机森林回归。 代码如下。 import numpy as np from sklearn.preprocessing import StandardScaler from sklearn.m
Google Play documentation claims this is an API_NOT_CONNECTED code ,但是为了访问 Google Fit API,我已经完成了我(认为
我正在使用google javascript api 。为了获取卡路里,我正在使用下一个数据源: 派生:com.google.calories.expished:com.google.android.
我开发了一个需要显示每日步数的应用程序。为此,我使用了 Google Fit SDK 中提供的 API。 似乎一切正常,但我得到的步数与 Google Fit 官方应用程序中显示的步数不匹配。 例如,
我正在尝试从 google fit API 检索用户的每周步数数据,但我从官方 google fit App 数据中获得了不同的步数结果。例如:星期四通过 google fit api 检索到的步数是
我们已经在我们的用户群中发现,自上次 google fit 应用程序更新以来,数据急剧下降,自开始以来,我们一直试图找出代码中的问题。给出时间,我们认为我们使用的版本(当时是 18.0)是问题所在。
拟合高斯混合模型(X-Y数据集)后,如何获取每个分布的参数?例如每个分布的均值、标准差、权重和角度? 我想我可以找到代码 here : def make_ellipses(gmm, ax):
我是一名优秀的程序员,十分优秀!