现在,我得到的背景是灰色的.我想把它变成黑色.我尝试过像setBackground(color.BLACK)这样的东西;但它没有用.有什么建议么?public test() {setTitle("Adjustment Form");setSize(670,450);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setLocationRelativeTo(null);setLayout(new GridLayout(4,6,2,2));setVisible(true); }解决方法:你可以打电话:getContentPane().setBackground(Color.black);或者将JPanel添加到您使用的...
模糊背景图像的最佳方法是什么,如下图所示?我看到了一些代码和库,但它们已经有几年的历史了,或者像BlurBehind库一样,但它没有给出相同的效果.提前致谢! 解决方法:最简单的方法是使用库.看一下这个:https://github.com/wasabeef/Blurry 使用库您只需要这样做:Blurry.with(context).radius(10).sampling(8).color(Color.argb(66, 255, 255, 0)).async().onto(rootView);
我在模糊背景上创建透明矩形时遇到问题.我正在尝试在glasspane上完成这项任务.这是我的代码片段.void createBlur() {alpha = 1.0f;JRootPane root = SwingUtilities.getRootPane(jf);blurBuffer = GraphicsUtilities.createCompatibleImage(jf.getWidth(), jf.getHeight());Graphics2D g2d = blurBuffer.createGraphics();root.paint(g2d);g2d.dispose();backBuffer = blurBuffer;blurBuffer = GraphicsUtilities.createThumbnailF...
我有自定义适配器视图的问题.我尝试,更改Click事件的视图背景.我有AdapterView.OnItemClickListener,我得到所选项目,并调用myListView.invalidate(); 无效后,调用适配器getView(…).这里是代码: @覆盖 public View getView(int position,View convertView,ViewGroup parent){View row = convertView;ProjectAdapterData projectItem;if (row == null) {LayoutInflater inflater = LayoutInflater.from(context);row = inflater...
我正在研究一个Java项目来模拟直升机在一个框架中的飞行.直升机使用箭头键在屏幕上移动.我希望直升机能够无限移动,也就是说,当直升机到达框架的边缘时,背景应朝相反的方向移动,以产生无尽的地形效果. 这是我到目前为止的代码:import java.awt.Graphics; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; import java.net.URL; import java.io.IOException;import javax....
我想要做的是水平移动背景并让它无限重复. 我尝试使用带有动画的ImageSwitcher来实现这种效果,但无法让它正常工作.这是我到目前为止的代码public class MainActivity extends AppCompatActivity implements ViewSwitcher.ViewFactory {private Animation animSlide;private ImageSwitcher image;private ImageView imagePop;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);set...
问题 我正在尝试使用可选项创建ListView.我希望能够单击ListView中的项目并让项目在列表中更改颜色,然后继续使用行中的数据执行其他操作. 我正在使用SimpleAdapter. 如何制作它,以便当我点击一行时,它会变成另一种颜色,然后当我点击另一行时,新行被选中并更改为新颜色,旧行变回正常? 码 到目前为止,这是我的代码. DBTools类具有我希望在ListView中显示的所有数据,并且需要处理. getAllReceivers()方法返回包含所有数据的HashMap< ...
我是制作GUI的新手,所以我决定尝试使用windows构建器进行eclipse,虽然很棒,但我确实有些疑惑.我一直在搜索,但我找不到找到一个很好的方法来添加背景图像到我的“菜单”.例如我试过这个:public Menu() {setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(50, 50, 300, 250); //DimensionescontentPane = new JPanel() { //Imagen de Fondopublic void paintComponent(Graphics g) { Image img = Toolkit.getDefaultTool...
我在更改ListView中的视图背景时遇到问题. 我需要的:在onClick()上更改行的背景图像 实际发生了什么:在按下例如后,背景被改变(选择)第一个条目.但在向下滚动后,也会选择第8个条目.滚动回到顶部,第一个不再被选中.现在选择第二个条目.继续滚动,继续跳… 我在代码中的内容:我有通道,onClick()我切换选择的通道布尔值的属性然后我改变了背景.我只是在onClick()这样做,这就是为什么我不明白为什么它也会在其他条目上发生.我注意到的...
我想在导航抽屉里的android菜单中设置所有标题项的背景颜色.我的布局看起来像:<menu xmlns:android="http://schemas.android.com/apk/res/android"><item android:title="TopItem" android:id="@+id/top_item1"> // Here i want to set the background<menu><group><item android:id="@+id/sub_item1"android:title="SubItem" /> // Here no background</group></menu></item><item android:title="TopItem" android:id="@+id/top...
我有一个JPanel,我想添加一个图像作为其背景.我怎样才能做到这一点 ?frame = new JFrame("Some frame"); panel1 = new JPanel(); panel1.setBorder(new EmptyBorder(5, 5, 5, 5)); // NEED TO ADD AN IMAGE TO THIS PANELpanel1.setLayout(cardlayout); frame.getContentPane().add(panel1);frame.setLocationByPlatform(true); frame.setVisible(true);我需要在面板中添加图像,我该怎么办? 更新1panel1 = new JPanel(){private ...
您好我使用JPanel作为我的框架的容器然后我真的想在我的面板中使用背景图片我真的需要帮助这是我的代码到目前为止.这是更新,请在这里查看我的代码import java.awt.*; import javax.swing.*; import java.awt.event.*;public class imagebut extends JFrame {public static void main(String args []) {imagebut w = new imagebut();w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);w.setSize(300,300);w.setVisible(true);} pub...
我正在尝试设置Swing Jtable的行颜色.我使用这个类来扩展Jtable作为网上的建议.public class ColorTable extends JTable {private static final long serialVersionUID = 1L;private Map rowColor = new HashMap();private Map columnColor = new HashMap();private Color cellColor;private Color defaultColor;public ColorTable( TableModel model ) {super( model );}public void setRowColor( int row, Color c) {rowColor.pu...
我刚刚开始使用android开发,我需要有关背景图像的帮助.我希望能够有一个背景图像,然后用布局覆盖其他项目(按钮,文本等).我使用LinearLayout只是为了简单,因为我不知道什么对我来说最好. 无论如何,我无法使用以下代码显示图像:import android.app.Activity; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.widget.*;public class NewGameActivity extends ...
我想创建一个背景颜色的屏幕,从红色变为蓝色.出于某种原因,当我尝试实例化ValueAnimator时它总是崩溃.我不知道我的代码有什么问题 谢谢 动画课public BackgroundAnimation(Context context){super(context);ValueAnimator colorAnim = ObjectAnimator.ofInt(R.anim.animator, "backgroundColor", Color.RED, Color.BLUE);colorAnim.setDuration(3000);colorAnim.setEvaluator(new ArgbEvaluator());colorAnim.setRepeatCount(Value...