修改Button的边框

在TinyLookAndFeel.java 的 protected void initComponentDefaults(UIDefaults table)  方法中设置

 

table.put("Button.border",
   new BorderUIResource.CompoundBorderUIResource(
    new TinyButtonBorder(),
    new BasicBorders.MarginBorder()));

 

 

 

TinyButtonBorder是继承AbstractBorder.java和实现UIResource.java 的类

 

 

public class TinyButtonBorder extends AbstractBorder implements UIResource {
	
	protected final Insets borderInsets = new Insets(2, 2, 2, 2);

	/**
	 * Draws the button border for the given component.
	 *
	 * @param mainColor The component to draw its border.
	 * @param g The graphics context.
	 * @param x The x coordinate of the top left corner.
	 * @param y The y coordinate of the top left corner.
	 * @param w The width.
	 * @param h The height.
	 */
	public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
		switch (Theme.derivedStyle[Theme.style]) {
			case Theme.TINY_STYLE :
				drawTinyBorder(c, g, x, y, w, h);
				break;
			case Theme.W99_STYLE :
				drawWinBorder(c, g, x, y, w, h);
				break;
			case Theme.YQ_STYLE :
				drawXpBorder(c, g, x, y, w, h);
				break;
		}
	}

	private void drawTinyBorder(Component c, Graphics g, int x, int y, int w, int h) {
	}

	private void drawWinBorder(Component c, Graphics g, int x, int y, int w, int h) {
		AbstractButton b = (AbstractButton)c;
		boolean isDefault = (c instanceof JButton) && (((JButton)c).isDefaultButton());
		
		if(b.getModel().isPressed() ||
			((b instanceof JToggleButton) && b.isSelected()))
		{
			g.setColor(Color.BLACK);
			g.drawRect(0, 0, w - 1, h - 1);
			
			g.setColor(Theme.buttonDarkColor[Theme.style].getColor());
			g.drawRect(1, 1, w - 3, h - 3);
			return;
		}
		else if(isDefault && b.isEnabled()) {
			g.setColor(Theme.buttonDefaultColor[Theme.style].getColor());
			g.drawRect(0, 0, w - 1, h - 1);
			x += 1; y += 1; w -= 1; h -= 1;
		}
		
		if(!b.isEnabled()) {
			g.setColor(Theme.buttonLightDisabledColor[Theme.style].getColor());
		}
		else {
			g.setColor(Theme.buttonLightColor[Theme.style].getColor());
		}
		g.drawLine(x, y, w - 2, y);
		g.drawLine(x, y + 1, x, h - 2);
		
		if(!b.isEnabled()) {
			g.setColor(Theme.buttonBorderDisabledColor[Theme.style].getColor());
		}
		else {
			g.setColor(Theme.buttonBorderColor[Theme.style].getColor());
		}
		g.drawLine(x, h - 1, w - 1, h - 1);
		g.drawLine(w - 1, y, w - 1, h - 1);
		
		if(!b.isEnabled()) {
			g.setColor(Theme.buttonDarkDisabledColor[Theme.style].getColor());
		}
		else {
			g.setColor(Theme.buttonDarkColor[Theme.style].getColor());
		}
		g.drawLine(x + 1, h - 2, w - 2, h - 2);
		g.drawLine(w - 2, y + 1, w - 2, h - 2);
	}

	private void drawXpBorder(Component c, Graphics g, int x, int y, int w, int h) {
		AbstractButton b = (AbstractButton)c;
		boolean isDefault = (c instanceof JButton) && (((JButton)c).isDefaultButton());
		boolean isComboBoxButton =
			Boolean.TRUE.equals(b.getClientProperty("isComboBoxButton"));

		if(isComboBoxButton) {
			if (!b.isEnabled()) {
				DrawRoutines.drawRoundedBorder(
					g, Theme.comboBorderDisabledColor[Theme.style].getColor(), x, y, w, h);
			}
			else {	
				DrawRoutines.drawRoundedBorder(
					g, Theme.comboBorderColor[Theme.style].getColor(), x, y, w, h);
	
				if(b.getModel().isPressed()) return;

				if(b.getModel().isRollover() && Theme.comboRollover[Theme.style]) {
					DrawRoutines.drawRolloverBorder(
						g, Theme.buttonRolloverColor[Theme.style].getColor(), x, y, w, h);
				}
			}
		}
		else {	// it's a normal JButton or a JSpinner button
			boolean isSpinnerButton =
				Boolean.TRUE.equals(b.getClientProperty("isSpinnerButton"));
			boolean paintRollover =
				(isSpinnerButton && Theme.spinnerRollover[Theme.style]) ||
				(!isSpinnerButton && Theme.buttonRollover[Theme.style]);
			
			if (!b.isEnabled()) {
				DrawRoutines.drawRoundedBorder(
					g, Theme.buttonBorderDisabledColor[Theme.style].getColor(), x, y, w, h);
			}
			else {	
				DrawRoutines.drawRoundedBorder(
					g, Theme.buttonBorderColor[Theme.style].getColor(), x, y, w, h);
	
				if(b.getModel().isPressed()) return;
				
				if(b.getModel().isRollover() && paintRollover) {
					DrawRoutines.drawRolloverBorder(
						g, Theme.buttonRolloverColor[Theme.style].getColor(), x, y, w, h);
				}
				else if(isDefault ||
					(Theme.buttonFocusBorder[Theme.style] && b.isFocusOwner()))
				{
					DrawRoutines.drawRolloverBorder(
						g, Theme.buttonDefaultColor[Theme.style].getColor(), x, y, w, h);
				}
			}
		}
	}

	/**
	 * Gets the border insets for a given component.
	 *
	 * @param c The component to get its border insets.
	 * @return Always returns the same insets as defined in <code>insets</code>.
	 */
	public Insets getBorderInsets(Component c) {
		return borderInsets;
	}
}

 

 

 

JButton去除边框 类似eclipse工具栏的效果,无悬浮,按钮无边框,悬浮时候呈现边框 立即下载

相关推荐

保姆级教程:在S32K312上配置C40驱动,实现Flash读写(基于RTD 4.4.2)

本文详细介绍了在S32K312微控制器上配置C40驱动实现Flash读写的全流程,基于RTD 4.4.2库。内容涵盖环境搭建、外设配置、Flash操作实战代码及高级应用场景,特别针对LLD驱动和FLS存储操作中的常见问题提供了解决方案,帮助开发者快速掌握嵌入式Flash存储技术。

weixin_28684757的博客 262

android button设置边框线

<?xml version="1.0" encoding="utf-8"?> <corners – 四个角的圆角半径,左边右边中间的区别就是在这里体现的 android:topLeftRadius=“5dp” android:bottomLeftRadius=“5dp” android:topRightRadius=“0.1dp” android:bottomRightRadius=“0.1dp” /> <stroke -- 指定边框,边框必须要的 androi

weixin_42504805的博客 3391

Win11内核隔离无法打开的解决方案详解

内核隔离问题的解决需遵循"先硬件后软件"的排查原则,90%以上的案例可通过驱动清理或外设断开解决。对于必须禁用该功能的用户,建议定期使用Windows Defender进行全盘扫描,并保持系统更新至最新版本。技术决策需在安全性和兼容性之间取得平衡,本文提供的多维解决方案可帮助用户构建更稳定的Windows 11使用环境。

mmoo_python的博客 4831

有趣的css - 边框动效按钮

交互感比较强的一个动效按钮。

设计师工作日常 1248

HTML爱心字母雨(完整代码)

HTML语言实现爱心字母雨的完整代码。

AIGC 2万+

手把手教你玩转服务器芯片架构--​​7.1 项目1:基于FPGA的RISC-V软核设计(Verilog实现核心指令执行单元)​

本文介绍了基于FPGA的RISC-V软核设计实践项目。项目采用Verilog实现RV32I指令集核心处理器,包含指令解码、ALU、寄存器堆等关键模块设计,并通过功能仿真验证。在Xilinx Artix-7 FPGA上完成综合与部署,资源利用率控制在5%以内。最后探讨了五级流水线优化、指令集扩展等进阶方案。该实践完整覆盖了从指令集设计、RTL实现到FPGA部署的全流程,可作为学习处理器架构与FPGA开发的典型案例。

MHD0815的博客 178

CSS3设置按钮的样式

平面按钮样式——现主流 在实际开发中,按钮的应用是必不可少 使用 CSS 来制作按钮,可以更有新意,更有趣,也可以自定义自己想要的样式 平面样式按钮的使用现在非常流行,并且符合无处不在的平面设计趋势 实现方式 .button { background-color: #4CAF50; /* Green */ border: none; color: white; padding: 15px 32px; text-align: center; text-dec

视觉软件 3万+

基于Scrapy+Playwright的学术会议信息智能爬取系统实战

本文详细介绍如何使用Python构建一个高效的学术会议信息爬取系统,结合Scrapy框架和Playwright无头浏览器技术,实现对全球学术会议数据的自动化采集、清洗和存储。文章包含完整的技术方案设计、代码实现细节以及性能优化策略,可帮助读者快速掌握现代网络爬虫开发的核心技术。关键词:Python爬虫、Scrapy、Playwright、学术会议、数据采集、反爬对抗python复制下载。

2201_76125261的博客 712

storyboard设置边框颜色_Word教程:只添加一个小小的边框,档次就上升了100倍!...

点击上方[word精品教程]-右上角[...]-[设为星标⭐]即可第一时间获取最新办公资讯日常图文排版的时候,为文档添加一些边框样式进行美化,会使整体排版的质感迅速上升,同时还能“框”住文档内容,让读者的视线聚焦在内容上,避免阅读枯燥。那么,今天在这里给大家分享的Word小技巧,就是如何快速为Word文档添加边框。01添加线型边框(1)点击【设计】-【页面背景】-【页面边框】按钮。(2)...

weixin_39694264的博客 389

从 Chat 提示词到可运行 Fiori 应用,ADT for VS Code 正在把 RAP 开发带进 Agent 时代

本文探讨了在VS Code中使用AI辅助进行ABAP RAP开发的新模式。文章指出,传统RAP开发需要手工创建数据库表、CDS视图、行为定义等十多个关联对象,命名和关联关系容易出错。现在通过GitHub Copilot Agent Mode配合ADT MCP Server,开发者可用自然语言描述业务场景直接生成完整的RAP业务对象。这种生成式开发的核心价值在于:1)通过标准化工具接口(MCP)连接ABAP后端,确保生成符合规范的RAP对象;2)能正确处理多实体组合场景下的命名一致性和关联关系;3)保持生成结

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 89

推免保研夏令营/预推免面试记录—北航网安

链接:https://pan.baidu.com/s/1vkP3EzbVrCc8a7wgQuUZgQ?链接:https://pan.baidu.com/s/1n4EFS2c9WLAfQn91CP4j2g?链接:https://pan.baidu.com/s/1VVNNSfcNDWjXhVhH3MtNjA?上面五个比例基本为:1:5:2:1:1。面试时间:当天上午面试,但是没面完,下午吃了饭之后又继续面试。--来自百度网盘超级会员V5的分享。--来自百度网盘超级会员V5的分享。

admin的博客 3013

MFC修改button的颜色、背景、边框

MFC的button控件是一个不同于其他控件,其CButtton类是CWnd的一个子类,在修改button的背景、颜色和边框的时候必须自己进行编写一个新的类,如CMyButton。下面是进行背景、颜色、边框修改的步骤: 1.在项目->添加类->CMyButton。这样会自动生成两个文件,一个.CPP文件和一个.h文件。例如CMyButton.cpp和CMyButton.h

那片宁静的港湾 2万+

【物联网技术】ESP8266 ESP-01/01s 固件下载烧录+STM32串口通信接线

ESP8266 ESP-01/01s 工作模式接线与MQTT固件下载烧录接线

嵌入式阿齐Archie 3万+

微信小程序button边框修改

刚接触微信小程序,今天碰到个button小问题,所以记录分享一下... 结构: &lt;view class='left'&gt; &lt;button&gt;新品&lt;/button&gt; &lt;button&gt;视频&lt;/button&gt; &lt;button&gt;课程&lt;/button&gt; &lt;but

luckybuling 2573

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

小程序button边框和背景色修改

一:button去掉边框border:none或border:0都无效 因为小程序默认的样式中给button::after{content:""} 自行添加button::after{border:0}去掉button的边框 二:button disable之后背景颜色和字体颜色的值都是默认的。如何修改disable的背景颜色和字体颜色 因为小程序给了button 

sly94的博客 3万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

MFC修改button的颜色、背景、边框、对话框标题

MFC的button控件是一个不同于其他控件,其CButtton类是CWnd的一个子类,在修改button的背景、颜色和边框的时候必须自己进行编写一个新的类,如CMyButton。下面是进行背景、颜色、边框修改的步骤: 1.在项目->添加类->CMyButton。这样会自动生成两个文件,一个.CPP文件和一个.h文件。例如CMyButton.cpp和CMyButton.h

u014260683的专栏 493

微信小程序 - 修改 button 边框和背景色

为什么80%的码农都做不了架构师?>>> ...

weixin_34378922的博客 1万+

Android开发:修改button的边框和点击改变背景

本文内容 讲解如何修改button的边框,点击button改变背景颜色 打开在res/values目录下的color.xml文件,添加代码: &amp;amp;lt;!-- 绿色 --&amp;amp;gt; &amp;amp;lt;color name=&amp;quot;green&amp;quot;&amp;amp;gt;#008000&amp;amp;lt;/color&amp;amp;gt; &amp;amp;lt;

shakdy的博客 1万+

微信小程序button修改边框样式after

这里写自定义目录标题 在微信小程序中,有些功能必须使用button组件(例如:获取用户手机号 (bindgetphonenumber),微信小程序文档官方传送门),如果使用view等组件,然后设置这个属性,点击是无法触发微信手机号授权的,必须使用button组件 我们接入button后 <button class='sure'>确定</button> .sure{ border-radius: 20px; } 效果如下 可以看到边框有灰色的细线, 当我们把.s

戴戴的博客 2872
上一篇: 修改Button的背景颜色
下一篇: 创建一个类后,jar打包 、keytool 数字签名然后web start 发布(1)
longyi_java
博客等级 码龄20年 24粉丝 127原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值