public static JRadioButton getRadioButton(String title, boolean isOn) { JRadioButton component = new JRadioButton(title, isOn); component.setCursor(CURSOR); component.setRolloverEnabled(true); component.setBackground(Css.BACKGROUND_COLOR_PANEL); component.setForeground(TEXT_COLOR); return component; }
/** * Initializes a window with all necessary components. This includes a JComboBox, JButton, * multiple JRadioButtons and multiple JLabels into the appropriate panels and adds them to the * current frame. */ private void initUI() { // Get data for comboBox final ArrayList<String> locList = new ArrayList<String>(); // Catch exceptions try { locationList(locList); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // Search buttons and selected value text JLabel lblHello = new JLabel("Choose your location..."); lblHello.setForeground(Color.BLACK); final JLabel lblText = new JLabel(); lblText.setForeground(Color.BLACK); // Radio Buttons JRadioButton radCelsius; final JRadioButton radFahrenheit; radCelsius = new JRadioButton("Celsius"); radCelsius.setSelected(true); radCelsius.setForeground(Color.BLACK); radFahrenheit = new JRadioButton("Fahrenheit"); radFahrenheit.setForeground(Color.BLACK); ButtonGroup grpTemp = new ButtonGroup(); grpTemp.add(radCelsius); grpTemp.add(radFahrenheit); // Auto Complete Combo Box StringSearchable searchable = new StringSearchable(locList); final AutoCompleteJComboBox combo = new AutoCompleteJComboBox(searchable); combo.setEditable(true); // Change listener for when switching between radio buttons radCelsius.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { String msg = "Selected: " + combo.getSelectedItem() + " in Celsius"; lblText.setText(msg); } }); // Change listener for when switching between radio buttons radFahrenheit.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { String msg = "Selected: " + combo.getSelectedItem() + " in Fahrenheit"; lblText.setText(msg); } }); // KeyListener for when hitting enter in window KeyListener eListener = new KeyListener() { public void keyReleased(KeyEvent event) { if (event.getKeyChar() == KeyEvent.VK_ENTER) { combo.setPopupVisible(true); if (!(locList.contains(combo.getSelectedItem()))) { String err = "Error: Incorrect Location, Please Try Again"; lblText.setText(err); } else { String msg = "Selected: " + combo.getSelectedItem(); if (radFahrenheit.isSelected()) msg += " in Fahrenheit"; else msg += " in Celsius"; lblText.setText(msg); } } } public void keyTyped(KeyEvent arg0) {} public void keyPressed(KeyEvent e) {} }; // Action listeners for window radCelsius.addKeyListener(eListener); radFahrenheit.addKeyListener(eListener); combo.getEditor().getEditorComponent().addKeyListener(eListener); // Set Preferred width of combo box combo.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXX"); // Add panes to window JPanel paneNorth = new JPanel(); JPanel paneCenter = new JPanel(); JPanel paneSouth = new JPanel(); JButton GWButton = new JButton("Get Weather"); // Add action listener to button "Get Local Weather" GWButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (!(combo.getSelectedItem().toString().equalsIgnoreCase("mars")) && !(locList.contains(combo.getSelectedItem()))) { String err = "Error: Incorrect Location, Please Try Again"; lblText.setText(err); // combo.setPopupVisible(true); } else { String msg = "Selected: " + combo.getSelectedItem(); if (radFahrenheit.isSelected()) { msg += " in Fahrenheit"; dataRequester.setFahrenheit(); } else { msg += " in Celsius"; dataRequester.setCelcius(); } lblText.setText(msg); // Print result to preferences file for secondary startup try { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("preferences.txt", true))); out.println(lblText.getText().toString()); out.close(); } catch (IOException f) { } String city = combo.getSelectedItem().toString(); String cityName; String cityId; if (city.equalsIgnoreCase("mars")) { cityName = "Mars"; cityId = "Mars"; } else { cityName = city.substring(0, city.indexOf('[')); cityId = city.substring(city.indexOf('[') + 1, city.indexOf(']')); } if (cityId.equals("Mars")) { dataRequester.update(cityId); localWeatherView.setCityName(cityName); try { localWeatherView.setLabels(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } shortTermView.clear(); lblText.setText("Weather Fetched"); } else { dataRequester.update(cityId); localWeatherView.setCityName(cityName); try { localWeatherView.setLabels(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } shortTermView.display(); lblText.setText("Weather Fetched"); } } } }); // Layout for window paneNorth.setLayout(new FlowLayout(FlowLayout.LEFT)); paneNorth.add(lblHello); GroupLayout groupLayout = new GroupLayout(this); groupLayout.setHorizontalGroup( groupLayout .createParallelGroup(Alignment.TRAILING) .addGroup( groupLayout .createSequentialGroup() .addGroup( groupLayout .createParallelGroup(Alignment.LEADING) .addGroup( groupLayout .createSequentialGroup() .addGap(36) .addComponent( paneNorth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup( groupLayout .createSequentialGroup() .addContainerGap() .addComponent( paneCenter, GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE)) .addGroup( groupLayout .createSequentialGroup() .addContainerGap() .addComponent( paneSouth, GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE))) .addContainerGap())); groupLayout.setVerticalGroup( groupLayout .createParallelGroup(Alignment.LEADING) .addGroup( groupLayout .createSequentialGroup() .addGap(5) .addComponent( paneNorth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( paneCenter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( paneSouth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(181))); GroupLayout gl_paneCenter = new GroupLayout(paneCenter); gl_paneCenter.setHorizontalGroup( gl_paneCenter .createParallelGroup(Alignment.LEADING) .addGroup( gl_paneCenter .createSequentialGroup() .addContainerGap() .addComponent( combo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(radFahrenheit) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(radCelsius) .addGap(62))); gl_paneCenter.setVerticalGroup( gl_paneCenter .createParallelGroup(Alignment.LEADING) .addGroup( gl_paneCenter .createSequentialGroup() .addGap(7) .addGroup( gl_paneCenter .createParallelGroup(Alignment.BASELINE) .addComponent( combo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(radFahrenheit) .addComponent(radCelsius)))); paneCenter.setLayout(gl_paneCenter); GroupLayout gl_paneSouth = new GroupLayout(paneSouth); gl_paneSouth.setHorizontalGroup( gl_paneSouth .createParallelGroup(Alignment.LEADING) .addGroup( Alignment.TRAILING, gl_paneSouth .createSequentialGroup() .addGap(7) .addComponent(lblText, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(GWButton) .addContainerGap())); gl_paneSouth.setVerticalGroup( gl_paneSouth .createParallelGroup(Alignment.TRAILING) .addGroup( Alignment.LEADING, gl_paneSouth .createSequentialGroup() .addContainerGap() .addGroup( gl_paneSouth .createParallelGroup(Alignment.TRAILING) .addComponent( lblText, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE) .addComponent(GWButton, Alignment.LEADING)) .addContainerGap())); paneSouth.setLayout(gl_paneSouth); setLayout(groupLayout); }
/** Sets up the GUI (panels, buttons, etc) and displays it on the screen. */ private void init() { DecimalFormat df; int xUnits; String unitStr; String distStr; setForeground(Color.black); setTitle("Center Distances version 2 07/14/08"); df = new DecimalFormat("0.000E0"); GridBagConstraints gbc = new GridBagConstraints(); int yPos = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 1; gbc.insets = new Insets(3, 3, 3, 3); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = yPos++; JPanel mainPanel = new JPanel(new GridBagLayout()); mainPanel.setForeground(Color.black); mainPanel.setBorder(buildTitledBorder("Input parameters")); blueMinLabel = new JLabel("Minimum number of blue pixels per nucleus"); blueMinLabel.setForeground(Color.black); blueMinLabel.setFont(serif12); gbc.gridx = 0; gbc.gridy = yPos; mainPanel.add(blueMinLabel, gbc); blueMinText = new JTextField(5); if (image.getNDims() == 2) { blueMinText.setText("1000"); } else { blueMinText.setText("20000"); } blueMinText.setFont(serif12); gbc.gridx = 1; gbc.gridy = yPos++; mainPanel.add(blueMinText, gbc); redMinLabel = new JLabel("Minimum red pixel count"); redMinLabel.setForeground(Color.black); redMinLabel.setFont(serif12); gbc.gridx = 0; gbc.gridy = yPos; mainPanel.add(redMinLabel, gbc); redMinText = new JTextField(5); redMinText.setText("50"); redMinText.setFont(serif12); gbc.gridx = 1; gbc.gridy = yPos++; mainPanel.add(redMinText, gbc); redFractionLabel = new JLabel("Fraction of red pixels to consider"); redFractionLabel.setForeground(Color.black); redFractionLabel.setFont(serif12); gbc.gridx = 0; gbc.gridy = yPos; mainPanel.add(redFractionLabel, gbc); redFractionText = new JTextField(5); redFractionText.setText("0.15"); redFractionText.setFont(serif12); gbc.gridx = 1; gbc.gridy = yPos++; mainPanel.add(redFractionText, gbc); xUnits = image.getFileInfo(0).getUnitsOfMeasure()[0]; if (xUnits != Unit.UNKNOWN_MEASURE.getLegacyNum()) { unitStr = (Unit.getUnitFromLegacyNum(xUnits)).toString(); greenMergingLabel = new JLabel("Green merging radius around peak (" + unitStr + ")"); } else { greenMergingLabel = new JLabel("Green merging radius around peak"); } greenMergingLabel.setForeground(Color.black); greenMergingLabel.setFont(serif12); gbc.gridx = 0; gbc.gridy = yPos; mainPanel.add(greenMergingLabel, gbc); if (image.getNDims() == 2) { // mergingDistance = 8.0f * image.getFileInfo(0).getResolutions()[0]; mergingDistance = 0.0f; } else { // mergingDistance = 4.0f * image.getFileInfo(0).getResolutions()[0]; mergingDistance = 0.0f; } distStr = df.format(mergingDistance); greenMergingText = new JTextField(10); greenMergingText.setText(distStr); greenMergingText.setFont(serif12); gbc.gridx = 1; gbc.gridy = yPos++; mainPanel.add(greenMergingText, gbc); greenMinLabel = new JLabel("Minimum green pixel count"); greenMinLabel.setForeground(Color.black); greenMinLabel.setFont(serif12); gbc.gridx = 0; gbc.gridy = yPos; mainPanel.add(greenMinLabel, gbc); greenMinText = new JTextField(5); greenMinText.setText("10"); greenMinText.setFont(serif12); gbc.gridx = 1; gbc.gridy = yPos++; mainPanel.add(greenMinText, gbc); greenFractionLabel = new JLabel("Fraction of green pixels to consider"); greenFractionLabel.setForeground(Color.black); greenFractionLabel.setFont(serif12); gbc.gridx = 0; gbc.gridy = yPos; mainPanel.add(greenFractionLabel, gbc); greenFractionText = new JTextField(5); greenFractionText.setText("0.01"); greenFractionText.setFont(serif12); gbc.gridx = 1; gbc.gridy = yPos++; mainPanel.add(greenFractionText, gbc); greenRegionsLabel = new JLabel("Green regions per cell"); greenRegionsLabel.setForeground(Color.black); greenRegionsLabel.setFont(serif12); gbc.gridx = 0; gbc.gridy = yPos; mainPanel.add(greenRegionsLabel, gbc); JPanel buttonPanel = new JPanel(new GridBagLayout()); greenGroup = new ButtonGroup(); oneButton = new JRadioButton("1", false); oneButton.setForeground(Color.black); oneButton.setFont(serif12); greenGroup.add(oneButton); gbc.gridx = 0; gbc.gridy = 0; buttonPanel.add(oneButton, gbc); twoButton = new JRadioButton("2", true); twoButton.setForeground(Color.black); twoButton.setFont(serif12); greenGroup.add(twoButton); gbc.gridx = 1; gbc.gridy = 0; buttonPanel.add(twoButton, gbc); threeButton = new JRadioButton("3", false); threeButton.setForeground(Color.black); threeButton.setFont(serif12); greenGroup.add(threeButton); gbc.gridx = 2; gbc.gridy = 0; buttonPanel.add(threeButton, gbc); fourButton = new JRadioButton("4", false); fourButton.setForeground(Color.black); fourButton.setFont(serif12); greenGroup.add(fourButton); gbc.gridx = 3; gbc.gridy = 0; buttonPanel.add(fourButton, gbc); gbc.gridx = 1; gbc.gridy = yPos++; mainPanel.add(buttonPanel, gbc); twoBox = new JCheckBox("Use 2 top gray levels in green segmentation", true); twoBox.setForeground(Color.black); twoBox.setFont(serif12); gbc.gridx = 0; gbc.gridy = yPos++; mainPanel.add(twoBox, gbc); blueValueLabel = new JLabel("Fraction of blue transition from image min to max at nucleus boundary"); blueValueLabel.setForeground(Color.black); blueValueLabel.setFont(serif12); gbc.gridx = 0; gbc.gridy = yPos; mainPanel.add(blueValueLabel, gbc); blueValueText = new JTextField(5); blueValueText.setText("0.15"); blueValueText.setFont(serif12); gbc.gridx = 1; gbc.gridy = yPos++; mainPanel.add(blueValueText, gbc); blueSmoothBox = new JCheckBox("Smooth blue VOI contours with AlgorithmBSmooth", true); blueSmoothBox.setForeground(Color.black); blueSmoothBox.setFont(serif12); blueSmoothBox.addActionListener(this); gbc.gridx = 0; gbc.gridy = yPos++; mainPanel.add(blueSmoothBox, gbc); interpolationLabel = new JLabel("Number of interpolation points determined by divisor (> 1.0)"); interpolationLabel.setForeground(Color.black); interpolationLabel.setFont(serif12); gbc.gridx = 0; gbc.gridy = yPos; mainPanel.add(interpolationLabel, gbc); interpolationText = new JTextField(5); interpolationText.setText("24.0"); interpolationText.setFont(serif12); gbc.gridx = 1; gbc.gridy = yPos++; mainPanel.add(interpolationText, gbc); getContentPane().add(mainPanel, BorderLayout.CENTER); getContentPane().add(buildButtons(), BorderLayout.SOUTH); pack(); setVisible(true); setResizable(false); System.gc(); } // end init()
public static void main(String args[]) { JRadioButton rb = new JRadioButton(); rb.getAccessibleContext(); rb.isFocusTraversable(); rb.setEnabled(false); rb.setEnabled(true); rb.requestFocus(); rb.requestFocusInWindow(); rb.getPreferredSize(); rb.getMaximumSize(); rb.getMinimumSize(); rb.contains(1, 2); Component c1 = rb.add(new Component() {}); Component c2 = rb.add(new Component() {}); Component c3 = rb.add(new Component() {}); Insets ins = rb.getInsets(); rb.getAlignmentY(); rb.getAlignmentX(); rb.getGraphics(); rb.setVisible(false); rb.setVisible(true); rb.setForeground(Color.red); rb.setBackground(Color.red); for (String font : Toolkit.getDefaultToolkit().getFontList()) { for (int j = 8; j < 17; j++) { Font f1 = new Font(font, Font.PLAIN, j); Font f2 = new Font(font, Font.BOLD, j); Font f3 = new Font(font, Font.ITALIC, j); Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); rb.setFont(f1); rb.setFont(f2); rb.setFont(f3); rb.setFont(f4); rb.getFontMetrics(f1); rb.getFontMetrics(f2); rb.getFontMetrics(f3); rb.getFontMetrics(f4); } } rb.enable(); rb.disable(); rb.reshape(10, 10, 10, 10); rb.getBounds(new Rectangle(1, 1, 1, 1)); rb.getSize(new Dimension(1, 2)); rb.getLocation(new Point(1, 2)); rb.getX(); rb.getY(); rb.getWidth(); rb.getHeight(); rb.isOpaque(); rb.isValidateRoot(); rb.isOptimizedDrawingEnabled(); rb.isDoubleBuffered(); rb.getComponentCount(); rb.countComponents(); rb.getComponent(1); rb.getComponent(2); Component[] cs = rb.getComponents(); rb.getLayout(); rb.setLayout(new FlowLayout()); rb.doLayout(); rb.layout(); rb.invalidate(); rb.validate(); rb.remove(0); rb.remove(c2); rb.removeAll(); rb.preferredSize(); rb.minimumSize(); rb.getComponentAt(1, 2); rb.locate(1, 2); rb.getComponentAt(new Point(1, 2)); rb.isFocusCycleRoot(new Container()); rb.transferFocusBackward(); rb.setName("goober"); rb.getName(); rb.getParent(); rb.getGraphicsConfiguration(); rb.getTreeLock(); rb.getToolkit(); rb.isValid(); rb.isDisplayable(); rb.isVisible(); rb.isShowing(); rb.isEnabled(); rb.enable(false); rb.enable(true); rb.enableInputMethods(false); rb.enableInputMethods(true); rb.show(); rb.show(false); rb.show(true); rb.hide(); rb.getForeground(); rb.isForegroundSet(); rb.getBackground(); rb.isBackgroundSet(); rb.getFont(); rb.isFontSet(); Container c = new Container(); c.add(rb); rb.getLocale(); for (Locale locale : Locale.getAvailableLocales()) rb.setLocale(locale); rb.getColorModel(); rb.getLocation(); boolean exceptions = false; try { rb.getLocationOnScreen(); } catch (IllegalComponentStateException e) { exceptions = true; } if (!exceptions) throw new RuntimeException("IllegalComponentStateException did not occur when expected"); rb.location(); rb.setLocation(1, 2); rb.move(1, 2); rb.setLocation(new Point(1, 2)); rb.getSize(); rb.size(); rb.setSize(1, 32); rb.resize(1, 32); rb.setSize(new Dimension(1, 32)); rb.resize(new Dimension(1, 32)); rb.getBounds(); rb.bounds(); rb.setBounds(10, 10, 10, 10); rb.setBounds(new Rectangle(10, 10, 10, 10)); rb.isLightweight(); rb.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); rb.getCursor(); rb.isCursorSet(); rb.inside(1, 2); rb.contains(new Point(1, 2)); rb.isFocusable(); rb.setFocusable(true); rb.setFocusable(false); rb.transferFocus(); rb.getFocusCycleRootAncestor(); rb.nextFocus(); rb.transferFocusUpCycle(); rb.hasFocus(); rb.isFocusOwner(); rb.toString(); rb.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); rb.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); rb.setComponentOrientation(ComponentOrientation.UNKNOWN); rb.getComponentOrientation(); }
private void setup() { setLayout(null); this.setSize(1200, 800); setBackground(Color.DARK_GRAY); list.setFont(new Font("Arial", Font.PLAIN, 24)); list.setBounds(52, 118, 429, 501); selecionado1 = new Label(""); selecionado1.setForeground(Color.WHITE); selecionado1.setFont(new Font("Dialog", Font.PLAIN, 18)); selecionado1.setBounds(560, 128, 611, 43); add(selecionado1); PreencheGenero(); add(list); logout = new JButton("Logout"); logout.setBounds(1074, 673, 97, 25); logout.addActionListener(this); logout.setVisible(true); add(logout); autor = new JRadioButton("Autor"); autor.setForeground(Color.WHITE); autor.setFont(new Font("Tahoma", Font.PLAIN, 18)); autor.setSelected(false); autor.setBackground(Color.DARK_GRAY); autor.setBounds(52, 56, 127, 25); autor.addActionListener(this); add(autor); titulo = new JRadioButton("Trabalho artístico"); titulo.setForeground(Color.WHITE); titulo.setFont(new Font("Tahoma", Font.PLAIN, 18)); titulo.setBackground(Color.DARK_GRAY); titulo.setSelected(false); titulo.setBounds(275, 56, 181, 25); titulo.addActionListener(this); add(titulo); genero = new JRadioButton("Gênero"); genero.setForeground(Color.WHITE); genero.setFont(new Font("Tahoma", Font.PLAIN, 18)); genero.setBackground(Color.DARK_GRAY); genero.setSelected(true); genero.setBounds(499, 58, 127, 25); genero.addActionListener(this); add(genero); selecionado2 = new Label(""); selecionado2.setForeground(Color.WHITE); selecionado2.setFont(new Font("Dialog", Font.PLAIN, 18)); selecionado2.setBounds(560, 197, 611, 43); add(selecionado2); selecionado3 = new Label(""); selecionado3.setForeground(Color.WHITE); selecionado3.setFont(new Font("Dialog", Font.PLAIN, 18)); selecionado3.setBounds(560, 268, 611, 55); add(selecionado3); label = new Label("Selecione um Filtro"); label.setForeground(Color.WHITE); label.setFont(new Font("Dialog", Font.PLAIN, 18)); label.setBounds(52, 10, 611, 43); add(label); adicionar = new JButton("Adicionar"); adicionar.setBounds(956, 673, 97, 25); adicionar.addActionListener(this); add(adicionar); Label logado = new Label("Selecione um Filtro"); logado.setAlignment(Label.RIGHT); logado.setForeground(Color.WHITE); logado.setFont(new Font("Dialog", Font.PLAIN, 18)); logado.setBounds(722, 10, 449, 43); logado.setText("Olá, " + Main.user.getNome()); add(logado); }
public Start() { frame = new JFrame("Airplane Shooter"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(400, 200, 400, 600); JPanel LeftPanel = new JPanel(); LeftPanel.setPreferredSize(new Dimension(250, 200)); LeftPanel.setBackground(new Color(59, 89, 152)); LeftPanel.setLayout(null); text = new JLabel("Welcome"); text.setBounds(90, 30, 150, 20); text.setFont(new Font("sansserif", Font.BOLD, 24)); text.setForeground(new Color(255, 255, 255)); namee = new JLabel("Player Name:"); namee.setBounds(10, 80, 85, 20); namee.setForeground(new Color(255, 255, 255)); nameEnter = new JTextField(); nameEnter.setBounds(90, 80, 120, 20); singlePlayer = new JRadioButton("Single PLayer"); singlePlayer.setSelected(true); singlePlayer.setBounds(90, 100, 120, 20); singlePlayer.setBackground(new Color(59, 89, 152)); singlePlayer.setForeground(new Color(255, 255, 255)); multiuplayer = new JRadioButton("Multi PLayer"); multiuplayer.setBounds(90, 120, 120, 20); multiuplayer.setBackground(new Color(59, 89, 152)); multiuplayer.setForeground(new Color(255, 255, 255)); group = new ButtonGroup(); group.add(multiuplayer); group.add(singlePlayer); play = new JButton("Play"); play.setBackground(new Color(98, 122, 172)); play.setForeground(new Color(255, 255, 255)); play.setBounds(90, 155, 120, 20); play.addActionListener(this); cancel = new JButton("Exit"); cancel.setBackground(new Color(98, 122, 172)); cancel.setForeground(new Color(255, 255, 255)); cancel.setBounds(90, 180, 120, 20); cancel.addActionListener(this); LeftPanel.add(text); LeftPanel.add(cancel); LeftPanel.add(play); LeftPanel.add(namee); LeftPanel.add(nameEnter); LeftPanel.add(singlePlayer); LeftPanel.add(multiuplayer); frame.getContentPane().add(LeftPanel); frame.pack(); frame.setResizable(false); frame.setVisible(true); }
private void makeMenuScreen() { menu = new JPanel(); menu.setBackground(Color.BLACK); menu.setLayout(null); menu.setBounds(0, 0, width, height); try { BufferedImage menuIMG = ImageIO.read(this.getClass().getResource("/Resources/MenuBackground.png")); // BufferedImage menuIMG = ImageIO.read(new // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/MenuBackground.png")); menuIMGL = new JLabel( new ImageIcon( menuIMG.getScaledInstance( (int) (width * 0.8), (int) (height * 0.8), Image.SCALE_SMOOTH))); menuIMGL.setBounds(0, 0, width, height); } catch (Exception e) { } highscoreL = new JLabel(String.valueOf(highscore)); highscoreL.setBackground(Color.darkGray); highscoreL.setBounds((width / 2) + 100, (height / 2) + 70, 500, 100); highscoreL.setForeground(Color.white); easy = new JButton("Easy"); hard = new JButton("Hard"); easy.addActionListener(this); hard.addActionListener(this); easy.setBounds((width / 2) - 60, (height / 2) - 50, 120, 20); hard.setBounds((width / 2) - 60, height / 2 - 10, 120, 20); onePlayerRB = new JRadioButton("One Player"); twoPlayerRB = new JRadioButton("Two Player"); mouseRB = new JRadioButton("Mouse (Player 1)"); keyboardRB = new JRadioButton("Keyboard (Player 1)"); keyboardSpeedS1 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50); keyboardSpeedS2 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50); musicCB = new JCheckBox("Music"); onePlayerRB.setBackground(null); twoPlayerRB.setBackground(null); mouseRB.setBackground(null); keyboardRB.setBackground(null); keyboardSpeedS1.setBackground(null); keyboardSpeedS2.setBackground(null); musicCB.setBackground(null); onePlayerRB.setForeground(Color.WHITE); twoPlayerRB.setForeground(Color.WHITE); mouseRB.setForeground(Color.WHITE); keyboardRB.setForeground(Color.WHITE); keyboardSpeedS1.setForeground(Color.WHITE); keyboardSpeedS2.setForeground(Color.WHITE); musicCB.setForeground(Color.WHITE); ButtonGroup playerChoice = new ButtonGroup(); playerChoice.add(onePlayerRB); playerChoice.add(twoPlayerRB); onePlayerRB.setSelected(true); ButtonGroup peripheralChoice = new ButtonGroup(); peripheralChoice.add(mouseRB); peripheralChoice.add(keyboardRB); mouseRB.setSelected(true); musicCB.setSelected(true); onePlayerRB.setBounds((width / 2) + 100, (height / 2) - 50, 100, 20); twoPlayerRB.setBounds((width / 2) + 100, (height / 2) - 30, 100, 20); mouseRB.setBounds((width / 2) + 100, (height / 2), 200, 20); keyboardRB.setBounds((width / 2) + 100, (height / 2) + 20, 200, 20); keyboardSpeedS1.setBounds(width / 2 - 120, height / 2 + 100, 200, 50); keyboardSpeedS2.setBounds(width / 2 - 120, height / 2 + 183, 200, 50); musicCB.setBounds((width / 2) + 100, (height / 2) + 50, 100, 20); keyboardSpeedL1 = new JLabel("Keyboard Speed (Player One)"); keyboardSpeedL1.setForeground(Color.WHITE); keyboardSpeedL1.setBounds(width / 2 - 113, height / 2 + 67, 200, 50); keyboardSpeedL2 = new JLabel("Keyboard Speed (Player Two)"); keyboardSpeedL2.setForeground(Color.WHITE); keyboardSpeedL2.setBounds(width / 2 - 113, height / 2 + 150, 200, 50); howTo = new JButton("How To Play"); howTo.addActionListener(this); howTo.setBounds((width / 2) - 60, height / 2 + 30, 120, 20); try { BufferedImage howToIMG = ImageIO.read(this.getClass().getResource("/Resources/HowTo.png")); // BufferedImage howToIMG = ImageIO.read(new // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/HowTo.png")); howToIMGL = new JLabel(new ImageIcon(howToIMG)); howToIMGL.setBounds( width / 2 - howToIMG.getWidth() / 2, height / 2 - howToIMG.getHeight() / 2, howToIMG.getWidth(), howToIMG.getHeight()); } catch (Exception e) { } howToBack = new JButton("X"); howToBack.setBounds( (int) (width / 2 + width * 0.25) - 50, (int) (height / 2 - height * 0.25), 50, 50); howToBack.setBackground(Color.BLACK); howToBack.setForeground(Color.WHITE); howToBack.addActionListener(this); menu.add(easy); menu.add(hard); menu.add(howTo); menu.add(highscoreL); menu.add(onePlayerRB); menu.add(twoPlayerRB); menu.add(mouseRB); menu.add(keyboardRB); menu.add(keyboardSpeedL1); menu.add(keyboardSpeedL2); menu.add(keyboardSpeedS1); menu.add(keyboardSpeedS2); menu.add(musicCB); menu.add(menuIMGL); back = new JButton("Back"); back.setBounds(width / 2 - 40, height / 2, 100, 20); back.addActionListener(this); back.setVisible(false); this.add(back); }
// End of variables declaration private void initComponents() { model = new DefaultListModel(); afkButtonGroup = new javax.swing.ButtonGroup(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(model); jButton1 = new javax.swing.JButton(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel3 = new javax.swing.JPanel(); jTabbedPane2 = new javax.swing.JTabbedPane(); jPanel5 = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); jRadioButton1 = new javax.swing.JRadioButton(); jRadioButton2 = new javax.swing.JRadioButton(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField(); jButton2 = new javax.swing.JButton(); addWindowListener( new java.awt.event.WindowAdapter() { @Override public void windowClosing(final java.awt.event.WindowEvent evt) { exitForm(evt); } }); setTitle("iPhQ's Alcher - Settings"); jPanel1.setBackground(new java.awt.Color(0, 102, 102)); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); jLabel1.setForeground(new java.awt.Color(204, 204, 0)); jLabel1.setText("iPhQ's Alcher - Settings"); jPanel2.setBackground(new java.awt.Color(0, 102, 102)); jPanel2.setBorder( javax.swing.BorderFactory.createTitledBorder( null, "Items in your Inventory", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 0))); // NOI18N jLabel2.setForeground(new java.awt.Color(255, 255, 0)); jLabel2.setText( "<html><body>Select item(s) to alch from the <br/> list below (you must be logged in for this to work) :</body></body>"); jScrollPane1.setViewportView(jList1); jButton1.setText("Refresh the List"); jButton1.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(final java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); final javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel2Layout .createSequentialGroup() .addGroup( jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel2Layout .createSequentialGroup() .addComponent( jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(16, 16, 16)) .addComponent( jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE) .addComponent( jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)) .addContainerGap())); jPanel2Layout.setVerticalGroup( jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel2Layout .createSequentialGroup() .addComponent( jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); jPanel3.setBackground(new java.awt.Color(0, 102, 102)); jPanel5.setBackground(new java.awt.Color(0, 102, 102)); jPanel4.setBackground(new java.awt.Color(0, 102, 102)); jPanel4.setBorder( javax.swing.BorderFactory.createTitledBorder( null, "Anti-ban Settings", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 0))); // NOI18N jRadioButton1.setBackground(new java.awt.Color(0, 102, 102)); afkButtonGroup.add(jRadioButton1); jRadioButton1.setForeground(new java.awt.Color(255, 255, 0)); jRadioButton1.setSelected(true); jRadioButton1.setText("AFK On"); jRadioButton2.setBackground(new java.awt.Color(0, 102, 102)); afkButtonGroup.add(jRadioButton2); jRadioButton2.setForeground(new java.awt.Color(255, 255, 0)); jRadioButton2.setText("AFK Off"); jLabel3.setForeground(new java.awt.Color(255, 255, 0)); jLabel3.setText("AFK Time (ms [1 second = 1000ms]): "); jLabel4.setForeground(new java.awt.Color(255, 255, 0)); jLabel4.setText("Min: "); jLabel5.setForeground(new java.awt.Color(255, 255, 0)); jLabel5.setText("Max: "); jTextField1.setText("5000"); jTextField2.setText("25000"); final javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel4Layout .createSequentialGroup() .addGroup( jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel4Layout .createSequentialGroup() .addGap(56, 56, 56) .addComponent(jLabel3)) .addGroup( jPanel4Layout .createSequentialGroup() .addContainerGap() .addGroup( jPanel4Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel4Layout .createSequentialGroup() .addComponent(jRadioButton1) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED, 223, Short.MAX_VALUE) .addComponent(jRadioButton2)) .addGroup( jPanel4Layout .createSequentialGroup() .addComponent(jLabel4) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent(jLabel5) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE))))) .addContainerGap())); jPanel4Layout.setVerticalGroup( jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel4Layout .createSequentialGroup() .addContainerGap() .addGroup( jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jRadioButton1) .addComponent( jRadioButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4) .addComponent(jLabel5)))); final javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel5Layout .createSequentialGroup() .addContainerGap() .addComponent( jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); jPanel5Layout.setVerticalGroup( jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout .createSequentialGroup() .addContainerGap() .addComponent( jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE) .addContainerGap())); jTabbedPane2.addTab("AFK", jPanel5); final javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel3Layout .createSequentialGroup() .addContainerGap() .addComponent( jTabbedPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE) .addContainerGap())); jPanel3Layout.setVerticalGroup( jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel3Layout .createSequentialGroup() .addContainerGap() .addComponent( jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jTabbedPane2.getAccessibleContext().setAccessibleName("AFK Settings"); jTabbedPane1.addTab("Anti-ban", jPanel3); jButton2.setText("Start Script"); jButton2.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(final java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); final javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel1Layout .createSequentialGroup() .addContainerGap() .addGroup( jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 718, Short.MAX_VALUE) .addGroup( jPanel1Layout .createSequentialGroup() .addGroup( jPanel1Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent( jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE) .addComponent( jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent( jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE))) .addContainerGap())); jPanel1Layout.setVerticalGroup( jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( jPanel1Layout .createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jTabbedPane1, 0, 0, Short.MAX_VALUE) .addComponent( jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); final javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)); pack(); } // </editor-fold>