/** * Immediately shows the popup at the specified point. {@link getContent()} is called to get the * content of the popup. * * @param showAt Show at the specified point. */ public void show(Point showAt) { this.removeAll(); Box content = new Box(BoxLayout.Y_AXIS); UIUtils.setPadding(content, 5, 5, 5, 5); content.add(this.getContent()); this.add(content); // For some reason we need to set the size manually. content.setPreferredSize(new Dimension(310, content.getPreferredSize().height)); this.viewer.showPopupAt(this, showAt, true); }
@Override protected void zmenaVyberu(final Set<Alela> aAlelyx) { jmenaVybranychAlel = Alela.alelyToNames(aAlelyx); final Genotyp genotyp = new Genotyp(aAlelyx, bag.getGenom()); final Sklivec sklivec = bag.getSklivec(genotyp); jskelneikony.removeAll(); // BoundingRect br = Imagant.sjednoceni(sklivec.imaganti); { jskelneikony.add(Box.createVerticalStrut(20)); final JButton jLabel = new JButton(); jLabel.setAlignmentX(CENTER_ALIGNMENT); // jLabel.setText("všechna skla přes sebe"); final Imagant imagant = Sklo.prekresliNaSebe(sklivec.imaganti); if (imagant != null) { jLabel.setIcon(new ImageIcon(imagant.getImage())); } jskelneikony.add(jLabel); } jskelneikony.add(Box.createVerticalStrut(50)); final Iterator<SkloAplikant> iterator = bag.getSada().getSkloAplikanti().iterator(); for (final Imagant imagant : sklivec.imaganti) { final SkloAplikant skloAplikant = iterator.next(); final Box panel = Box.createHorizontalBox(); final TitledBorder border = BorderFactory.createTitledBorder(skloAplikant.sklo.getName()); border.setTitleJustification(TitledBorder.CENTER); panel.setBorder(border); final JLabel jLabel = new JLabel(); // jLabel.setText("sklo"); if (imagant != null) { jLabel.setIcon(new ImageIcon(imagant.getImage())); } jLabel.setAlignmentX(CENTER_ALIGNMENT); panel.add(Box.createHorizontalGlue()); panel.add(jLabel); panel.add(Box.createHorizontalGlue()); panel.setMinimumSize(new Dimension(150, 100)); panel.setPreferredSize(new Dimension(150, 100)); // JLabel jJmenoSady = new JLabel(skloAplikant.sklo.getName()); // jJmenoSady.setAlignmentX(JComponent.CENTER_ALIGNMENT); // jskelneikony.add(jJmenoSady); jskelneikony.add(panel); jskelneikony.add(Box.createVerticalStrut(10)); } jskelneikony.add(Box.createVerticalGlue()); final JCheckBox jZobrazovaniVseho = new JCheckBox("Zobrazit vše"); jZobrazovaniVseho.setSelected(zobrazovatVse); jskelneikony.add(jZobrazovaniVseho); jZobrazovaniVseho.addItemListener( e -> { zobrazovatVse = jZobrazovaniVseho.isSelected(); resetBag(bag); }); // a teď vyrendrovat vše přes sebe System.out.println(genotyp); jskelneikony.revalidate(); // pack(); }
public DocumentPanel() { super(new BorderLayout()); JLabel lblDocument = new JLabel("Document: " + document.getTitle()); lblDocument.setBorder(new EtchedBorder()); textPane = new JTextPane(document); textPane.setEditable(false); textPane.setMargin(new Insets(5, 20, 5, 5)); textPane.setMaximumSize(new Dimension(364, 1000000000)); textPane.setPreferredSize(new Dimension(364, 400)); textPane.setMinimumSize(new Dimension(364, 10)); textPane.addCaretListener( new CaretListener() { public void caretUpdate(CaretEvent e) { int length = document.getLength(); int offset = e.getDot(); if (e.getDot() == e.getMark()) textPane.getCaret().moveDot(offset + 1); Paragraph p = lockManager.getParFromOffset(offset); int pOffset = p.getOffset(); lblCursor.setText( "Document Length=" + String.valueOf(length) + ", CaretOffset=" + String.valueOf(offset) + ", Paragraph=" + p.toString() + ", Offset in Paragraph=" + String.valueOf(offset - p.getOffset())); } }); Box box = new Box(BoxLayout.X_AXIS); box.add(textPane); box.add(Box.createGlue()); box.setBackground(Color.WHITE); box.setOpaque(true); box.setPreferredSize(new Dimension(600, 10000)); lblCursor = new JLabel("Cursor"); lblCursor.setBorder(new EtchedBorder()); JPanel boxText = new JPanel(new BorderLayout()); boxText.setBorder(new EmptyBorder(5, 5, 5, 5)); boxText.add(lblDocument, BorderLayout.NORTH); boxText.add(new JScrollPane(box), BorderLayout.CENTER); boxText.add(lblCursor, BorderLayout.SOUTH); JLabel lblPars = new JLabel("Paragraphs: "); lblPars.setBorder(new EtchedBorder()); parList = new JList(); parList.setPreferredSize(new Dimension(100, 300)); parList.setEnabled(false); JPanel boxPars = new JPanel(new BorderLayout()); boxPars.setBorder(new EmptyBorder(5, 5, 5, 5)); boxPars.add(lblPars, BorderLayout.NORTH); boxPars.add(new JScrollPane(parList), BorderLayout.CENTER); add(boxText, BorderLayout.CENTER); add(boxPars, BorderLayout.EAST); }