我有一个JTextField,我想setMargin.但是当我设置任何边框时,它都不能正常工作.它的保证金功能不起作用.这是我的代码;
import java.awt.Color;
import java.awt.Insets;
import java.io.IOException;
import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class ImageField {
public static void main(String[] args) throws IOException {
JTextField textField = new JTextField();
textField.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
textField.setMargin(new Insets(0, 20, 0, 0));
JOptionPane.showMessageDialog(null, textField, "",
JOptionPane.PLAIN_MESSAGE);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我告诉这一行,它是有效的
//textField.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
Run Code Online (Sandbox Code Playgroud) 正如标题所说,我只是试图在TextArea上设置一个LineBorder设置的边距(提供一些填充).没有设置边框,.setMargins工作正常.这是特定的代码块.
aboutArea = new JTextArea("program info etc.....");
Border border = BorderFactory.createLineBorder(Color.BLACK);
aboutArea.setSize(400, 200);
aboutArea.setBorder(border);
aboutArea.setEditable(false);
aboutArea.setFont(new Font("Verdana", Font.BOLD, 12));
add(aboutArea);
Run Code Online (Sandbox Code Playgroud)
我尝试过以下各项:
aboutArea.setMargins(10,10,10,10);
.getBorders(aboutArea).set(10,10,10,10);
UIManager.put("aboutArea.margin", new Insets(10, 10, 10, 10));
Run Code Online (Sandbox Code Playgroud)
但是在应用边框后没有任何影响边距,填充总是为0.任何想法如何在带有边框的textArea上设置填充?
我在 SwiftUI 中创建了一个文本字段和一个安全文本字段,但我不知道如何在 SwiftUI 中将图像添加到我的文本字段/安全文本字段中。SwiftUI 的在线文档并不像旧版本的 Swift 那样多。我还想将(占位符/输入文本)移动指定的数量,例如向右移动 30 点。我还试图查看背景颜色是否会从白色变为红色,但正如您所看到的,它在我的代码中对 UI 没有影响。
注意:我在代码中调用了 GeometryReader 以及用户名和密码的 @state 变量。
VStack (spacing: deviceSize.size.height * (50/812)) {
TextField ("Username", text: self.$username)
.foregroundColor(.black)//text color when you type
.accentColor(.blue)//cursor color
.background(Color(.red))//????
.textFieldStyle(RoundedBorderTextFieldStyle())
.cornerRadius(50)
// .border(Color.white)
//.font(.title)
SecureField ("Password", text: self.$password)
.textFieldStyle(RoundedBorderTextFieldStyle())
.cornerRadius(50)
}
.padding(.init(top: 0, leading: deviceSize.size.width * (38/375), bottom: 0, trailing: deviceSize.size.width * (38/375)))
Run Code Online (Sandbox Code Playgroud) 
我想要上面按钮的插入效果."文本"取消似乎是按下的类型.我在网上尝试了很多例子,但他们没有白色背景示例.
帮助我获得这种效果.
提前致谢!!
我在matplot lib中创建了一个图,我希望在该图中添加一个插图.我希望绘制的数据保存在我在其他图中使用的字典中.我在循环中找到了这个数据,然后我再次为子图运行这个循环.以下是相关部分:
leg = []
colors=['red','blue']
count = 0
for key in Xpr: #Xpr holds my data
#skipping over what I don't want to plot
if not key[0] == '5': continue
if key[1] == '0': continue
if key[1] == 'a': continue
leg.append(key)
x = Xpr[key]
y = Ypr[key] #Ypr holds the Y axis and is created when Xpr is created
plt.scatter(x,y,color=colors[count],marker='.')
count += 1
plt.xlabel(r'$z/\mu$')
plt.ylabel(r'$\rho(z)$')
plt.legend(leg)
plt.xlim(0,10)
#Now I wish to create the inset
a=plt.axes([0.7,0.7,0.8,0.8])
count = 0
for …Run Code Online (Sandbox Code Playgroud) 是否可以使用 CSS3 Box Shadow 实现淡出效果?
这是我到目前为止所拥有的这只会在垂直侧面添加插入/内部阴影,但我需要在顶部实现淡出效果。
-moz-box-shadow: inset 5px 0 7px -5px #a4a4a4, inset -5px 0 7px -5px #a4a4a4;
-webkit-box-shadow: inset 5px 0 5px -5px #a4a4a4, inset -5px 0 5px -5px #a4a4a4;
box-shadow: inset 5px 0 7px -5px #a4a4a4, inset -5px 0 7px -5px #a4a4a4;
Run Code Online (Sandbox Code Playgroud)
请参阅下图以查看预期结果和我目前拥有的结果。

我想要一个图像(最好是SVG)作为R中现有图形的插图,并在图像周围放置黑色边框。
R中的基本功能可能吗?我需要包装吗?
我有JScrollPane,它只包含一个JTree实例.如何在JScrollPane中设置JTree周围的边距?
我有这样的代码
tree.setPreferredSize(new Dimension(200, 200));
JScrollPane scrollerTree = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollerTree.setPreferredSize(new Dimension(200, 199));
scrollerTree.getVerticalScrollBar().setUnitIncrement(16);
Run Code Online (Sandbox Code Playgroud)
我想实现,利用滚动窗格内容可以滚动边距.
请看这个小提琴,或下面的代码:
http://jsfiddle.net/MegaMatt3/92G6X/9/
HTML:
<div id="outer">
<div id="inner"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#outer {
border: 1px solid black;
box-shadow: 0 0 20px rgba(0, 0, 0, 1) inset;
height: 200px;
position: relative;
width: 200px;
}
#inner {
background-color: #55A8FF;
bottom: 0;
height: 50px;
left: 0;
position: absolute;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
如果我有一个父元素,一个插入框阴影和一个子元素,子元素将显示在框阴影的顶部.如果可能的话,我希望子元素"在盒子阴影下面".效果基本上会在子元素顶部显示插入框阴影.
我已经搞砸了z-index,但没有运气.这可能吗?任何帮助将非常感激.谢谢.
编辑:
这个问题现在有点混乱了,但我原来的问题应该表明我正在寻找一种解决方案,当外部div具有不透明的背景时可以使用.我已经更新了我的原始小提琴和代码以反映这种情况.这里的其他答案都是有效的,但我标记为正确的答案在这种情况下适合我.