天道酬勤,学无止境

translucency

Java Swing - 半透明组件(Java Swing - Translucent Components)

问题 我最近问了一个关于半透明组件导致奇怪的工件似乎没有正确更新的问题。 我收到的答案导致文物消失,但以半透明为代价。 解决方案是 - 对于每个半透明组件 - 也调用 setOpaque(false) 函数。 这样,Swing 就知道它需要重新绘制这些组件背后的背景。 然而,这是以我试图实现的半透明为代价的。 它导致组件变得透明。 前提是这样的:我正在为一个聊天客户端设计 GUI,一个功能请求是有背景的。 我通过遵循用于扩展 JPanel 类的代码片段成功地使背景工作,但随后我希望组件允许显示背景。 设置它们的半透明后,更新组件的残余会显示在它们不应该出现的地方。 我来到这里并解决了我的问题,但现在我遇到了一个新问题。 所以我们来了。 所以,这是我的猜测: - 为每个所需的组件调用 setOpaque(false) 函数而不设置半透明颜色并不能达到我想要的效果。 - 设置半透明颜色而不调用 setOpaque(false) 允许显示半透明背景,但会导致伪影,让我回到第一个。 所以我需要在没有伪影的透明和有伪影的半透明之间有一些中间地带。 也就是说,我想要一个没有伪影的半透明背景(不完全透明)。 似乎我将需要覆盖 JFrame 以使其重新绘制其所有组件,而不管不透明度如何。 除非我遗漏了什么……这就是我来这里的原因! 谢谢! (这是原始问题的链接,附有图片供参考:Java Swing

2021-10-22 15:03:29    分类:技术分享    user-interface   swing   components   transparency   translucency

Java Swing - 导致工件的半透明组件(Java Swing - Translucent Components causing Artifacts)

问题 我目前正在为大学课程开展一个小组项目,但我遇到了一些绊脚石。 我们决定实施的程序是一个带有中央服务器的点对点聊天客户端,用于存储和共享用户名等。我被指派做 GUI。 一个朋友开玩笑地建议我包括“一个燃烧的背景!” 所以我决定这样做,但要有一个用户选择的背景图像。 照原样,只有点点滴滴的背景图像和它上面的所有组件都是可见的,所以我决定尝试实现半透明。 这就是我的问题所在: 当从输入框向聊天窗口发送信息时,或浏览好友列表时,或滚动聊天窗口时,会留下奇怪的工件。 这些工件有时是发送按钮的半透明“幽灵”,有时是菜单的一部分,或旧文本。 在我看来,整个框架没有被正确重绘,但我不确定它是如何工作的。 对于实现 JTextComponent 的组件,我将它们的选择颜色设置为半透明颜色。 对于其他组件,我将背景设置为半透明。 我有一个函数 setTranslucency(Component com) ,它查看一个组件,根据它的内容设置它的半透明,然后查看它是否是某种容器并递归设置每个项目的半透明。 现在,我发现解决此问题的方法是将窗口拖出视线(例如最小化或将窗口拖出屏幕并返回)。 所以, 1)有没有办法强制整个窗口更新,就像我将它拖出屏幕或最小化它一样? 要么, 2)我一开始就做错了吗? 如果是这样,我将如何修复它? 这是一张图片供参考: http://i.stack.imgur.com

2021-10-22 14:34:03    分类:技术分享    java   user-interface   swing   transparency   translucency

Transparent AWT component, possible?

I'm in the need of a translucent AWT component/container to be placed on top of other components to receive the mouse events. The problem here is to create a translucent component. My investigation so far showed that Swing has the possiblity to do setOpaque(false) on e.g. a JPanel. Is there something similiar for AWT? The idea is to make a ScrollPane scrollable by simply clicking somewhere and moving the mouse around. Thats why I need a transparent component to place it above all other components. Long story short, I need a translucent component, no matter which one, to place on top of other

2021-10-18 11:55:38    分类:问答    java   swing   awt   transparent   translucency

Translucent QWidget should be clickable cross-os

I'm trying to accomplish the following with a Qt (C++) app, cross OS. Upon running the program a new window pops up, a fullscreen QWidget. Now I want this to be see-through/transparent, so the user won't actually see it. On this 'layer' a user can drag his/her mouse to draw a (red) rectangle to select an area which is - when the mouse is released - taken a screenshot of. The problem: The issue lays in the whole transparent layer thing since this doesn't appear to work well cross OS. Because when I click on where the layer is, to invoke the mousePressEvent(), I click through it on to the window

2021-10-03 06:55:09    分类:问答    c++   qt   cross-platform   qwidget   translucency

如何在半透明的 QWidget 上播放视频?(How to play a video on a translucent QWidget?)

问题 我想使用 QVideoWidget 或 QGraphicsVideoItem 在具有 Qt::FramelessWindowHint 标志和 Qt::WA_TranslucentBackground 属性的 QWidget 上播放电影。 但是视频看不到。 我只听到声音。 问题是什么? 编辑: #include "videoplayer.h" #include <QtWidgets/QApplication> #include "qboxlayout.h" #include "qvideowidget.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *w = new QWidget; w->setWindowFlags(Qt :: Window | Qt::FramelessWindowHint ); w->setAttribute(Qt::WA_TranslucentBackground, true); w->setMinimumSize(300,200); QVideoWidget *videoWidget = new QVideoWidget; QBoxLayout *controlLayout = new QHBoxLayout; controlLayout-

2021-09-13 18:11:02    分类:技术分享    qt   qwidget   translucency

Java Swing - Translucent Components

I recently asked a question about translucent components causing odd artifacts from seemingly not updating properly. The answer I received caused the artifacts to go away, but at the cost of translucency. The solution was to- for every translucent component- also call the setOpaque(false) function. This way, Swing knew that it needed to redraw the background behind those components. However, this came at the cost of the translucency that I was trying to achieve. It caused the components to become transparent instead. The premise is this: I am designing the GUI for a chat client, and a feature

2021-09-02 23:14:07    分类:问答    user-interface   swing   components   transparency   translucency

How to play a video on a translucent QWidget?

I want to play a movie on a QWidget that has Qt::FramelessWindowHint flag and Qt::WA_TranslucentBackground attirbute using QVideoWidget or QGraphicsVideoItem. But the video is not visible. I hear only sound. What is the problem? Edit: #include "videoplayer.h" #include <QtWidgets/QApplication> #include "qboxlayout.h" #include "qvideowidget.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *w = new QWidget; w->setWindowFlags(Qt :: Window | Qt::FramelessWindowHint ); w->setAttribute(Qt::WA_TranslucentBackground, true); w->setMinimumSize(300,200); QVideoWidget

2021-08-31 23:01:46    分类:问答    qt   qwidget   translucency

Java Window Translucency on Linux

Using Java 7 window translucency on Windows XP SP3, Vista, 7, 8 and Mac OS X Mountain Lion works great. However, on Linux I cannot get it to work properly. Using the tutorial found here, specifically the GradientTranslucentWindow example, it seems to work great. But if you change the color to something other than white (the only change I made was set R to 0 in the example code), the frame does not composite correctly: The isWindowTranslucencySupported method returns true for PERPIXEL_TRANSLUCENT. I'm running Ubuntu 12.04 LTS 32bit with Compiz composite manager with the Composite plugin turned

2021-08-31 08:51:55    分类:问答    java   linux   swing   translucency

iPhone: problems with translucent black uistatusbar with view layout

I am having some issues with my status bar. This is an iPhone app, not an iPad app. I would like to have a Black Translucent status bar everywhere in the app. I have set the status bar style in the app plist. It is set to black translucent. My understanding is that when this is set, the layout of all the views will start at 0,0 and not 0,20 like it does when you have an opaque status bar. This is why IB gives you the option to specify a hint of what sort of status bar you will be using so it can simulate it and display it correctly in IB. (And yes ALL my views in IB are set to show a black

2021-08-12 06:18:46    分类:问答    iphone   ios   layout   translucency   uistatusbar

iOS 7 导航栏颜色无法在 iPhone 4 上正确显示(iOS 7 navbar colours not showing properly on iPhone 4)

问题 我的导航栏颜色在 iOS 7 中正常显示 部署iOS 6.0,但如果系统版本为iOS 7.0或更高版本,部分导航栏颜色在iPhone 4上无法正常显示。在iPhone 5上工作正常。 这是我的做法: if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) { self.edgesForExtendedLayout = UIRectEdgeNone; [self.navigationController.navigationBar setBarTintColor:[UIColor blueColor]]; [self.navigationController.navigationBar setTranslucent:YES]; } #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 也许最后一行是问题(setTranslucent),因为我听说 iPhone 4 在半透明方面存在一些问题,但我很确定您也可以在 iOS 6 中将导航栏设置为半透明。 接下来将尝试摆脱它

2021-08-12 00:53:51    分类:技术分享    iphone   uinavigationbar   ios7   iphone-4   translucency