List of usage examples for java.awt GridLayout setRows
public void setRows(int rows)
From source file:com.heliosdecompiler.bootstrapper.Bootstrapper.java
private static HeliosData loadHelios() throws IOException { System.out.println("Finding Helios implementation"); HeliosData data = new HeliosData(); boolean needsToDownload = !IMPL_FILE.exists(); if (!needsToDownload) { try (JarFile jarFile = new JarFile(IMPL_FILE)) { ZipEntry entry = jarFile.getEntry("META-INF/MANIFEST.MF"); if (entry == null) { needsToDownload = true;/*w w w . j a v a 2s .co m*/ } else { Manifest manifest = new Manifest(jarFile.getInputStream(entry)); String ver = manifest.getMainAttributes().getValue("Implementation-Version"); try { data.buildNumber = Integer.parseInt(ver); data.version = manifest.getMainAttributes().getValue("Version"); data.mainClass = manifest.getMainAttributes().getValue("Main-Class"); } catch (NumberFormatException e) { needsToDownload = true; } } } catch (IOException e) { needsToDownload = true; } } if (needsToDownload) { URL latestJar = new URL(LATEST_JAR); System.out.println("Downloading latest Helios implementation"); FileOutputStream out = new FileOutputStream(IMPL_FILE); HttpURLConnection connection = (HttpURLConnection) latestJar.openConnection(); if (connection.getResponseCode() == 200) { int contentLength = connection.getContentLength(); if (contentLength > 0) { InputStream stream = connection.getInputStream(); byte[] buffer = new byte[1024]; int amnt; AtomicInteger total = new AtomicInteger(); AtomicBoolean stop = new AtomicBoolean(false); Thread progressBar = new Thread() { public void run() { JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); JLabel label = new JLabel(); label.setText("Downloading latest Helios build"); panel.add(label); GridLayout layout = new GridLayout(); layout.setColumns(1); layout.setRows(3); panel.setLayout(layout); JProgressBar pbar = new JProgressBar(); pbar.setMinimum(0); pbar.setMaximum(100); panel.add(pbar); JTextArea textArea = new JTextArea(1, 3); textArea.setOpaque(false); textArea.setEditable(false); textArea.setText("Downloaded 00.00MB/00.00MB"); panel.add(textArea); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setContentPane(panel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); while (!stop.get()) { SwingUtilities.invokeLater( () -> pbar.setValue((int) (100.0 * total.get() / contentLength))); textArea.setText("Downloaded " + bytesToMeg(total.get()) + "MB/" + bytesToMeg(contentLength) + "MB"); try { Thread.sleep(100); } catch (InterruptedException ignored) { } } frame.dispose(); } }; progressBar.start(); while ((amnt = stream.read(buffer)) != -1) { out.write(buffer, 0, amnt); total.addAndGet(amnt); } stop.set(true); return loadHelios(); } else { throw new IOException("Content-Length set to " + connection.getContentLength()); } } else if (connection.getResponseCode() == 404) { // Most likely bootstrapper is out of date throw new RuntimeException("Bootstrapper out of date!"); } else { throw new IOException(connection.getResponseCode() + ": " + connection.getResponseMessage()); } } return data; }
From source file:Main.java
public Main() { JButton button = new JButton("w w w.j a v a 2 s . c o m"); add(button);/*from w w w .j a v a 2 s. c o m*/ add(new JButton("w w w.j a v a 2 s . com")); add(new JButton("w w w.java2s.com")); add(new JButton("www.j ava 2 s . c o m")); GridLayout gridLayout = new GridLayout(); gridLayout.setColumns(2); gridLayout.setRows(2); setLayout(gridLayout); }
From source file:problema_inventario.vistas.GraphicCostos.java
private void initLayout() { GridLayout l = new GridLayout(); l.setColumns(1);// w w w .j a v a 2 s . c o m l.setRows(1); panelGrafica.setLayout(l); panelGrafica.add(chart); }
From source file:EspectroForm.java
private void initPanel() { GridLayout gL = new GridLayout(); gL.setColumns(1);/*from w w w. ja v a 2 s.co m*/ gL.setRows(1); spectroPanel.setLayout(gL); spectroPanel.setPreferredSize(new Dimension(240, 350)); spectroPanel.add(spectroChart); }
From source file:gtu.xml.xstream.iisi.MQDecodeUI.java
private void initGUI() { try {/*from ww w .j a v a 2s . c o m*/ JCommonUtil.defaultLookAndFeel(); GridLayout thisLayout = new GridLayout(3, 1); thisLayout.setColumns(1); thisLayout.setHgap(5); thisLayout.setVgap(5); thisLayout.setRows(3); getContentPane().setLayout(thisLayout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { beforeArea = new JTextArea(); getContentPane().add(beforeArea); } { afterArea = new JTextArea(); getContentPane().add(afterArea); } { jPanel1 = new JPanel(); FlowLayout jPanel1Layout = new FlowLayout(); getContentPane().add(jPanel1); jPanel1.setPreferredSize(new java.awt.Dimension(546, 38)); jPanel1.setLayout(jPanel1Layout); { executeBtn = new JButton(); jPanel1.add(executeBtn); executeBtn.setText("\u7522\u751f"); executeBtn.setPreferredSize(new java.awt.Dimension(78, 22)); executeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { Validate.notBlank(beforeArea.getText(), "messgaeContent"); String msg2 = beforeArea.getText(); XmlParserImpl xmlParserImpl = new XmlParserImpl(); final String jmsMessageXML = StringCompressUtil.uncompress(msg2); JmsMessageNew jmsMessageNew = (JmsMessageNew) xmlParserImpl .parseToObj(jmsMessageXML); String returnMessage = jmsMessageNew.getMessageXML(); System.out.println(returnMessage); afterArea.setText(returnMessage); System.out.println("done..."); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { cleanBtn = new JButton(); jPanel1.add(cleanBtn); cleanBtn.setText("\u6e05\u9664"); cleanBtn.setPreferredSize(new java.awt.Dimension(78, 22)); cleanBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { beforeArea.setText(""); afterArea.setText(""); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } } pack(); this.setSize(554, 402); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:de.tbuchloh.kiskis.gui.widgets.PasswordElement.java
/** * @param value/* w ww . j a v a 2s . c o m*/ * true if the button should be shown */ public void setShowTestButton(boolean value) { _testButton.setVisible(value); if (value) { final GridLayout layout = (GridLayout) _buttonPanel.getLayout(); layout.setRows(layout.getRows() + 1); _buttonPanel.add(_testButton); } else { final GridLayout layout = (GridLayout) _buttonPanel.getLayout(); layout.setRows(layout.getRows() - 1); _buttonPanel.remove(_testButton); } }
From source file:ResultScreen.java
private void initPanels() { GridLayout gL = new GridLayout(); gL.setColumns(1);/*ww w.j a v a 2 s . c o m*/ gL.setRows(1); demoduladaPanel.setLayout(gL); demoduladaPanel.setPreferredSize(new Dimension(150, 200)); demoduladaPanel.add(demoduladaChart); moduladaPanel.setLayout(gL); moduladaPanel.setPreferredSize(new Dimension(150, 200)); moduladaPanel.add(moduladaChart); }
From source file:com.codecrate.shard.ui.view.PlayerCharacterPanel.java
/** * This method initializes jPanel/*ww w .ja va 2s .c om*/ * * @return javax.swing.JPanel */ private JPanel getBasicInfoPanel() { if (basicInfoPanel == null) { alignmentScript = new JLabel(); alignmentScript.setText("Alignment:"); alignmentScript.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); raceScript = new JLabel(); raceScript.setText("Race:"); raceScript.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); classScript = new JLabel(); classScript.setText("Class:"); classScript.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); levelScript = new JLabel(); levelScript.setText("Level:"); levelScript.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); GridLayout gridLayout = new GridLayout(); gridLayout.setRows(2); gridLayout.setHgap(5); basicInfoPanel = new JPanel(); basicInfoPanel.setLocation(new java.awt.Point(165, 44)); basicInfoPanel.setSize(new java.awt.Dimension(300, 60)); basicInfoPanel.setLayout(gridLayout); basicInfoPanel.add(classScript, null); basicInfoPanel.add(getClassValue(), null); basicInfoPanel.add(levelScript, null); basicInfoPanel.add(getLevelValue(), null); basicInfoPanel.add(raceScript, null); basicInfoPanel.add(getRaceValue(), null); basicInfoPanel.add(alignmentScript, null); basicInfoPanel.add(getAlignmentValue(), null); } return basicInfoPanel; }
From source file:com.codecrate.shard.ui.view.PlayerCharacterPanel.java
/** * This method initializes jPanel//from w ww. j av a 2s . c om * * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { jLabel10 = new JLabel(); jLabel10.setText("DEX"); jLabel8 = new JLabel(); jLabel8.setText("CON"); jLabel5 = new JLabel(); jLabel5.setText("CHA"); jLabel4 = new JLabel(); jLabel4.setText("STR"); jLabel3 = new JLabel(); jLabel3.setText("INT"); jLabel = new JLabel(); jLabel.setText("WIS"); GridLayout gridLayout1 = new GridLayout(); gridLayout1.setRows(6); jPanel = new JPanel(); jPanel.setLayout(gridLayout1); jPanel.setBounds(new java.awt.Rectangle(6, 165, 151, 151)); jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createLineBorder(java.awt.Color.black, 2), "Ability Scores", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), new java.awt.Color(51, 51, 51))); jPanel.add(jLabel4, null); jPanel.add(getStrengthValue(), null); jPanel.add(getStrengthBonusValue(), null); jPanel.add(jLabel10, null); jPanel.add(getDexterityValue(), null); jPanel.add(getDexterityBonusValue(), null); jPanel.add(jLabel8, null); jPanel.add(getConstitutionValue(), null); jPanel.add(getConstitutionBonusValue(), null); jPanel.add(jLabel3, null); jPanel.add(getIntelligenceValue(), null); jPanel.add(getIntelligenceBonusValue(), null); jPanel.add(jLabel, null); jPanel.add(getWisdomValue(), null); jPanel.add(getWisdomBonusValue(), null); jPanel.add(jLabel5, null); jPanel.add(getCharismaValue(), null); jPanel.add(getCharsimaBonusValue(), null); } return jPanel; }
From source file:com.codecrate.shard.ui.view.PlayerCharacterPanel.java
/** * This method initializes Appearance/*from w ww . j av a2 s.c o m*/ * * @return javax.swing.JPanel */ private JPanel getAppearance() { if (Appearance == null) { skincolorValue = new JLabel(); skincolorValue.setText("Pale"); ageValue = new JLabel(); ageValue.setText("21"); skincolorScript = new JLabel(); skincolorScript.setText("Skin Color:"); ageScript = new JLabel(); ageScript.setText("Age:"); eyecolorValue = new JLabel(); eyecolorValue.setText("Blue"); heightValue = new JLabel(); heightValue.setText("5'11"); haircolorScript = new JLabel(); haircolorScript.setText("HairColor:"); weightValue = new JLabel(); weightValue.setText("180"); weightScript = new JLabel(); weightScript.setText("Weight:"); eyecolorScript = new JLabel(); eyecolorScript.setText("Eye Color:"); GridLayout gridLayout2 = new GridLayout(); gridLayout2.setRows(2); heightScript = new JLabel(); heightScript.setText("Height:"); haircolorValue = new JLabel(); haircolorValue.setText("Blond"); Appearance = new JPanel(); Appearance.setLayout(gridLayout2); Appearance.setBounds(new java.awt.Rectangle(165, 120, 392, 60)); Appearance.setBorder(javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createLineBorder(java.awt.Color.black, 1), "Appearance", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), new java.awt.Color(51, 51, 51))); Appearance.add(heightScript, null); Appearance.add(heightValue, null); Appearance.add(eyecolorScript, null); Appearance.add(eyecolorValue, null); Appearance.add(skincolorScript, null); Appearance.add(skincolorValue, null); Appearance.add(weightScript, null); Appearance.add(weightValue, null); Appearance.add(haircolorScript, null); Appearance.add(haircolorValue, null); Appearance.add(ageScript, null); Appearance.add(ageValue, null); } return Appearance; }