JComboBox stops responding when focus is directed to another component - jcombobox
I'm having an issue with a small personal application I am puttig together. I am loading data into a JDialog. Within the JDialog, I am loading multiple JPanels that each contain a TableLayout. I am dynamically generating the rows from the data that is loaded into the JDialog. Each row contains a JComboBox and a JTextField that are use to make comments about the status of that particular set of data.
The problem I am encountering has to do with the JComboBox components that are being created. When the JDialog window opens, the JComboBox components are visable and working. Although, as soon as I direct the focus to a different type of component, the JComboBox components stop responding to the mouse clicks.
There is no special logic around the JComboBox components. They simply populate with four different string values, which the user should be able to choose from. No ChangeListener is required for this.
Also note, I wrap all the content in a ScrollPane within the JDialog.
The following is the code where I create the JComboBox components within the TableLayout of the JPanel:
private JPanel createColumnPanel() {
int columnCount = report.getColumns().size();
int rowCount = (columnCount * 2) - 1;
SpringLayout layout = new SpringLayout();
JPanel padding = new JPanel(layout);
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Column Differences: ");
border.setTitleJustification(TitledBorder.LEFT);
double[] columns = new double[] {3, 75, 3, 175, 3, 150, 3, 100, 3, 125};
double[] rows = new double[rowCount];
for(int i = 0; i < rowCount; i++) {
rows[i] = 20;
if (i + 1 < rowCount)
rows[i + 1] = 5;
i++;
}
double size[][] = {columns, rows};
JPanel panel = new JPanel(new TableLayout(size));
columnStatus = new ArrayList<JComboBox<String>>();
for(int i = 0; i < columnCount; i++) {
JComboBox<String> comboBox = new JComboBox<String>(statusLiterals);
comboBox.setEnabled(true);
columnStatus.add(comboBox);
}
for (int i = 0; i < columnCount; i++) {
panel.add(new JLabel(report.getColumns().get(i).getSchema().toString()), 1 + ", " + (i * 2));
panel.add(new JLabel(report.getColumns().get(i).getTableName()), 3 + ", " + (i * 2));
panel.add(new JLabel(report.getColumns().get(i).getColumnName()), 5 + ", " + (i * 2));
panel.add(columnStatus.get(i), 7 + ", " + (i * 2));
panel.add(new JTextField(report.getColumns().get(i).getRequestor()), 9 + ", " + (i * 2));
}
panel.setBorder(border);
panel.setVisible(true);
panel.setAlignmentX(LEFT_ALIGNMENT);
panel.setBackground(Color.WHITE);
layout.putConstraint(SpringLayout.NORTH, panel, 10, SpringLayout.NORTH, padding);
layout.putConstraint(SpringLayout.SOUTH, padding, 10, SpringLayout.SOUTH, panel);
layout.putConstraint(SpringLayout.EAST, padding, 10, SpringLayout.EAST, panel);
layout.putConstraint(SpringLayout.WEST, panel, 10, SpringLayout.WEST, padding);
padding.add(panel, SwingConstants.CENTER);
padding.setBackground(Color.WHITE);
return padding;
}
The following is the full code for this particular JDialog:
public class ManageRequestsDialog extends JDialog {
private static final long serialVersionUID = 1L;
private ComparisonReport report;
private JPanel outerPanel;
private ScrollPane scrollPane;
private JPanel innerPanel;
private JPanel databasePanel;
private JPanel tablePanel;
private JPanel columnPanel;
private List<JLabel> databaseSchemas = null;
private List<JComboBox<String>> databaseStatus = null;
private List<JTextField> databaseRequestors = null;
private List<JLabel> tableSchemas = null;
private List<JLabel> tableTableNames = null;
private List<JComboBox<String>> tableStatus = null;
private List<JTextField> tableRequestors = null;
private List<JLabel> columnSchemas = null;
private List<JLabel> columnTableNames = null;
private List<JLabel> columnColumnNames = null;
private List<JComboBox<String>> columnStatus = null;
private List<JTextField> columnRequestors = null;
private String[] statusLiterals = DifferenceStatus.getLiterals();
public ManageRequestsDialog (ComparisonReport report) {
super();
this.report = report;
outerPanel = createOuterPanel();
add(outerPanel);
setLayout(new GridLayout(1, 1));
setModal(true);
setSize(700, 500);
setBackground(Color.WHITE);
setResizable(false);
setLocationRelativeTo(null);
setVisible(true);
}
private JPanel createOuterPanel() {
JPanel panel = new JPanel(new GridLayout(1, 1));
scrollPane = createScrollPane();
panel.add(scrollPane);
panel.setVisible(true);
panel.setBackground(Color.WHITE);
return panel;
}
private ScrollPane createScrollPane() {
ScrollPane scrollPane = new ScrollPane();
innerPanel = createInnerPanel();
scrollPane.add(innerPanel);
scrollPane.setVisible(true);
scrollPane.setBackground(Color.WHITE);
return scrollPane;
}
private JPanel createInnerPanel() {
JPanel panel = new JPanel(new BorderLayout());
if (report.getDatabases().size() > 0) {
databasePanel = createDatabasePanel();
panel.add(databasePanel, BorderLayout.NORTH);
}
if (report.getTables().size() > 0) {
tablePanel = createTablePanel();
panel.add(tablePanel, BorderLayout.CENTER);
}
if (report.getColumns().size() > 0) {
columnPanel = createColumnPanel();
panel.add(columnPanel, BorderLayout.SOUTH);
}
panel.setVisible(true);
panel.setBackground(Color.WHITE);
return panel;
}
private JPanel createDatabasePanel() {
int databaseCount = report.getDatabases().size();
int rowCount = (databaseCount * 2) - 1;
SpringLayout layout = new SpringLayout();
JPanel padding = new JPanel(layout);
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Database Differences: ");
border.setTitleJustification(TitledBorder.LEFT);
double[] columns = new double[] {3, 75, 3, 75, 3, 150};
double[] rows = new double[rowCount];
for(int i = 0; i < rowCount; i++) {
rows[i] = 20;
if (i + 1 < rowCount)
rows[i + 1] = 5;
i++;
}
double size[][] = {columns, rows};
JPanel panel = new JPanel(new TableLayout(size));
databaseStatus = new ArrayList<JComboBox<String>>();
for(int i = 0; i < databaseCount; i++) {
JComboBox<String> comboBox = new JComboBox<String>(statusLiterals);
comboBox.setEnabled(true);
databaseStatus.add(comboBox);
}
for (int i = 0; i < databaseCount; i++) {
panel.add(new JLabel(report.getDatabases().get(i).getSchema().toString()), 1 + ", " + (i * 2));
panel.add(databaseStatus.get(i), 3 + ", " + (i * 2));
panel.add(new JTextField(report.getDatabases().get(i).getRequestor()), 5 + ", " + (i * 2));
}
panel.setBorder(border);
panel.setVisible(true);
panel.setAlignmentX(LEFT_ALIGNMENT);
panel.setBackground(Color.WHITE);
layout.putConstraint(SpringLayout.NORTH, panel, 10, SpringLayout.NORTH, padding);
layout.putConstraint(SpringLayout.SOUTH, padding, 10, SpringLayout.SOUTH, panel);
layout.putConstraint(SpringLayout.EAST, padding, 10, SpringLayout.EAST, panel);
layout.putConstraint(SpringLayout.WEST, panel, 10, SpringLayout.WEST, padding);
padding.add(panel, SwingConstants.CENTER);
padding.setBackground(Color.WHITE);
return padding;
}
private JPanel createTablePanel() {
int tableCount = report.getTables().size();
int rowCount = (tableCount * 2) - 1;
SpringLayout layout = new SpringLayout();
JPanel padding = new JPanel(layout);
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Table Differences: ");
border.setTitleJustification(TitledBorder.LEFT);
double[] columns = new double[] {3, 75, 3, 175, 3, 100, 3, 150};
double[] rows = new double[rowCount];
for(int i = 0; i < rowCount; i++) {
rows[i] = 20;
if (i + 1 < rowCount)
rows[i + 1] = 5;
i++;
}
double size[][] = {columns, rows};
JPanel panel = new JPanel(new TableLayout(size));
tableStatus = new ArrayList<JComboBox<String>>();
for(int i = 0; i < tableCount; i++) {
JComboBox<String> comboBox = new JComboBox<String>(statusLiterals);
comboBox.setEnabled(true);
tableStatus.add(comboBox);
}
for (int i = 0; i < tableCount; i++) {
panel.add(new JLabel(report.getTables().get(i).getSchema().toString()), 1 + ", " + (i * 2));
panel.add(new JLabel(report.getTables().get(i).getTableName()), 3 + ", " + (i * 2));
panel.add(tableStatus.get(i), 5 + ", " + (i * 2));
panel.add(new JTextField(report.getTables().get(i).getRequestor()), 7 + ", " + (i * 2));
}
panel.setBorder(border);
panel.setVisible(true);
panel.setAlignmentX(LEFT_ALIGNMENT);
panel.setBackground(Color.WHITE);
layout.putConstraint(SpringLayout.NORTH, panel, 10, SpringLayout.NORTH, padding);
layout.putConstraint(SpringLayout.SOUTH, padding, 10, SpringLayout.SOUTH, panel);
layout.putConstraint(SpringLayout.EAST, padding, 10, SpringLayout.EAST, panel);
layout.putConstraint(SpringLayout.WEST, panel, 10, SpringLayout.WEST, padding);
padding.add(panel, SwingConstants.CENTER);
padding.setBackground(Color.WHITE);
return padding;
}
private JPanel createColumnPanel() {
int columnCount = report.getColumns().size();
int rowCount = (columnCount * 2) - 1;
SpringLayout layout = new SpringLayout();
JPanel padding = new JPanel(layout);
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Column Differences: ");
border.setTitleJustification(TitledBorder.LEFT);
double[] columns = new double[] {3, 75, 3, 175, 3, 150, 3, 100, 3, 125};
double[] rows = new double[rowCount];
for(int i = 0; i < rowCount; i++) {
rows[i] = 20;
if (i + 1 < rowCount)
rows[i + 1] = 5;
i++;
}
double size[][] = {columns, rows};
JPanel panel = new JPanel(new TableLayout(size));
columnStatus = new ArrayList<JComboBox<String>>();
for(int i = 0; i < columnCount; i++) {
JComboBox<String> comboBox = new JComboBox<String>(statusLiterals);
comboBox.setEnabled(true);
columnStatus.add(comboBox);
}
for (int i = 0; i < columnCount; i++) {
panel.add(new JLabel(report.getColumns().get(i).getSchema().toString()), 1 + ", " + (i * 2));
panel.add(new JLabel(report.getColumns().get(i).getTableName()), 3 + ", " + (i * 2));
panel.add(new JLabel(report.getColumns().get(i).getColumnName()), 5 + ", " + (i * 2));
panel.add(columnStatus.get(i), 7 + ", " + (i * 2));
panel.add(new JTextField(report.getColumns().get(i).getRequestor()), 9 + ", " + (i * 2));
}
panel.setBorder(border);
panel.setVisible(true);
panel.setAlignmentX(LEFT_ALIGNMENT);
panel.setBackground(Color.WHITE);
layout.putConstraint(SpringLayout.NORTH, panel, 10, SpringLayout.NORTH, padding);
layout.putConstraint(SpringLayout.SOUTH, padding, 10, SpringLayout.SOUTH, panel);
layout.putConstraint(SpringLayout.EAST, padding, 10, SpringLayout.EAST, panel);
layout.putConstraint(SpringLayout.WEST, panel, 10, SpringLayout.WEST, padding);
padding.add(panel, SwingConstants.CENTER);
padding.setBackground(Color.WHITE);
return padding;
}
}
Related
PDFBox: draw millimeter paper
I want to draw millimeter paper into a pdf, but when I measure the printed document I'm a bit off (drawn cm < 1 cm). I'm using the size of an A4 Paper (210 * 297) and the pageWidth and pageHeight to calculate the pixel per mm (used the average of both hoping this would work). I also tried different option when printing the document (with & without margin etc.), but this didn't work as well. public class TestPrint extends Application { protected static final float DINA4_IN_MM_WIDTH = 210; protected static final float DINA4_IN_MM_HEIGHT = 297; protected static final int LEFTSIDE = 35; protected static final int TEXT_FONT_SIZE = 11; protected static final int TOP_MARGIN = 60; public static void main(String[] args) { launch(args); } #Override public void start(Stage primaryStage) { File file = new File("test.pdf"); double windowWidth = 600; double windowHeight = 1000; float x = LEFTSIDE; PDFont font = PDType1Font.TIMES_ROMAN; PDPage page = new PDPage(PDRectangle.A4); PDRectangle pageSize = page.getMediaBox(); PDDocument mainDocument = new PDDocument(); mainDocument.addPage(page); float stringHeight = font.getFontDescriptor().getFontBoundingBox().getHeight() * TEXT_FONT_SIZE; float y = pageSize.getHeight() - stringHeight / 1000f - TOP_MARGIN; float pixelPerMM = (pageSize.getWidth() / DINA4_IN_MM_WIDTH + pageSize.getHeight() / DINA4_IN_MM_HEIGHT) / 2; float displayW = 520; float displayH = 300; try { PDPageContentStream contents = new PDPageContentStream(mainDocument, page, AppendMode.APPEND, true); drawBackgroundRaster(contents, x, y, displayW, displayH, pixelPerMM); contents.close(); mainDocument.save(file); ImageView imgView = getImageViewFromDocument(mainDocument, windowHeight); VBox vBox = new VBox(imgView); Scene scene = new Scene(vBox, windowWidth, windowHeight); primaryStage.setScene(scene); primaryStage.show(); } catch (IOException e) { e.printStackTrace(); } } // draw millimeter paper with dots, two boxes shall be 1cm private void drawBackgroundRaster(PDPageContentStream contents, float x, float y, float displayW, float displayH, float pixelPerMM) throws IOException { // rasterColor = grey Color rasterColor = new Color(175, 175, 175); contents.setStrokingColor(rasterColor); float dotSize = 0.5f; // draw vertical lines for (int i = 0; i <= displayW; i++) { float xPos = x + i * pixelPerMM; if (xPos > displayW + x) { break; } contents.moveTo(xPos, y); if (i % 5 == 0) { contents.setLineDashPattern(new float[] {}, 0); contents.lineTo(xPos, y - displayH); } contents.stroke(); } // draw dots and horizontal lines for (int i = 0; i <= displayH; i++) { float yPos = y - i * pixelPerMM; if (yPos < y - displayH) { break; } contents.moveTo(x, yPos); if (i % 5 == 0) { contents.setLineDashPattern(new float[] {}, 0); contents.lineTo(x + displayW, yPos); } else { contents.setLineDashPattern(new float[] { dotSize, pixelPerMM - dotSize }, dotSize / 2); contents.lineTo(x + displayW, yPos); } contents.stroke(); } contents.setLineDashPattern(new float[] {}, 0); contents.moveTo(x, y); contents.lineTo(x + displayW, y); contents.lineTo(x + displayW, y - displayH); contents.lineTo(x, y - displayH); contents.lineTo(x, y); contents.stroke(); } private ImageView getImageViewFromDocument(PDDocument mainDocument, double windowHeight) throws IOException { PDFRenderer pdfRenderer = new PDFRenderer(mainDocument); BufferedImage bim = pdfRenderer.renderImageWithDPI(0, 150, ImageType.RGB); Image image = SwingFXUtils.toFXImage(bim, null); ImageView imageView = new ImageView(image); double scaleFactor = windowHeight / imageView.getImage().getHeight(); double zoomFactor = scaleFactor * 2d * 2.55d / 3; double width = imageView.getImage().getWidth() * zoomFactor; double height = imageView.getImage().getHeight() * zoomFactor; imageView.setFitWidth(width); imageView.setFitHeight(height); return imageView; } }
How to split or device an Entry into small entries in Xamarin forms
Hi Guys, I'm building an app that has an Entry similar to that of tinder, does anyone have an idea on how I can achieve this. I tried creating multiple entries and move focus on the text entered but deleting is the issue as TextChaned method is only called when there is text
In Xamarin.Forms , you can Custom a Entry Render View in iOS to implement it . Create a custom Entry : public class CustomEntry : Entry { } Then in Native iOS, create a CustomEntryRenderer : public class CustomEntryRenderer : EntryRenderer { private UITextField textField; int numberCount = 6; nfloat itemMargin =20; List<UILabel> labels = new List<UILabel>(); List<UIView> lines = new List<UIView>(); UIControl maskView = new UIControl(); protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) { base.OnElementChanged(e); textField = (UITextField)this.Control; //textField.ReturnKeyType = UIReturnKeyType.Done; textField.KeyboardType = UIKeyboardType.NumberPad; textField.AutocapitalizationType = UITextAutocapitalizationType.None; textField.TextColor = UIColor.Clear; textField.TintColor = UIColor.Clear; textField.EditingChanged += TextField_EditingChanged; UIButton maskView = new UIButton(); maskView.BackgroundColor = UIColor.White; maskView.TouchUpInside += MaskView_TouchUpInside; textField.AddSubview(maskView); this.maskView = maskView; for (int i = 0; i < numberCount; i++) { UILabel label = new UILabel(); label.TextAlignment = UITextAlignment.Center; label.TextColor = UIColor.DarkTextColor; label.Font = UIFont.FromName("PingFangSC-Regular", 41); textField.AddSubview(label); labels.Add(label); } for(int i = 0; i < numberCount; i++) { UIView line = new UIView(); line.BackgroundColor = UIColor.Purple; textField.AddSubview(line); lines.Add(line); } } public override void LayoutSubviews() { base.LayoutSubviews(); nfloat temp = textField.Bounds.Size.Width - (itemMargin * (numberCount - 1)); nfloat w = temp / numberCount; nfloat x = 0; for(int i = 0; i < labels.Count; i++) { x = i * (w + itemMargin); UILabel label = labels[i]; label.Frame = new CGRect(x, 0, w, textField.Bounds.Size.Height); UIView line = lines[i]; line.Frame = new CGRect(x, textField.Bounds.Size.Height - 1, w, 1); } maskView.Frame = textField.Bounds; } private void MaskView_TouchUpInside(object sender, EventArgs e) { textField.BecomeFirstResponder(); } private void TextField_EditingChanged(object sender, EventArgs e) { if(textField.Text.Length > numberCount) { //Range range = new Range(0, numberCount); textField.Text = textField.Text.Substring(0, numberCount); } for(int i = 0; i < numberCount; i++) { UILabel label = labels[i]; if(i< textField.Text.Length) { label.Text = textField.Text.Substring(i, 1); } else { label.Text = ""; } } if (textField.Text.Length >= numberCount) { textField.ResignFirstResponder(); } } } Finally , you can use it in Xaml : <ProjectNameSpace:CustomEntry x:Name="customEntry" WidthRequest="300" /> The effect :
I am working with asp.net and i try to display multiple div dynamically it working but every time display same slider data
#region fillAllData4 private void fillAllData4() { clsCategory objCategory = new clsCategory(true); clsProductMain objProduct = new clsProductMain(true); objCategory.getDropDownMenu(); objProduct.getProduct(); string str = string.Empty; int i = 0; // int j = 0; if (objCategory.ListclsCategory.Count > 0) { for (i = 0; i < objCategory.ListclsCategory.Count; i++) { cat.InnerHtml = objCategory.ListclsCategory[0].CategoryName; cat1.InnerHtml = objCategory.ListclsCategory[1].CategoryName; cat2.InnerHtml = objCategory.ListclsCategory[2].CategoryName; cat3.InnerHtml = objCategory.ListclsCategory[3].CategoryName; string[] filePaths = Directory.GetFiles(Server.MapPath("~/images/Saree/")); int j = 0; foreach (string filePath in filePaths) { string fileName = Path.GetFileName(filePath); str += #"<div><div><img class='imges' src='images/Saree/" + fileName + #"' /></div> <div class='sname'>" + objProduct.ListclsProductMain[j].ProductName + #"</div> <div class='sname2'>" + objProduct.ListclsProductMain[j].MRP + #"</div></div>"; j++; } slider3.InnerHtml = str; slider4.InnerHtml = str; slider5.InnerHtml = str; slider6.InnerHtml = str; //System.Web.UI.HtmlControls.HtmlGenericControl createDiv = //new System.Web.UI.HtmlControls.HtmlGenericControl("DIV"); //createDiv.ID = "createDiv"; //createDiv.InnerHtml =str; //this.Controls.Add(createDiv); } } } #endregion
how to create radiobutton list using itextsharp in c#
i am trying to make radiobutton list in pdf file using itextsharp but it create box. Is there anyone can say me why this is happening ? for (int j = 0; j < 8; j++) { Rectangle(0, 0, 22, 22), "RadioButtons_" + j.ToString(), "On"); Rectangle _rect; _rect = new Rectangle(100, 100, 100, 100); radios[j] = new RadioCheckField(writer, _rect, "RadioButtons_" + j.ToString(), "On"); radios[j].BackgroundColor = new GrayColor(0.8f); radios[j].BorderColor = GrayColor.BLACK; radios[j].CheckType = RadioCheckField.TYPE_CIRCLE; cell = new PdfPCell(); if (j == 6) { cell.Colspan = 3; radios[j].Text = " Not Important"; } else if (j == 7) { cell.Colspan = 3; radios[j].Text = "Not Applicable"; } else { cell.Colspan = 1; } kid = new iTextSharp.text.pdf.events.FieldPositioningEvents(writer, radios[j].CheckField, "radios"); kid.Padding = 0.5f; cell.CellEvent = kid; table.AddCell(cell); }
Cannot find class type name "Normalized"- Processing
I'm having a dilemma with this code and have no clue what to do. I'm pretty new to processing. This is a project from this link... http://blog.makezine.com/2012/08/10/build-a-touchless-3d-tracking-interface-with-everyday-materials/ any help is massively appreciated... Thanks in advance import processing.serial.*; import processing.opengl.*; Serial serial; int serialPort = 1; int sen = 3; // sensors int div = 3; // board sub divisions Normalize n[] = new Normalize[sen]; MomentumAverage cama[] = new MomentumAverage[sen]; MomentumAverage axyz[] = new MomentumAverage[sen]; float[] nxyz = new float[sen]; int[] ixyz = new int[sen]; float w = 256; // board size boolean[] flip = { false, true, false}; int player = 0; boolean moves[][][][]; PFont font; void setup() { size(800, 600, P3D); frameRate(25); font = loadFont("TrebuchetMS-Italic-20.vlw"); textFont(font); textMode(SCREEN); println(Serial.list()); serial = new Serial(this, Serial.list()[serialPort], 115200); for(int i = 0; i < sen; i++) { n[i] = new Normalize(); cama[i] = new MomentumAverage(.01); axyz[i] = new MomentumAverage(.15); } reset(); } void draw() { updateSerial(); drawBoard(); } void updateSerial() { String cur = serial.readStringUntil('\n'); if(cur != null) { String[] parts = split(cur, " "); if(parts.length == sensors) { float[] xyz = new float[sen]; for(int i = 0; i < sen; i++) xyz[i] = float(parts[i]); if(mousePressed && mouseButton == LEFT) for(int i = 0; i < sen; i++) n[i].note(xyz[i]); nxyz = new float[sen]; for(int i = 0; i < sen; i++) { float raw = n[i].choose(xyz[i]); nxyz[i] = flip[i] ? 1 - raw : raw; cama[i].note(nxyz[i]); axyz[i].note(nxyz[i]); ixyz[i] = getPosition(axyz[i].avg); } } } } float cutoff = .2; int getPosition(float x) { if(div == 3) { if(x < cutoff) return 0; if(x < 1 - cutoff) return 1; else return 2; } else { return x == 1 ? div - 1 : (int) x * div; } } void drawBoard() { background(255); float h = w / 2; camera( h + (cama[0].avg - cama[2].avg) * h, h + (cama[1].avg - 1) * height / 2, w * 2, h, h, h, 0, 1, 0); pushMatrix(); noStroke(); fill(0, 40); translate(w/2, w/2, w/2); rotateY(-HALF_PI/2); box(w); popMatrix(); float sw = w / div; translate(h, sw / 2, 0); rotateY(-HALF_PI/2); pushMatrix(); float sd = sw * (div - 1); translate( axyz[0].avg * sd, axyz[1].avg * sd, axyz[2].avg * sd); fill(255, 160, 0); noStroke(); sphere(18); popMatrix(); for(int z = 0; z < div; z++) { for(int y = 0; y < div; y++) { for(int x = 0; x < div; x++) { pushMatrix(); translate(x * sw, y * sw, z * sw); noStroke(); if(moves[0][x][y][z]) fill(255, 0, 0, 200); else if(moves[1][x][y][z]) fill(0, 0, 255, 200); else if( x == ixyz[0] && y == ixyz[1] && z == ixyz[2]) if(player == 0) fill(255, 0, 0, 200); else fill(0, 0, 255, 200); else fill(0, 100); box(sw / 3); popMatrix(); } } } fill(0); if(mousePressed && mouseButton == LEFT) msg("defining boundaries"); } void keyPressed() { if(key == TAB) { moves[player][ixyz[0]][ixyz[1]][ixyz[2]] = true; player = player == 0 ? 1 : 0; } } void mousePressed() { if(mouseButton == RIGHT) reset(); } void reset() { moves = new boolean[2][div][div][div]; for(int i = 0; i < sen; i++) { n[i].reset(); cama[i].reset(); axyz[i].reset(); } } void msg(String msg) { text(msg, 10, height - 10); }
You are missing a class, in fact, more than one. Go back to the github and download, or copy and paste, all three codes, placing each one in a new tab named same name of the class (well this is not required, but is a good practice). The TicTacToe3D.pde is the main code. To make a new tab choose "new tab" from the arrow menu in Processing IDE (just below the standard button at the right). The code should run. WIll need an Arduino though to really get it working.