- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 JFrame
上加载了一个 JPanel
。 JPanel 包含 4 个 JButton。我想要做的是自动将焦点放在第一个 jbutton 上,这样我就可以使用键盘在 JButton 之间移动。
我在 jpanel 的构造函数中尝试了 jButton1.requestFocusInWindow();
代码,但仍然无法正常工作。有什么我想念的吗?我还能做什么?
编辑:工程包含3个java文件,代码如下:
新JFrame.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sampleui;
import java.awt.Container;
import java.awt.Toolkit;
import javax.swing.JRootPane;
import javax.swing.UIManager;
/**
*
* @author Administrator
*/
public class NewJFrame extends javax.swing.JFrame {
static Container container;
/**
* Creates new form NewJFrame
*/
public NewJFrame() {
initComponents();
rootPane= getRootPane();
container=getContentPane();
setSize(Toolkit.getDefaultToolkit().getScreenSize());
setVisible(true);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jMenuItem1 = new javax.swing.JMenuItem();
jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jDesktopPane1 = new javax.swing.JDesktopPane();
jMenuItem1.setText("jMenuItem1");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("This is the Title");
jPanel1.setBackground(new java.awt.Color(204, 204, 204));
jPanel1.setLayout(new java.awt.BorderLayout());
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jPanel1.add(jLabel2, java.awt.BorderLayout.PAGE_START);
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel5.setForeground(new java.awt.Color(51, 51, 51));
jLabel5.setText("dfgdfgdfg");
jPanel1.add(jLabel5, java.awt.BorderLayout.LINE_START);
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel6.setText("dfgdfgdfg");
jPanel1.add(jLabel6, java.awt.BorderLayout.LINE_END);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("dfgdfgfdgfdgfdg");
jPanel1.add(jLabel1, java.awt.BorderLayout.CENTER);
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setText("jLabel3");
jPanel1.add(jLabel3, java.awt.BorderLayout.PAGE_END);
getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);
jPanel2.setBackground(new java.awt.Color(204, 204, 204));
jPanel2.setLayout(new java.awt.BorderLayout());
jLabel7.setText("jLabel7");
jPanel2.add(jLabel7, java.awt.BorderLayout.LINE_START);
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel8.setText("jLabel8");
jPanel2.add(jLabel8, java.awt.BorderLayout.LINE_END);
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel9.setText("jLabel9");
jPanel2.add(jLabel9, java.awt.BorderLayout.CENTER);
getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_END);
jDesktopPane1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jDesktopPane1MouseClicked(evt);
}
});
getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER);
pack();
}// </editor-fold>
private void jDesktopPane1MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
container=getContentPane();
setSize(Toolkit.getDefaultToolkit().getScreenSize());
setVisible(true);
//callCompanyOption();
container.setVisible(false);
jDesktopPane1.setVisible(false);
NewJPanel p=new NewJPanel();
//p.setBounds(40, 30, 1200, 786);
container.add(p);
container.setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JDesktopPane jDesktopPane1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
// End of variables declaration
}
NewJPanel.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sampleui;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.KeyEvent;
/**
*
* @author Administrator
*/
public class NewJPanel extends javax.swing.JPanel {
/**
* Creates new form NewJPanel
*/
public NewJPanel() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel2 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jButton2 = new javax.swing.JButton();
jXMonthView1 = new org.jdesktop.swingx.calendar.JXMonthView();
setLayout(new java.awt.GridBagLayout());
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
add(jPanel2, new java.awt.GridBagConstraints());
jButton2.setText("OK");
jButton2.setNextFocusableComponent(jButton2);
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
}
});
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton2.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jButton2KeyPressed(evt);
}
});
jXMonthView1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jXMonthView1KeyPressed(evt);
}
});
javax.swing.GroupLayout jXMonthView1Layout = new javax.swing.GroupLayout(jXMonthView1);
jXMonthView1.setLayout(jXMonthView1Layout);
jXMonthView1Layout.setHorizontalGroup(
jXMonthView1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
jXMonthView1Layout.setVerticalGroup(
jXMonthView1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 160, Short.MAX_VALUE)
);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(64, 64, 64)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
.addComponent(jXMonthView1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(56, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jXMonthView1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
add(jPanel1, new java.awt.GridBagConstraints());
}// </editor-fold>
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
jPanel1.setVisible(false);
NewJFrame.container.remove(NewJPanel.this);
NewJPanel1 p=new NewJPanel1();
NewJFrame.container.add(p);
}
private void jButton2KeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
int key=evt.getKeyCode();
if(key==KeyEvent.VK_ENTER)
{
System.out.println("Enter Pressed");
jPanel1.setVisible(false);
NewJFrame.container.remove(NewJPanel.this);
NewJPanel1 p=new NewJPanel1();
NewJFrame.container.add(p);
}
}
private void jXMonthView1KeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
jButton2.requestFocus();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jPanel1.setVisible(false);
NewJFrame.container.remove(NewJPanel.this);
NewJPanel1 p=new NewJPanel1();
NewJFrame.container.add(p);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private org.jdesktop.swingx.calendar.JXMonthView jXMonthView1;
// End of variables declaration
}
NewJPanel1.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sampleui;
import java.awt.Window;
import java.awt.event.KeyEvent;
import javax.swing.JRootPane;
/**
*
* @author Administrator
*/
public class NewJPanel1 extends javax.swing.JPanel {
//=new NewJFrame();
/**
* Creates new form NewJPanel1
*/
public NewJPanel1() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
setRequestFocusEnabled(false);
addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
formKeyPressed(evt);
}
});
setLayout(new java.awt.GridBagLayout());
jPanel1.setNextFocusableComponent(jButton5);
jPanel1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jPanel1KeyPressed(evt);
}
public void keyReleased(java.awt.event.KeyEvent evt) {
jPanel1KeyReleased(evt);
}
});
jButton1.setText("back");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
jButton1MouseEntered(evt);
}
});
jButton1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jButton1KeyPressed(evt);
}
});
jButton2.setText("jButton2");
jButton2.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jButton2KeyPressed(evt);
}
});
jButton3.setText("jButton3");
jButton3.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jButton3KeyPressed(evt);
}
});
jButton4.setText("jButton4");
jButton4.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jButton4KeyPressed(evt);
}
});
jButton5.setText("jButton5");
jButton5.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jButton5.setFocusCycleRoot(true);
jButton5.setFocusTraversalPolicyProvider(true);
jButton5.setInheritsPopupMenu(true);
jButton5.setNextFocusableComponent(jButton4);
jButton5.setVerifyInputWhenFocusTarget(false);
jButton5.requestFocusInWindow();
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButton5.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jButton5KeyPressed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(41, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(38, 38, 38))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jButton5.getAccessibleContext().setAccessibleParent(this);
add(jPanel1, new java.awt.GridBagConstraints());
//jButton1.requestFocusInWindow();
//NewJFrame.getRootPane().setDefaultButton(jButton1);
//jButton1.requestFocus();
}// </editor-fold>
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
jPanel1.setVisible(false);
NewJFrame.container.remove(NewJPanel1.this);
NewJPanel p=new NewJPanel();
NewJFrame.container.add(p);
}
private void jPanel1KeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
System.out.println("Key Pressed");
}
private void jButton5KeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
int key=evt.getKeyCode();
if(key==KeyEvent.VK_ESCAPE)
{
System.out.println("Escape Pressed");
jPanel1.setVisible(false);
NewJFrame.container.remove(NewJPanel1.this);
NewJPanel p=new NewJPanel();
NewJFrame.container.add(p);
}
}
private void jButton4KeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
int key=evt.getKeyCode();
if(key==KeyEvent.VK_ESCAPE)
{
System.out.println("Escape Pressed");
jPanel1.setVisible(false);
NewJFrame.container.remove(NewJPanel1.this);
NewJPanel p=new NewJPanel();
NewJFrame.container.add(p);
}
}
private void jButton3KeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
int key=evt.getKeyCode();
if(key==KeyEvent.VK_ESCAPE)
{
System.out.println("Escape Pressed");
jPanel1.setVisible(false);
NewJFrame.container.remove(NewJPanel1.this);
NewJPanel p=new NewJPanel();
NewJFrame.container.add(p);
}
}
private void jButton2KeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
int key=evt.getKeyCode();
if(key==KeyEvent.VK_ESCAPE)
{
System.out.println("Escape Pressed");
jPanel1.setVisible(false);
NewJFrame.container.remove(NewJPanel1.this);
NewJPanel p=new NewJPanel();
NewJFrame.container.add(p);
}
}
private void jButton1KeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
int key=evt.getKeyCode();
if(key==KeyEvent.VK_ESCAPE||key==KeyEvent.VK_ENTER)
{
jPanel1.setVisible(false);
NewJFrame.container.remove(NewJPanel1.this);
NewJPanel p=new NewJPanel();
NewJFrame.container.add(p);
}
}
private void jButton1MouseEntered(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void formKeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
System.out.println("key pressed");
}
private void jPanel1KeyReleased(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
public static javax.swing.JPanel jPanel1;
// End of variables declaration
使按钮能够获得焦点的原因是通过箭头键或键盘在按钮之间遍历。
最佳答案
方法
jButton1.requestFocus();
应该工作得很好。但是当你调用这个方法时它是必不可少的。
该方法必须在按钮显示后调用。这意味着,不要在构造函数中调用 requestFocus()
,而是在面板已经可见时调用它。
这是一些伪代码:
public NewJFrame() {
initComponents();
//some methods ommitted
setVisible(true);
//change to NewJPanel1
//request focus after displaying the NewJPanel1
}
编辑:这是一个可能解决方案的具体实现。
NewPanel.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jPanel1.setVisible(false);
NewJFrame.container.remove(NewJPanel.this);
NewJPanel1 p=new NewJPanel1();
NewJFrame.container.add(p);
p.initFocus();
}
NewJPanel1.java
public void initFocus() {
jButton5.requestFocus();
}
关于java - 自动聚焦于 jpanel 上的 jButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14499950/
我想做的是,如果鼠标位于“下一个”按钮上,它会以慢速向右滚动,如果鼠标没有位于“下一个”按钮上,它会停止滚动? 这是我的尝试http://jsfiddle.net/mdanz/nCCRy/14/ $(
StyleCop 是一个很棒的视觉工作室小插件。但它不会向您显示实时提示或提供任何自动修复。 随之而来的是 reSharper 和 StyleCop for reSharper,这是理想的解决方案,但
我为我的MatchQuery使用了模糊性选项,但是我想将模糊性值设置为auto。有什么办法吗? 另外,对于完成建议程序,您可以将其设置为支持unicode,对于我的MatchQuery,有什么方法可以
我想从表中获取一行[字符串名称,字符串密码,int 某些内容]并将其映射到一个 User 对象,该对象具有 3 个属性,如上面的 getter 和 setter有什么方法可以自动完成吗?我考虑过反射,
我有一个像这样的方法:void m1(string str) 并且有一个像这样的类: public class MyClass { public bool b1 { set; get; }
我正在尝试使用 $rootScope 从一个 Controller 向另一个 Controller $broadcast 一些数据。 如果我使用像 ng-click 这样的触发器来运行将广播的功能,它
我考虑了很多关于是要使用完全自动化的缓存还是手动缓存。 我们的自动方法是一种解决方案,它可以挖掘数据库、查询和格式化每个潜在和 future 的数据请求,并将其保存到适当的缓存存储(内存缓存或基于磁盘
我的 CSS 必须使用过渡来更改,直到现在我都使用 div:hover 来实现。 当您单击另一个 div 时需要激活过渡,而不是当您将鼠标悬停在必须移动/更改的 div 上时。 我该怎么做? 谢谢 永
在我的应用程序中,我需要一些动画,但如果它已经设置了动画,则不需要持续时间。但我的问题是它会自动添加持续时间。 在这里你可以看到 2 个函数,第二个没有持续时间但它确实有持续时间(可能从 1 秒开始)
两年前,我需要制作一个工具,通过 POST 自动将 txt/csv 文件上传到我的 Web 服务器,然后使用 cronjob 通过 PHP 对其进行解析。 这有两次在每天午夜自动发生。尽管这行得通,但
请阅读下面程序中的评论: #include void test(char c[]) { c=c+2; //why does this work ? c--; printf("%
也许是个幼稚的问题,但是...... 确认或拒绝: 自动和静态存储持续时间的对象/变量的内存的存在是在编译时确定的,程序运行时失败的可能性绝对为零,因为没有足够的内存用于自动对象。 自然地,当自动对象
有没有什么方法可以自动获得类中属性更改的通知,而不必在每个 setter 中都编写 OnPropertyChanged? (我有数百个属性,我想知道它们是否已更改)。 安东建议 dynamic pro
我们在使用 Azure DevOps 的项目中采用了 gitflow 流程。我有以下场景: 当功能分支合并到 Develop 时,我想在完成拉取请求的同时执行压缩合并策略 当 Release 分支定期
我的网站上有一个评论部分,我将 html 编码的评论保存在我的数据库中。所以我添加了这条评论- "testing" `quotes` \and backslashes\ and html 并将其保存在
是否存在“ checkin 前 TFS 自动 checkout ”这样的功能,以便在我说“ checkin ”之前我不会 checkout 任何文件,例如以防我只是临时更改文件 - 这一直发生。 换句
我有一个运行在 Linux/Apache/Tomcat 堆栈上的网站,它需要每隔几个月自动脱机以进行服务器维护,这将持续任意时间。有哪些选项可以让 Apache 建立和取消“服务器维护”页面? 我需要
我经常在工作中创建文档,在公司内部,由于我们使用的首字母缩写词和缩写词的数量,我们几乎拥有自己的语言。因此,我厌倦了在发布文档之前手动创建首字母缩写词和缩写表,并且快速的谷歌搜索发现了一个可以有效地为
我希望在用户或宏将计算模式从自动更改为手动或手动更改为自动时运行代码。是否有为此触发的事件? (属性是 Application.Calculation 在 Excel 互操作中。) 使用 Excel
这个问题在这里已经有了答案: Repeat command automatically in Linux (13 个回答) 6年前关闭。 我想创建一个脚本来获取另一个文件夹中的所有文件夹名称。并为这些
我是一名优秀的程序员,十分优秀!