@@ -188,18 +188,16 @@ private SearchBar() {
188188 * @param positionY Y坐标
189189 * @param searchBarWidth 宽度
190190 * @param searchBarHeight 高度
191- * @param transparentColor 透明的背景颜色
192- * @param contentPanel 内容面板
193191 */
194- private void initFrame (int positionX , int positionY , int searchBarWidth , int searchBarHeight , Color transparentColor , JPanel contentPanel ) {
192+ private void initFrame (int positionX , int positionY , int searchBarWidth , int searchBarHeight ) {
195193 //frame
196194 searchBar .setBounds (positionX , positionY , searchBarWidth , searchBarHeight );
197195 searchBar .setDefaultCloseOperation (JFrame .HIDE_ON_CLOSE );
198196 searchBar .setUndecorated (true );
199197 searchBar .getRootPane ().setWindowDecorationStyle (JRootPane .NONE );
200- searchBar .setBackground (transparentColor );
198+ searchBar .setBackground (new Color ( 0 , 0 , 0 , 0 ) );
201199 searchBar .setOpacity (AllConfigs .getInstance ().getConfigEntity ().getTransparency ());
202- searchBar .setContentPane (contentPanel );
200+ searchBar .setContentPane (searchBarContentPane );
203201 searchBar .setType (JFrame .Type .UTILITY );
204202 searchBar .setAlwaysOnTop (true );
205203 //用于C++判断是否点击了当前窗口
@@ -224,7 +222,7 @@ private void initGUI() {
224222 labelFontColor = new Color (configs .getFontColor ());
225223 initBorder (allConfigs .getBorderType (), new Color (configs .getBorderColor ()), configs .getBorderThickness ());
226224
227- initFrame (positionX , positionY , searchBarWidth , searchBarHeight , transparentColor , searchBarContentPane );
225+ initFrame (positionX , positionY , searchBarWidth , searchBarHeight );
228226
229227 int labelHeight = searchBarHeight / 9 ;
230228 int textFieldHeight = (int ) (labelHeight * TEXT_FIELD_HEIGHT_RATIO );
@@ -263,6 +261,7 @@ private void initGUI() {
263261 searchBar .setIconImage (image );
264262 }
265263 //panel
264+ searchBarContentPane .setDoubleBuffered (true );
266265 searchBarContentPane .setBounds (0 , 0 , searchBarWidth , searchBarHeight );
267266 searchBarContentPane .setLayout (null );
268267 searchBarContentPane .setBackground (transparentColor );
@@ -413,8 +412,9 @@ private void initMenuItems() {
413412 * @param borderColor 边框颜色
414413 * @param borderThickness 边框厚度
415414 */
416- private void initBorder (Constants .Enums .BorderType borderType , Color borderColor , int borderThickness ) {
415+ private void initBorder (Constants .Enums .BorderType borderType , Color borderColor , float borderThickness ) {
417416 double roundRadius = AllConfigs .getInstance ().getConfigEntity ().getRoundRadius ();
417+ int borderThickNessInt = (int ) borderThickness ;
418418 RoundBorder topRound = new RoundBorder (borderColor ,
419419 borderThickness ,
420420 (int ) roundRadius ,
@@ -432,7 +432,7 @@ private void initBorder(Constants.Enums.BorderType borderType, Color borderColor
432432 RoundBorder .ShowLines .ALL );
433433 if (Constants .Enums .BorderType .AROUND == borderType ) {
434434 topBorder = topRound ;
435- middleBorder = BorderFactory .createMatteBorder (0 , borderThickness , 0 , borderThickness , borderColor );
435+ middleBorder = BorderFactory .createMatteBorder (0 , borderThickNessInt , 0 , borderThickNessInt , borderColor );
436436 bottomBorder = bottomRound ;
437437 fullBorder = fullRound ;
438438 } else if (Constants .Enums .BorderType .EMPTY == borderType ) {
@@ -444,9 +444,9 @@ private void initBorder(Constants.Enums.BorderType borderType, Color borderColor
444444 } else if (borderType == Constants .Enums .BorderType .FULL ) {
445445 Border lineBorder = BorderFactory .createMatteBorder (
446446 0 ,
447- borderThickness ,
448- borderThickness ,
449- borderThickness ,
447+ borderThickNessInt ,
448+ borderThickNessInt ,
449+ borderThickNessInt ,
450450 borderColor );
451451 topBorder = topRound ;
452452 middleBorder = lineBorder ;
@@ -2588,6 +2588,9 @@ private void addSearchWaiter(AtomicBoolean isWaiting) {
25882588 }
25892589
25902590 private void setSearchBarRadius (int x , int y , double radius , int width , int height ) {
2591+ Graphics g = searchBar .getGraphics ();
2592+ Graphics2D graphics2d = (Graphics2D ) g ;
2593+ graphics2d .setRenderingHint (RenderingHints .KEY_ANTIALIASING , RenderingHints .VALUE_ANTIALIAS_ON );
25912594 searchBar .setShape (new RoundRectangle2D .Double (x , y , width , height , radius , radius ));
25922595 }
25932596
@@ -4397,7 +4400,7 @@ private void setSearchBarFontColor(int colorNum) {
43974400 textField .setForeground (new Color (colorNum ));
43984401 }
43994402
4400- private void setBorderColor (Constants .Enums .BorderType borderType , int colorNum , int borderThickness ) {
4403+ private void setBorderColor (Constants .Enums .BorderType borderType , int colorNum , float borderThickness ) {
44014404 initBorder (borderType , new Color (colorNum ), borderThickness );
44024405 }
44034406}
0 commit comments