第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > java jpanel方法 Java JPanel.putClientProperty方法代码示例

java jpanel方法 Java JPanel.putClientProperty方法代码示例

时间:2022-02-11 09:35:27

相关推荐

java jpanel方法 Java JPanel.putClientProperty方法代码示例

import javax.swing.JPanel; //导入方法依赖的package包/类

private JPanel createContainer(ProfilerFeature feature) {

JPanel container = new JPanel(new BorderLayout(0, 0));

container.putClientProperty(ProfilerFeature.class, feature);

JPanel results = feature.getResultsUI();

JPanel xresults = new JPanel(new BorderLayout()) {

public void paint(Graphics g) {

super.paint(g);

if (hintLabel != null) {

Dimension dim = hintLabel.getSize();

int x = (getWidth() - dim.width) / 2;

int y = (getHeight() - dim.height) / 2;

g.setColor(hintColor);

g.fillRect(x - XMAR, y - YMAR, dim.width + XMAR * 2, dim.height + YMAR * 2);

g.setColor(Color.LIGHT_GRAY);

g.drawRect(x - XMAR, y - YMAR, dim.width + XMAR * 2, dim.height + YMAR * 2);

g.translate(x, y);

hintLabel.paint(g);

g.translate(-x, -y);

}

}

};

xresults.add(results, BorderLayout.CENTER);

container.add(xresults, BorderLayout.CENTER);

JPanel settings = feature.getSettingsUI();

if (settings != null) {

JPanel pan = new JPanel(new BorderLayout(0, 0)) {

public void setVisible(boolean visible) {

super.setVisible(visible);

for (Component c : getComponents()) c.setVisible(visible);

}

};

pan.setOpaque(true);

pan.setBackground(UIUtils.getProfilerResultsBackground());

pan.add(settings, BorderLayout.CENTER);

JSeparator sep = UIUtils.createHorizontalLine(pan.getBackground());

pan.add(sep, BorderLayout.SOUTH);

pan.setVisible(settings.isVisible());

container.add(pan, BorderLayout.NORTH);

}

return container;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。