@Override protected JComponent getRowPresentation( ParameterTableModelItemBase<ParameterInfoImpl> item, boolean selected, final boolean focused) { final JPanel panel = new JPanel(new BorderLayout()); final String typeText = item.typeCodeFragment.getText(); final String separator = StringUtil.repeatSymbol(' ', getTypesMaxLength() - typeText.length() + 1); String text = typeText + separator + item.parameter.getName(); final String defaultValue = item.defaultValueCodeFragment.getText(); String tail = ""; if (StringUtil.isNotEmpty(defaultValue)) { tail += " default value = " + defaultValue; } if (item.parameter.isUseAnySingleVariable()) { if (StringUtil.isNotEmpty(defaultValue)) { tail += ";"; } tail += " Use any var."; } if (!StringUtil.isEmpty(tail)) { text += " //" + tail; } final EditorTextField field = new EditorTextField(" " + text, getProject(), getFileType()) { @Override protected boolean shouldHaveBorder() { return false; } }; Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN); font = new Font(font.getFontName(), font.getStyle(), 12); field.setFont(font); if (selected && focused) { panel.setBackground(UIUtil.getTableSelectionBackground()); field.setAsRendererWithSelection( UIUtil.getTableSelectionBackground(), UIUtil.getTableSelectionForeground()); } else { panel.setBackground(UIUtil.getTableBackground()); if (selected && !focused) { panel.setBorder(new DottedBorder(UIUtil.getTableForeground())); } } panel.add(field, BorderLayout.WEST); return panel; }
private int getColumnWidth(int index) { int letters = getTypesMaxLength() + (index == 0 ? 1 : getNamesMaxLength() + 2); Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN); font = new Font(font.getFontName(), font.getStyle(), 12); return letters * Toolkit.getDefaultToolkit().getFontMetrics(font).stringWidth("W"); }
public GUI() { // Sets the text and initiates the objects for the buttons playButton = new JButton("PLAY"); exitButton = new JButton("QUIT"); howToPlay = new JButton("HOW TO PLAY"); quitEducation = new JButton("Quit education"); rollDice = new JButton("ROLL THE DICE"); saveCareerProspects = new JButton("Save career prospects"); exitApplication = new JButton("Exit application"); // The main container for the JFrames // container for frame JPanel welcome = new JPanel(); spalshScreen.setContentPane(welcome); JPanel container = new JPanel(); frame.setContentPane(container); // container for frame 2 JPanel container2 = new JPanel(); container2.setBackground(Color.WHITE); frame2.setContentPane(container2); // container for frame 3 JPanel container3 = new JPanel(); container3.setBackground(Color.WHITE); frame3.setContentPane(container3); loading = new javax.swing.JLabel(); loading.setIcon( new javax.swing.ImageIcon(getClass().getClassLoader().getResource("images/hexLoader.gif"))); // start panel with play button and exit button // for frame playerName = new javax.swing.JTextField(); playerName.setText("Player"); playerName.setLocation(100, 100); playerName.setPreferredSize(new Dimension(100, 100)); playerName.setHorizontalAlignment(JTextField.CENTER); JPanel frame = new JPanel(); frame.add(playerName); frame.add(playButton); playButton.setPreferredSize(new Dimension(200, 100)); frame.add(exitButton); exitButton.setPreferredSize(new Dimension(200, 100)); frame.add(howToPlay); howToPlay.setPreferredSize(new Dimension(200, 100)); // board image start screen start = new javax.swing.JLabel(); start.setIcon( new javax.swing.ImageIcon(getClass().getClassLoader().getResource("images/logo2.png"))); // for frame 2 JPanel frame2 = new JPanel(); frame2.add(quitEducation); /* Start of creating the board */ JButton ordinaryButton; int row = 10, column = 10; frame2.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(3, 3, 3, 3); for (int j = 1; j <= row; j++) { for (int i = 0; i < column; i++) { ordinaryButton = new JButton(); if (i == column - 1 && j == row) doActiveTile(ordinaryButton); if (j == 1) { // top line gbc.ipady = 30; gbc.gridx = i; gbc.gridy = j; gbc.gridwidth = 1; addToList(ordinaryButton, TOP); frame2.add(ordinaryButton, gbc); // add in the frame } else { if (j == 10) { // bottom line gbc.ipady = 30; gbc.gridx = i; gbc.gridy = j; gbc.gridwidth = 1; addToList(ordinaryButton, BOTTOM); frame2.add(ordinaryButton, gbc); // add in the frame } else { if (i == 0) { // left-hand side column gbc.ipady = 30; gbc.gridx = i; gbc.gridy = j; gbc.gridwidth = 1; addToList(ordinaryButton, LEFT); frame2.add(ordinaryButton, gbc); // add in the frame } else { if (i == 9) { // right-hand side column gbc.ipady = 30; gbc.gridx = i; gbc.gridy = j; gbc.gridwidth = 1; addToList(ordinaryButton, RIGHT); frame2.add(ordinaryButton, gbc); // add in the frame } } } } } } /* End of creating the board */ /* adding constraints for roll dice and Quit education */ gbc.ipady = 30; gbc.gridx = 2; gbc.gridy = 4; gbc.gridwidth = 2; frame2.add(rollDice, gbc); // add in the frame gbc.ipady = 30; gbc.gridx = 6; gbc.gridy = 4; gbc.gridwidth = 2; frame2.add(quitEducation, gbc); // add in the frame /* END OF adding constraints for roll dice and Quit education */ // for frame 3 JPanel frame3 = new JPanel(); frame3.setLayout(new GridBagLayout()); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(3, 3, 3, 3); gbc.ipady = 30; gbc.gridx = 1; gbc.gridy = 1; gbc.gridwidth = 4; frame3.add(saveCareerProspects, gbc); frame3.setBackground(Color.WHITE); skillsLabel = new javax.swing.JLabel("SKILLS"); skillsLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.ORANGE)); Font font = skillsLabel.getFont(); // same font but bold int fontSize = font.getSize(); fontSize += 5; Font boldFont = new Font(font.getFontName(), Font.BOLD, fontSize); skillsLabel.setFont(boldFont); gbc.ipady = 10; gbc.gridx = 1; gbc.gridy = 3; gbc.gridwidth = 1; frame3.add(skillsLabel, gbc); mathematicsLabel = new javax.swing.JLabel(); mathematicsLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.PINK)); gbc.gridx = 1; gbc.gridy = 4; gbc.gridwidth = 1; frame3.add(mathematicsLabel, gbc); scienceLabel = new javax.swing.JLabel(); scienceLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.CYAN)); gbc.gridx = 1; gbc.gridy = 5; gbc.gridwidth = 1; frame3.add(scienceLabel, gbc); computerScienceLabel = new javax.swing.JLabel(); computerScienceLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.green)); gbc.gridx = 1; gbc.gridy = 6; gbc.gridwidth = 1; frame3.add(computerScienceLabel, gbc); geographyLabel = new javax.swing.JLabel(); geographyLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.RED)); gbc.gridx = 1; gbc.gridy = 7; gbc.gridwidth = 1; frame3.add(geographyLabel, gbc); historyLabel = new javax.swing.JLabel(); historyLabel.setBorder(BorderFactory.createMatteBorder(1, 5, 1, 1, Color.BLACK)); gbc.gridx = 1; gbc.gridy = 8; gbc.gridwidth = 1; frame3.add(historyLabel, gbc); gbc.ipady = 30; gbc.gridx = 1; gbc.gridy = 9; gbc.gridwidth = 4; frame3.add(exitApplication, gbc); gbc.ipady = 10; careersLabel = new javax.swing.JLabel("CAREER PROSPECTS", SwingConstants.RIGHT); gbc.gridx = 3; gbc.gridy = 3; gbc.gridwidth = 1; careersLabel.setFont(boldFont); frame3.add(careersLabel, gbc); secondColMaths = new javax.swing.JLabel(mathematicsCareer[0], SwingConstants.RIGHT); gbc.gridx = 3; gbc.gridy = 4; gbc.gridwidth = 1; frame3.add(secondColMaths, gbc); secondColScience = new javax.swing.JLabel(scienceCareer[0], SwingConstants.RIGHT); gbc.gridx = 3; gbc.gridy = 5; gbc.gridwidth = 1; frame3.add(secondColScience, gbc); secondColCompScience = new javax.swing.JLabel(computerScienceCareer[0], SwingConstants.RIGHT); gbc.gridx = 3; gbc.gridy = 6; gbc.gridwidth = 1; frame3.add(secondColCompScience, gbc); secondColGeography = new javax.swing.JLabel(geographyCareer[0], SwingConstants.RIGHT); gbc.gridx = 3; gbc.gridy = 7; gbc.gridwidth = 1; frame3.add(secondColGeography, gbc); secondColHistory = new javax.swing.JLabel(historyCareer[0], SwingConstants.RIGHT); gbc.gridx = 3; gbc.gridy = 8; gbc.gridwidth = 1; frame3.add(secondColHistory, gbc); JLabel skills = new javax.swing.JLabel(); skills.setIcon( new javax.swing.ImageIcon(getClass().getClassLoader().getResource("images/small.jpg"))); gbc.gridx = 1; gbc.gridy = 1; gbc.gridheight = 9; gbc.gridwidth = 3; frame3.add(skills, gbc); JLabel backgroundImage = new javax.swing.JLabel(); backgroundImage.setIcon( new javax.swing.ImageIcon(getClass().getClassLoader().getResource("images/logoSmall.jpg"))); gbc.gridx = 3; gbc.gridy = 2; gbc.gridheight = 2; gbc.gridwidth = 3; frame2.setBackground(Color.WHITE); frame2.add(backgroundImage, gbc); JLabel rollDiceImage = new javax.swing.JLabel(); rollDiceImage.setIcon( new javax.swing.ImageIcon(getClass().getClassLoader().getResource("images/rollDice.jpg"))); gbc.gridx = 2; gbc.gridy = 5; gbc.gridheight = 3; gbc.gridwidth = 3; frame2.add(rollDiceImage, gbc); JLabel quitEducationImage = new javax.swing.JLabel(); quitEducationImage.setIcon( new javax.swing.ImageIcon( getClass().getClassLoader().getResource("images/quitEducation.jpg"))); gbc.gridx = 6; gbc.gridy = 5; gbc.gridheight = 3; gbc.gridwidth = 3; frame2.add(quitEducationImage, gbc); exitApplication.setFont(boldFont); saveCareerProspects.setFont(boldFont); saveCareerProspects.setForeground(Color.ORANGE); exitApplication.setBackground(Color.BLACK); exitApplication.setForeground(Color.RED); Border border = new LineBorder(Color.LIGHT_GRAY, 5); exitApplication.setBorder(border); saveCareerProspects.setBorder(border); start.setBorder(border); howToPlay.setBorder(border); playButton.setBorder(border); exitButton.setBorder(border); howToPlay.setFont(boldFont); playButton.setFont(boldFont); exitButton.setFont(boldFont); border = new LineBorder(Color.ORANGE, 5); playerName.setBorder(border); // Adds the fields to the panel // Adds all the panels to the container welcome.add(loading); container.add(start); container.add(frame); container2.add(frame2); container3.add(frame3); // Action Listeners for the buttons howToPlay.addActionListener(this); playButton.addActionListener(this); exitButton.addActionListener(this); quitEducation.addActionListener(this); rollDice.addActionListener(this); saveCareerProspects.addActionListener(this); exitApplication.addActionListener(this); // Starts up the UI startGui(); print(); }