我想在我的JMenu中放置一个翻转效果,这是我的代码:
Icon firstPicAcc= new ImageIcon(Welcome.class.getResource("/app/resources/user1.jpg"));
Icon secPicAcc= new ImageIcon(Welcome.class.getResource("/app/resources/user2.jpg"));
JMenu mnAccountSettings = new JMenu("Account Settings");
mnAccountSettings.addMouseWheelListener(new MouseWheelListener() {
public void mouseWheelMoved(MouseWheelEvent arg0) {
}
});
mnAccountSettings.setFont(new Font("Dialog", Font.PLAIN, 20));
mnAccountSettings.setForeground(new Color(0, 153, 0));
mnAccountSettings.setBackground(new Color(255, 204, 255));
mnAccountSettings.setRolloverEnabled(true);
mnAccountSettings.setIcon(firstPicAcc);
mnAccountSettings.setRolloverIcon(secPicAcc);
mnAccount.add(mnAccountSettings);
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?谢谢!应该发生的是当我将鼠标滚过JMenu栏时,原始图标应该变成另一个图标.
我试图导入它但我遇到了一些错误.
这是我的错误:
08:49:13 PM恢复dbDB(联系)运行:mysql --defaults-extra-file ="/ tmp/tmpdwf14l/extraparams.cnf"--host = 127.0.0.1 --user = root --port = 3306 - -default-character-set = utf8 - 注释第22行的ERROR 1046(3D000):未选择数据库
使用exitcode 1操作失败08:49:13 PM恢复dbDBB(课程)运行:mysql --defaults-extra-file ="/ tmp/tmpMW20Fb/extraparams.cnf"--host = 127.0.0.1 --user = root - -port = 3306 --default-character-set = utf8 ERROR 1046(3D000)第22行:未选择数据库
我正在创建一个独立但不在线的系统.它是一个基于java的系统.我只想让我的UI看起来像Windows 8中的那样.这可能吗?
我想通过点击键盘上的"enter"键关闭我的JDialog.我怎样才能做到这一点?谢谢!注意:我想这样做,不涉及任何按钮.谢谢!
我有两个标签,一个用于添加,一个用于删除JtextFields.我可以添加jTextField并删除它们,但我的目标是删除标签点击上的文本字段.
下面的图片显示了我的目标,每次点击"+"标签,它下面的文本字段都会被创建.当我单击" - "标签时,同一行上的文本字段将被删除.我应该怎么做才能实现这一目标?
这是我的代码:
lblRemoveTf = new JLabel();
lblRemoveTf.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
for(JTextField myTxt1 : myListOfTxtNum){
eto1 = myTxt1;
}
myListOfTxtNum.remove(eto1);
pnlTxtTxt.remove(pnlTxtTxt.getComponentAt(eto1.getLocation()));
frmGM.revalidate();
frmGM.repaint();
for(JTextField myTxt : myListOfTxtName){
eto = myTxt;
}
myListOfTxtName.remove(eto);
pnlTxtTxt.remove(pnlTxtTxt.getComponentAt(eto.getLocation()));
x-=50;
y-=50;
frmGM.revalidate();
frmGM.repaint();
}
});
lblRemoveTf.setBounds(450,6, 125, 25);
pnlTxtTxt.add(lblRemoveTf);
lblRemoveTf.setIcon(new ImageIcon(GroupManagement.class.getResource("/app/resources/minussmall.png")));
lblAddNewTF = new JLabel();
lblAddNewTF.setBounds(420, 6, 38, 25);
lblAddNewTF.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
count++;
txtStudentName= new JTextField();
txtStudentNumber = new JTextField();
myListOfTxtName.add(txtStudentName);
myListOfTxtNum.add(txtStudentNumber);
txtStudentName.setName("txtStudentname"+count);
txtStudentNumber.setName("txtStudentNumber" …Run Code Online (Sandbox Code Playgroud)