private void NumberMinus10ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_NumberMinus10ActionPerformed int temp = Integer.parseInt(NumberField.getText()) - 10; if (temp < 0) { temp = 0; } NumberField.setText(String.valueOf(temp)); } // GEN-LAST:event_NumberMinus10ActionPerformed
private void NumberPlusTenActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_NumberPlusTenActionPerformed int temp = Integer.parseInt(NumberField.getText()) + 10; if (temp < 0) { temp = 0; } NumberField.setText(String.valueOf(temp)); // TODO add your handling code here: } // GEN-LAST:event_NumberPlusTenActionPerformed
protected void ok() { try { int runs = Integer.parseInt(runsField.getText()); int steps = Integer.parseInt(stepsField.getText()); ((TrajPanel) context).runRandomUpdateTraj(runs, steps); } catch (NumberFormatException ex) { ((TrajPanel) context).runRandomUpdateTraj(-1, -1); } }
/** * Test if all of the <CODE>NumberField</CODE>s on this <CODE>Floor</CODE> are superfields of * <CODE>n</CODE> * * @param n A number field for which we wish to determine if all members of this floor are * superfields * @return <CODE>true</CODE> iff all number fields belonging to this floor are subfields of * <CODE>n</CODE>; <CODE>false</CODE> otherwise */ public boolean allSuperFieldsOf(NumberField n) { Component[] all = getComponents(); for (int i = 0; i < all.length; i++) { NumberField maybeSuper = (NumberField) all[i]; // DEBUG: // System.err.println("\tSuperfield Test:" + maybeSuper.getPoly() + ", " + n.getPoly()); if (!maybeSuper.hasSubfield(n)) return false; } return true; }
private void DelButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_DelButtonActionPerformed if (NumberField.getCaretPosition() != NumberField.getText().length()) { // only do something if the caret is not the at the end int tmpcaretpos = NumberField.getCaretPosition(); NumberField.setText( NumberField.getText().substring(0, NumberField.getCaretPosition()) + NumberField.getText() .substring(NumberField.getCaretPosition() + 1, NumberField.getText().length())); NumberField.setCaretPosition(tmpcaretpos); } } // GEN-LAST:event_DelButtonActionPerformed
private void BackspaceButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_BackspaceButtonActionPerformed if (NumberField.getCaretPosition() != 0) { // only do something if the caret is not the at the beginning int tmpcaretpos = NumberField.getCaretPosition(); NumberField.setText( NumberField.getText().substring(0, NumberField.getCaretPosition() - 1) + NumberField.getText() .substring(NumberField.getCaretPosition(), NumberField.getText().length())); NumberField.setCaretPosition(tmpcaretpos - 1); } } // GEN-LAST:event_BackspaceButtonActionPerformed
private void SettingsOKButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_SettingsOKButtonActionPerformed this.FieldParent.setText(NumberField.getText()); CardLayout cl = (CardLayout) (Parent.GetCardManager().getLayout()); cl.show(Parent.GetCardManager(), TargetCard); } // GEN-LAST:event_SettingsOKButtonActionPerformed
void AppendCharacter(String character) { int tmpcaretpos = NumberField .getCaretPosition(); // save positon of the caret so we can use it again after replacing // the string NumberField.setText( NumberField.getText().substring(0, NumberField.getCaretPosition()) + character + NumberField.getText() .substring(NumberField.getCaretPosition(), NumberField.getText().length())); NumberField.setCaretPosition(tmpcaretpos + 1); // use the save caret position again NumberField.getCaret().setVisible(true); }
public void Load(String Varname, int value, JTextField parent, String targetCard) { this.FieldParent = parent; this.VarName.setText(Varname); this.TargetCard = targetCard; this.NumberField.setText(String.valueOf(value)); NumberField.getCaret().setVisible(true); }
/** * Where to insert <CODE>n</CODE>, based only on degree, in the current tower. In <CODE> * addField()</CODE> we further test to see if the floors above, and/or at, and/or below are * sub-/superfields. * * @param n The NumberField whose insertion index we are intersted in * @return The index where <CODE>n</CODE> should be inserted into <CODE>floors</CODE> * @see #floors */ private int findInsertionIndex(NumberField n) { int i = 0; for (i = 0; i < floors.size(); i++) { Floor f = (Floor) floors.get(i); if (f.getDegree() <= n.getDegree()) break; } return i; }
/** * Test if all of the <CODE>NumberField</CODE>s on this <CODE>Floor</CODE> are subfields of * <CODE>n</CODE> * * @param n A number field for which we wish to determine if all members of this floor are * subfields * @return <CODE>true</CODE> iff all number fields belonging to this floor are subfields of * <CODE>n</CODE>; <CODE>false</CODE> otherwise */ public boolean allSubfieldsOf(NumberField n) { Component[] all = getComponents(); for (int i = 0; i < all.length; i++) { NumberField maybeSub = (NumberField) all[i]; if (!n.hasSubfield(maybeSub)) return false; } return true; }
public RandomRunPanel(Point pLocation, BMVPanel pContext) { super(); context = pContext; location = pLocation; requestFocusInWindow(); runsField = new NumberField("Number of Runs"); runsField.setFont(new Font("arial", Font.BOLD, 14)); runsField.setOpaque(true); this.add(runsField); addHelp( "This mode will run the experiment on the model, only updating a single variable (randomly determined) at a time.\n\nNumber of Runs: this is how many times the experiment will be rerun, the more runs the more consistent the results should become.\n\nNumber of Steps: this is how many steps each run will go through. More steps would represent observing the system for a greater period of time, so the more steps the longer term behavior will be observed.", 200, 200); stepsField = new NumberField("Number of Steps"); stepsField.setFont(new Font("arial", Font.BOLD, 14)); stepsField.setOpaque(true); this.add(stepsField); transferFocus(); addOkCancel(); setBounds(location.x, location.y, 170, 95); }
/** * Creates a new <CODE>Floor</CODE> with the given inhabitant * * @param n A <CODE>NumberField</CODE> that should live on the new <CODE>Floor</CODE> */ private Floor(NumberField n) { super(); // DEBUG use /* addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { floorMouseEntered(evt); } });*/ setLayout(new BoxLayout(this, javax.swing.BoxLayout.X_AXIS)); setFocusable(false); setOpaque(false); degree = n.getDegree(); add(n); }
/** * Determine the subfields of <CODE>n</CODE> and store the results there as well. * * @param n The NumberField whose subfields we are after */ private void determineSubfields(NumberField n) { // Progress Bar GiANT.gui.appendConsoleText( "\nDetermining sub- and superfield relations for new field" + ELL, false); GiANT.gui.showProgressBar(true); // DEBUG // System.err.println("subfields start for " + n.getName()); int i = 0; final float size = (float) allFields.size(); final int max = GiANT.gui.getProgressMax(); Iterator it = allFields.iterator(); while (it.hasNext()) { // Progress Bar float index = (float) i++; int progress = (int) (max * (index / size)); // DEBUG // System.err.println("\tprogress=" + progress); GiANT.gui.setProgress(progress); NumberField test = (NumberField) it.next(); if (n.hasSubfield(test) || test.hasSubfield(n)) { // do nothing } else if (GiANT.gui.kash.isSubfield(test, n)) { n.addSubfield(test); // also adds all subfields of test to subfields of this if (test.getDegree() == n.getDegree()) { test.addSubfield(n); } } else if (GiANT.gui.kash.isSubfield(n, test)) { test.addSubfield(n); // also adds all subfields of n to subfields of this } } // Progress Bar GiANT.gui.showProgressBar(false); GiANT.gui.appendConsoleText("done.\n", false); // System.err.println("subfields end for " + n.getName()); }
private void RightButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_RightButtonActionPerformed NumberField.setCaretPosition(NumberField.getCaretPosition() + 1); NumberField.getCaret().setVisible(true); } // GEN-LAST:event_RightButtonActionPerformed
private void NumberClearActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_NumberClearActionPerformed NumberField.setText(""); } // GEN-LAST:event_NumberClearActionPerformed
/** * Add <CODE>newguy</CODE> to the list of all fields in this city * * @param newguy the NumberField to add * @see #allFields */ protected void addField(NumberField newguy) { boolean fatal = false; if (population >= MAX_POPULATION) { GiANT.gui.appendConsoleText( "\nUnable to add numberfield; maximum population of " + MAX_POPULATION + " reached.", true); fatal = true; } else if (allFields.contains(newguy)) { GiANT.gui.appendConsoleText( "\nUnable to add numberfield. It duplicates one already displayed.", true); fatal = true; } if (fatal) return; // we will need to know all subfields of this cat... determineSubfields(newguy); // System.err.println("entering addField()"); // TODO do not allow duplicate (isomorphic) numberfields to be added boolean homeless = true; // we have yet to find a place for newguy boolean redraw = false; // update maxDegree final int newDeg = newguy.getDegree(); if (newDeg > maxDegree) { maxDegree = newDeg; redraw = true; } // search all towers, left to right towers: for (int i = 0; i < towers.size(); i++) { Tower t = (Tower) towers.get(i); // boolean flags for existence of [proper] superfields / subfields boolean hasSuper = false; boolean hasSub = false; final int insert = t.findInsertionIndex(newguy); boolean hasEqual = false; Tower.Floor f = null; if (insert == t.getHeight()) { // nothing to check; we are outside of the current tower array } else { f = t.getFloor(insert); if (f.getDegree() == newDeg) hasEqual = true; } Tower.Floor above = null; Tower.Floor below = null; if (insert == 0) { // we are at the top of the tower hasSuper = true; // super is C int fetch = 0; if (hasEqual) fetch = 1; if (fetch >= t.getHeight()) { hasSub = true; // there are no towers below, sub is Q } else { below = t.getFloor(fetch); if (below.allSubfieldsOf(newguy)) hasSub = true; } } else if (insert == t.getHeight()) { // we are at the very bottom of the tower hasSub = true; // sub is Q itself above = t.getFloor(t.getHeight() - 1); if (above.allSuperFieldsOf(newguy)) hasSuper = true; } else { // we are somewhere WITHIN the tower if (hasEqual) { above = t.getFloor(insert - 1); if (insert == t.getHeight() - 1) hasSub = true; // sub is Q else below = t.getFloor(insert + 1); } else { above = t.getFloor(insert - 1); below = t.getFloor(insert); } if (above.allSuperFieldsOf(newguy)) hasSuper = true; if (hasSub) { // do nothing } else { // test for the same if (below.allSubfieldsOf(newguy)) hasSub = true; } } if (hasSub && hasSuper) { if (hasEqual) // kkl if (!f.allSubfieldsOf( newguy)) // could also use allSuperfieldsOf(), we need to make sure all fields this // floor are isomorphic to newguy... continue towers; // homeless = false; t.add(insert, hasEqual, newguy); break towers; } } if (homeless) { // then build a new tower for newguy Tower newT = newTower(); newT.add(0, false, newguy); } population++; // one more citizen! allFields.add(newguy); // add him to the set of all fields // if(redraw) //OPTIM redraw(); GiANT.gui.repaint(); // System.err.println("exiting addField()"); }
/** * Draw the lines connecting fields on the desktop. These lines represent super-/subfield * relations. * * @param g The Graphics context on which to draw the lines * @see #linesLayer */ private void drawLines(Graphics g) { java.awt.Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint( java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON); final Point Q = getCenterLocation(QLabel); for (int i = 0; i < towers.size(); i++) { Tower t = (Tower) towers.get(i); g2.setColor(COLORS[i % COLORS.length]); boolean bottom = false; for (int j = 0; j < t.floors.size(); j++) { if (j == t.floors.size() - 1) bottom = true; Tower.Floor f = (Tower.Floor) t.getFloor(j); // iterate over all fields this floor Component[] fields = f.getComponents(); for (int k = 0; k < fields.length; k++) { NumberField a = (NumberField) fields[k]; // line origin Point p1 = getCenterLocation(a.getCenterComponent()); // get center for (int l = 0; l < towers.size(); l++) { if (i == l) // use different colors for drawing within/without towers g2.setStroke(IN_LINE); else g2.setStroke(OUT_LINE); Tower t2 = (Tower) towers.get(l); // pen color changes according to destination tower // that way all 'sets of subsets' are monochrome // g2.setColor(COLORS[l % COLORS.length]); floors: for (int m = 0; m < t2.floors.size(); m++) { Tower.Floor f2 = (Tower.Floor) t2.getFloor(m); // iterate over all fields this floor boolean done = false; Component[] fields2 = f2.getComponents(); for (int n = 0; n < fields2.length; n++) { NumberField b = (NumberField) fields2[n]; // line destination if (i == l & j == m) { // we are within a floor{ if (k == n) ; // do nothing (don't draw to yourself) else { // to do, maybe have different lines for isomorphy? Point p2 = getCenterLocation(b.getCenterComponent()); // get center g2.drawLine(p1.x, p1.y, p2.x, p2.y); done = true; } } else if (a.hasSubfield(b) && !a.subfieldHasProperSubfield(b)) { Point p2 = getCenterLocation(b.getCenterComponent()); // get center g2.drawLine(p1.x, p1.y, p2.x, p2.y); done = true; } } // go to the next tower; only need to draw to ONE floor per tower if (done) break floors; } } if (bottom && a.hasNoProperSubfields()) { // bottom of tower, no lines out of tower... g2.setColor(COLORS[i % COLORS.length]); g2.setStroke(IN_LINE); g2.drawLine(p1.x, p1.y, Q.x, Q.y); // then draw to Q! } } } } }
/** * This method is called from within the init() method 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">//GEN-BEGIN:initComponents private void initComponents() { bg = new javax.swing.JPanel(); Keypad = new javax.swing.JPanel(); Number1 = new EButton(Parent); Number2 = new EButton(Parent); Number3 = new EButton(Parent); Number4 = new EButton(Parent); Number5 = new EButton(Parent); Number6 = new EButton(Parent); Number7 = new EButton(Parent); Number8 = new EButton(Parent); Number9 = new EButton(Parent); NumberClear = new EButton(Parent); Number0 = new EButton(Parent); NumberPlusOne = new EButton(Parent); NumberPlusTen = new EButton(Parent); NumberMinusOne = new EButton(Parent); NumberMinus10 = new EButton(Parent); BackspaceButton = new EButton(Parent); DelButton = new EButton(Parent); NumberPanel = new javax.swing.JPanel(); VarName = new javax.swing.JLabel(); NumberField = new javax.swing.JTextField(); EndButton = new EButton(Parent); RightButton = new EButton(Parent); LeftButton = new EButton(Parent); Pos1Button = new EButton(Parent); Validation = new javax.swing.JLabel(); ConfirmationPanel = new javax.swing.JPanel(); SettingsCancelButton = new EButton(Parent); SettingsOKButton = new EButton(Parent); bg.setBackground(new java.awt.Color(0, 0, 0)); bg.setPreferredSize(new java.awt.Dimension(1024, 600)); Keypad.setBackground(new java.awt.Color(0, 0, 0)); Number1.setText("1"); Number1.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Number1.setPreferredSize(new java.awt.Dimension(100, 60)); Number1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Number1ActionPerformed(evt); } }); Number2.setText("2"); Number2.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Number2.setPreferredSize(new java.awt.Dimension(100, 60)); Number2.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Number2ActionPerformed(evt); } }); Number3.setText("3"); Number3.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Number3.setPreferredSize(new java.awt.Dimension(100, 60)); Number3.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Number3ActionPerformed(evt); } }); Number4.setText("4"); Number4.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Number4.setPreferredSize(new java.awt.Dimension(100, 60)); Number4.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Number4ActionPerformed(evt); } }); Number5.setText("5"); Number5.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Number5.setPreferredSize(new java.awt.Dimension(100, 60)); Number5.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Number5ActionPerformed(evt); } }); Number6.setText("6"); Number6.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Number6.setPreferredSize(new java.awt.Dimension(100, 60)); Number6.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Number6ActionPerformed(evt); } }); Number7.setText("7"); Number7.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Number7.setPreferredSize(new java.awt.Dimension(100, 60)); Number7.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Number7ActionPerformed(evt); } }); Number8.setText("8"); Number8.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Number8.setPreferredSize(new java.awt.Dimension(100, 60)); Number8.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Number8ActionPerformed(evt); } }); Number9.setText("9"); Number9.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Number9.setPreferredSize(new java.awt.Dimension(100, 60)); Number9.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Number9ActionPerformed(evt); } }); NumberClear.setText("Clear"); NumberClear.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); NumberClear.setPreferredSize(new java.awt.Dimension(100, 60)); NumberClear.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NumberClearActionPerformed(evt); } }); Number0.setText("0"); Number0.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Number0.setPreferredSize(new java.awt.Dimension(100, 60)); Number0.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Number0ActionPerformed(evt); } }); NumberPlusOne.setText("+1"); NumberPlusOne.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); NumberPlusOne.setPreferredSize(new java.awt.Dimension(100, 60)); NumberPlusOne.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NumberPlusOneActionPerformed(evt); } }); NumberPlusTen.setText("+10"); NumberPlusTen.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); NumberPlusTen.setPreferredSize(new java.awt.Dimension(100, 60)); NumberPlusTen.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NumberPlusTenActionPerformed(evt); } }); NumberMinusOne.setText("-1"); NumberMinusOne.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); NumberMinusOne.setPreferredSize(new java.awt.Dimension(100, 60)); NumberMinusOne.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NumberMinusOneActionPerformed(evt); } }); NumberMinus10.setText("-10"); NumberMinus10.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); NumberMinus10.setPreferredSize(new java.awt.Dimension(100, 60)); NumberMinus10.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NumberMinus10ActionPerformed(evt); } }); BackspaceButton.setText("Backspace"); BackspaceButton.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); BackspaceButton.setPreferredSize(new java.awt.Dimension(100, 60)); BackspaceButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BackspaceButtonActionPerformed(evt); } }); DelButton.setText("Del"); DelButton.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); DelButton.setPreferredSize(new java.awt.Dimension(100, 60)); DelButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DelButtonActionPerformed(evt); } }); javax.swing.GroupLayout KeypadLayout = new javax.swing.GroupLayout(Keypad); Keypad.setLayout(KeypadLayout); KeypadLayout.setHorizontalGroup( KeypadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( KeypadLayout.createSequentialGroup() .addGroup( KeypadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup( KeypadLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( KeypadLayout.createSequentialGroup() .addComponent( Number1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent( Number2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent( Number3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( KeypadLayout.createSequentialGroup() .addComponent( Number4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent( Number5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent( Number6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup( KeypadLayout.createSequentialGroup() .addGroup( KeypadLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent( Number0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup( KeypadLayout.createSequentialGroup() .addContainerGap() .addComponent( Number7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGap(18, 18, 18) .addComponent( Number8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup( KeypadLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent( NumberClear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( Number9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGap(18, 18, 18) .addGroup( KeypadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( NumberMinus10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup( KeypadLayout.createSequentialGroup() .addGroup( KeypadLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent( NumberPlusOne, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( NumberPlusTen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(74, 74, 74) .addGroup( KeypadLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent( DelButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( BackspaceButton, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent( NumberMinusOne, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap())); KeypadLayout.setVerticalGroup( KeypadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( KeypadLayout.createSequentialGroup() .addContainerGap() .addGroup( KeypadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup( KeypadLayout.createSequentialGroup() .addComponent( BackspaceButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent( DelButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( KeypadLayout.createSequentialGroup() .addGroup( KeypadLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( Number2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( Number3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( Number1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( NumberPlusTen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup( KeypadLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( Number5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( Number6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( Number4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( NumberPlusOne, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGap(18, 18, 18) .addGroup( KeypadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( Number8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( Number9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( NumberMinusOne, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( Number7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup( KeypadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( Number0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( NumberClear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( NumberMinus10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); NumberPanel.setBackground(java.awt.Color.black); VarName.setFont(new java.awt.Font("DejaVu Sans", 1, 18)); VarName.setForeground(new java.awt.Color(255, 255, 255)); VarName.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); VarName.setText("Name"); VarName.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); VarName.setAlignmentY(0.0F); VarName.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); VarName.setIconTextGap(0); VarName.setInheritsPopupMenu(false); VarName.setRequestFocusEnabled(false); VarName.setVerifyInputWhenFocusTarget(false); VarName.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); NumberField.setBackground(new java.awt.Color(0, 0, 0)); NumberField.setFont(new java.awt.Font("Bitstream Vera Sans Mono", 0, 18)); NumberField.setForeground(new java.awt.Color(255, 255, 255)); NumberField.setHorizontalAlignment(javax.swing.JTextField.CENTER); NumberField.setBorder( javax.swing.BorderFactory.createLineBorder(new java.awt.Color(148, 148, 148))); NumberField.setCaretColor(new java.awt.Color(255, 255, 255)); NumberField.addCaretListener( new javax.swing.event.CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent evt) { NumberFieldCaretUpdate(evt); } }); EndButton.setText("End"); EndButton.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); EndButton.setPreferredSize(new java.awt.Dimension(100, 60)); EndButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EndButtonActionPerformed(evt); } }); RightButton.setText("->"); RightButton.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); RightButton.setPreferredSize(new java.awt.Dimension(100, 60)); RightButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RightButtonActionPerformed(evt); } }); LeftButton.setText("<-"); LeftButton.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); LeftButton.setPreferredSize(new java.awt.Dimension(100, 60)); LeftButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LeftButtonActionPerformed(evt); } }); Pos1Button.setText("Pos1"); Pos1Button.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); Pos1Button.setPreferredSize(new java.awt.Dimension(100, 60)); Pos1Button.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Pos1ButtonActionPerformed(evt); } }); javax.swing.GroupLayout NumberPanelLayout = new javax.swing.GroupLayout(NumberPanel); NumberPanel.setLayout(NumberPanelLayout); NumberPanelLayout.setHorizontalGroup( NumberPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( NumberPanelLayout.createSequentialGroup() .addContainerGap() .addGroup( NumberPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(VarName) .addGroup( NumberPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addGroup( NumberPanelLayout.createSequentialGroup() .addComponent( Pos1Button, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent( LeftButton, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent( RightButton, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent( EndButton, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent( NumberField, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(191, Short.MAX_VALUE))); NumberPanelLayout.setVerticalGroup( NumberPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( NumberPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(VarName) .addGap(18, 18, 18) .addComponent( NumberField, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( NumberPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( Pos1Button, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( LeftButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( RightButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( EndButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); Validation.setForeground(new java.awt.Color(180, 1, 1)); ConfirmationPanel.setBackground(java.awt.Color.black); SettingsCancelButton.setText("Cancel"); SettingsCancelButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SettingsCancelButtonActionPerformed(evt); } }); SettingsOKButton.setText("OK"); SettingsOKButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SettingsOKButtonActionPerformed(evt); } }); javax.swing.GroupLayout ConfirmationPanelLayout = new javax.swing.GroupLayout(ConfirmationPanel); ConfirmationPanel.setLayout(ConfirmationPanelLayout); ConfirmationPanelLayout.setHorizontalGroup( ConfirmationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( ConfirmationPanelLayout.createSequentialGroup() .addComponent( SettingsOKButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent( SettingsCancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); ConfirmationPanelLayout.setVerticalGroup( ConfirmationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( ConfirmationPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( SettingsOKButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( SettingsCancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); javax.swing.GroupLayout bgLayout = new javax.swing.GroupLayout(bg); bg.setLayout(bgLayout); bgLayout.setHorizontalGroup( bgLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( bgLayout .createSequentialGroup() .addContainerGap() .addComponent( NumberPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( Validation, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(283, Short.MAX_VALUE)) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, bgLayout .createSequentialGroup() .addContainerGap(922, Short.MAX_VALUE) .addComponent( ConfirmationPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) .addGroup( bgLayout .createSequentialGroup() .addContainerGap() .addComponent( Keypad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(339, Short.MAX_VALUE))); bgLayout.setVerticalGroup( bgLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( bgLayout .createSequentialGroup() .addGroup( bgLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( bgLayout .createSequentialGroup() .addContainerGap() .addComponent( NumberPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( bgLayout .createSequentialGroup() .addGap(42, 42, 42) .addComponent( Validation, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent( Keypad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE) .addComponent( ConfirmationPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( bg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( bg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)); } // </editor-fold>//GEN-END:initComponents
private void EndButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_EndButtonActionPerformed NumberField.setCaretPosition(NumberField.getText().length()); NumberField.getCaret().setVisible(true); } // GEN-LAST:event_EndButtonActionPerformed