public class DefineEquationQuadratic extends javax.swing.JFrame {
private void nextActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new SelectSolutionsQuadratic().setVisible(true);
String dataSent = aQuadraticSpinner.getValue().toString() + " " + addSubQuadraticComboBox.getSelectedItem();
SelectSolutionsQuadratic transferMe = new SelectSolutionsQuadratic();
transferMe.displayText(dataSent);
}
public class SelectSolutionsQuadratic extends javax.swing.JFrame {
public void displayText(String textToSet) {
displayQuadraticEquation.setText(textToSet);
displayQuadraticEquation.setText("Help); //This doesn't work by the way
System.out.println(textToSet);
}
defineequationquadratic:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package GUI;
/**
*
* @author MatthewAlanTroutman
*/
public class DefineEquationQuadratic extends javax.swing.JFrame {
/**
* Creates new form DefineEquation
*/
public DefineEquationQuadratic() {
initComponents();
}
public DefineEquationQuadratic(String transferData) {
this.transferData = transferData;
initComponents();
}
public String transferData;
/**
* 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() {
graphSelectedLabel = new javax.swing.JLabel();
defineTextLabel = new javax.swing.JLabel();
quadraticEquationTextField = new javax.swing.JTextField();
defineLabel = new javax.swing.JLabel();
xSquaredQuadraticLabel = new javax.swing.JLabel();
addSubQuadraticComboBox = new javax.swing.JComboBox();
xQuadraticLabel = new javax.swing.JLabel();
addSubQuadraticComboBox2 = new javax.swing.JComboBox();
aQuadraticSpinner = new javax.swing.JSpinner();
cQuadraticSpinner = new javax.swing.JSpinner();
bQuadraticSpinner = new javax.swing.JSpinner();
help = new javax.swing.JButton();
close = new javax.swing.JButton();
next = new javax.swing.JButton();
back = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMaximumSize(new java.awt.Dimension(1280, 800));
graphSelectedLabel.setFont(new java.awt.Font("Lucida Grande", 0, 36)); // NOI18N
graphSelectedLabel.setText("You selected the Quadratic graph type");
defineTextLabel.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
defineTextLabel.setText("Please define your graph as an equation in the form of:");
quadraticEquationTextField.setEditable(false);
quadraticEquationTextField.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
quadraticEquationTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
quadraticEquationTextField.setText("ax^2+bx+c");
quadraticEquationTextField.setToolTipText("");
quadraticEquationTextField.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
defineLabel.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
defineLabel.setText("Define:");
xSquaredQuadraticLabel.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
xSquaredQuadraticLabel.setText("x^2");
addSubQuadraticComboBox.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
addSubQuadraticComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "+", "-" }));
xQuadraticLabel.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
xQuadraticLabel.setText("x");
addSubQuadraticComboBox2.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
addSubQuadraticComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "+", "-" }));
aQuadraticSpinner.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
aQuadraticSpinner.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.0d), null, null, Double.valueOf(1.0d)));
aQuadraticSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
aQuadraticSpinnerStateChanged(evt);
}
});
cQuadraticSpinner.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
cQuadraticSpinner.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.0d), null, null, Double.valueOf(1.0d)));
cQuadraticSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
cQuadraticSpinnerStateChanged(evt);
}
});
bQuadraticSpinner.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
bQuadraticSpinner.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.0d), null, null, Double.valueOf(1.0d)));
bQuadraticSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
bQuadraticSpinnerStateChanged(evt);
}
});
help.setFont(new java.awt.Font("Lucida Grande", 0, 48)); // NOI18N
help.setText("Help");
close.setFont(new java.awt.Font("Lucida Grande", 0, 48)); // NOI18N
close.setText("Close");
close.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
closeActionPerformed(evt);
}
});
next.setFont(new java.awt.Font("Lucida Grande", 0, 48)); // NOI18N
next.setText("Next");
next.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nextActionPerformed(evt);
}
});
back.setFont(new java.awt.Font("Lucida Grande", 0, 48)); // NOI18N
back.setText("Back");
back.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(defineTextLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(quadraticEquationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(154, 154, 154))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(graphSelectedLabel)
.addGroup(layout.createSequentialGroup()
.addComponent(defineLabel)
.addGap(18, 18, 18)
.addComponent(aQuadraticSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(xSquaredQuadraticLabel)
.addGap(18, 18, 18)
.addComponent(addSubQuadraticComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(bQuadraticSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(12, 12, 12)
.addComponent(xQuadraticLabel)
.addGap(18, 18, 18)
.addComponent(addSubQuadraticComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(cQuadraticSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addGap(233, 233, 233)
.addComponent(help, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(back, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(close, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(next, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(39, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(77, 77, 77)
.addComponent(graphSelectedLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(defineTextLabel)
.addComponent(quadraticEquationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(77, 77, 77)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(defineLabel)
.addComponent(xSquaredQuadraticLabel)
.addComponent(addSubQuadraticComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(xQuadraticLabel)
.addComponent(addSubQuadraticComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(aQuadraticSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bQuadraticSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cQuadraticSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 211, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(help, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(close, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(next, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(back, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(65, 65, 65))
);
pack();
}// </editor-fold>
private void closeActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void nextActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new SelectSolutionsQuadratic().setVisible(true);
String dataSent = aQuadraticSpinner.getValue().toString() + " " + addSubQuadraticComboBox.getSelectedItem();
SelectSolutionsQuadratic transferMe = new SelectSolutionsQuadratic();
transferMe.displayText(dataSent);
}
private void backActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new GraphEquationSolverGUI().setVisible(true);
}
private void aQuadraticSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {
String aQuadraticSpinnerValue = (String)aQuadraticSpinner.getValue().toString();
if (!"0.0".equals(aQuadraticSpinnerValue))
{
aQuadraticSpinnerValue = aQuadraticSpinnerValue + "x^2";
}
else
{
aQuadraticSpinnerValue = "";
}
System.out.println(aQuadraticSpinnerValue);
transferData = (String)addSubQuadraticComboBox.getSelectedItem();
System.out.println(transferData);
}
private void bQuadraticSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {
String bQuadraticSpinnerValue = (String)bQuadraticSpinner.getValue();
}
private void cQuadraticSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {
String cQuadraticSpinnerValue = (String)cQuadraticSpinner.getValue();
}
/**
* @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(DefineEquationQuadratic.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DefineEquationQuadratic.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DefineEquationQuadratic.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DefineEquationQuadratic.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new DefineEquationQuadratic().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JSpinner aQuadraticSpinner;
private javax.swing.JComboBox addSubQuadraticComboBox;
private javax.swing.JComboBox addSubQuadraticComboBox2;
private javax.swing.JSpinner bQuadraticSpinner;
private javax.swing.JButton back;
private javax.swing.JSpinner cQuadraticSpinner;
private javax.swing.JButton close;
private javax.swing.JLabel defineLabel;
private javax.swing.JLabel defineTextLabel;
private javax.swing.JLabel graphSelectedLabel;
private javax.swing.JButton help;
private javax.swing.JButton next;
private javax.swing.JTextField quadraticEquationTextField;
private javax.swing.JLabel xQuadraticLabel;
private javax.swing.JLabel xSquaredQuadraticLabel;
// End of variables declaration
}
selectsolutionsungratic:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package GUI;
/**
*
* @author MatthewAlanTroutman
*/
public class SelectSolutionsQuadratic extends javax.swing.JFrame {
/**
* Creates new form SelectSolutionsQuadratic
*/
public SelectSolutionsQuadratic() {
initComponents();
}
public SelectSolutionsQuadratic(String theData) {
this.theData = theData;
initComponents();
}
public String theData;
/**
* 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() {
displayQuadraticEquation = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setSize(new java.awt.Dimension(1280, 800));
displayQuadraticEquation.setEditable(false);
displayQuadraticEquation.setColumns(1);
displayQuadraticEquation.setToolTipText("");
displayQuadraticEquation.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
displayQuadraticEquationActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(568, 568, 568)
.addComponent(displayQuadraticEquation, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(422, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(75, 75, 75)
.addComponent(displayQuadraticEquation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(697, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void displayQuadraticEquationActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
public void displayText(String textToSet) {
displayQuadraticEquation.setText(textToSet);
displayQuadraticEquation.setText("Help); //This doesn't work by the way
System.out.println(textToSet);
}
/**
* @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(SelectSolutionsQuadratic.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(SelectSolutionsQuadratic.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(SelectSolutionsQuadratic.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(SelectSolutionsQuadratic.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 SelectSolutionsQuadratic().setVisible(true);
}
});
}
// Variables declaration - do not modify
public javax.swing.JTextField displayQuadraticEquation;
// End of variables declaration
}
您正在创建JFrame
的两个不同实例,特别是SelectSolutionSquadratic
new SelectSolutionsQuadratic().setVisible(true);//1
...
SelectSolutionsQuadratic transferMe = new SelectSolutionsQuadratic();//2
这将创建两个不同的实例。
DisplayText
。//new SelectSolutionsQuadratic().setVisible(true);//REMOVE THIS LINE
String dataSent = aQuadraticSpinner.getValue().toString() + " " +
addSubQuadraticComboBox.getSelectedItem();
SelectSolutionsQuadratic transferMe = new SelectSolutionsQuadratic();
transferMe.displayText(dataSent);
transferMe.setVisible(true);//ADD THIS LINE
我正在学习高级Java并尝试编写一个利用MVC设计模式的程序。程序需要绘制一个字符串,用户可以在中输入该字符串进行修改。用户还可以分别通过一个和一个来调整文本的颜色和字体大小。 以下是我目前掌握的情况: 目前,我只实现了组件(还没有弄清楚如何正确地执行和),即使这样也很难做到完美。 我怀疑这可能与我程序中的事件处理部分有关。但我对GUI编程还是一个新手,对事件是如何触发和处理的有一个非常基本的了解
因此,我创建了一个新的gradle项目,选择Java作为“附加库和框架”。 Gradle将编译为<代码>。\构建\类并维护包结构, 但是项目结构中的“模块编译输出路径”—— 这真的很烦人,我不想每次创建一个新的Java项目时都要对其进行更改。 我是否可以更改默认值,使其与gradle输出路径匹配?
我有来自POST方法的响应正文,如下所示 然后我想提取该会话密钥以添加到我使用此代码的环境变量中 但是在环境变量上仍然返回“undefined”值。请帮助,谢谢
问题内容: 我创建了一个JTextField,现在我想在该JTextField上设置占位符,但我不知道如何在JTextField上设置占位符?请帮助如何在JTextField上设置占位符文本 那是我现在在该代码中的文本字段代码,我想设置占位符,如何在该JTextField上设置占位符 问题答案: 试试这个课程:
我尝试将int作为参数并单独对其字节进行操作,例如取0xDEADF00D并逐个处理每个字节:0xDE 0xAD 0xF0 0x0D 为此,我执行了以下代码: HashFn的sig为: 编译失败,并显示: 错误C2131:表达式未计算为常量 注意:失败是由于在变量的生命周期之外读取了变量导致的 注意:请参阅“字节”的用法 我在StackOverflow上读过一些关于参数在编译时可能无法求值的主题(这