Tag: resize

JavaFX – 调整屏幕大小时调整canvas大小

我正在使用我在JavaFX中构建的关卡编辑器的GUI,我希望能够将canvas对象的大小调整为新的拆分窗格尺寸。 似乎所有尝试的东西都失败了。 这包括直接传递窗格对象并使用它的宽度,使用窗口大小侦听器并将width和height属性绑定到拆分窗格的属性。 有任何想法吗。 这是resize之前的松散之处: resize后: 有没有人有任何想法。 该类的代码非常广泛,但将包含resize的代码。 public Canvas canvas; public String tabTitle; public VBox layout; public GraphicsContext g; public Core core; public CanvasTab(Core core, String tabTitle){ this.core = core; this.canvas = new Canvas(core.scene.getWidth() – 70, core.scene.getHeight() – 70); layout = VBoxBuilder.create().spacing(0).padding(new Insets(10, 10, 10, 10)).children(canvas).build(); this.g = canvas.getGraphicsContext2D(); g.setFill(Color.BLACK); g.fillRect(0, 0, canvas.getWidth(), canvas.getHeight()); […]

如何在使用未修饰的JFrame时添加对resize的支持?

我想自定义标题栏,最小化,最大化和关闭按钮。 所以我使用了setUndecorated(true); 在我的JFrame上,但我仍然希望能够调整窗口大小。 实现它的最佳方法是什么? 我在RootPane上有一个边框,我可以在Border或RootPane上使用MouseListeners。 有什么建议? import java.awt.Color; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.border.LineBorder; public class UndecoratedFrame extends JFrame { private LineBorder border = new LineBorder(Color.BLUE,2); private JMenuBar menuBar = new JMenuBar(); private JMenu menu = new JMenu(“File”); private JMenuItem item = new JMenuItem(“Nothing”); public UndecoratedFrame() { menu.add(item); menuBar.add(menu); this.setJMenuBar(menuBar); this.setUndecorated(true); […]

调整具有固定宽度的长句的对话框消息(JOptionPane)

我正在尝试使用超链接调整长句的对话框( JOptionPane )的高度。 我的代码是…… public class DialogTest { public static void main(String[] args) throws Exception { JTextPane jtp = new JTextPane(); Document doc = jtp.getDocument(); for (int i = 0; i < 50; i++) { doc.insertString(doc.getLength(), " Hello Java World ", new SimpleAttributeSet()); if ((3 == i) || (7 == i) || (15 == i)) […]

如何在javafx中调整imageview图像的大小?

我需要在JavaFX中将图像调整为特定尺寸,例如100 x 100像素。 我怎样才能做到这一点? Image或ImageView类可以用于此目的吗?

我们如何自动调整SWT中组件的大小?

在我的SWT应用程序中,我在SWT shell中有一些组件。 现在,我如何根据显示窗口的大小自动重新调整此组件的大小。 Display display = new Display(); Shell shell = new Shell(display); Group outerGroup,lowerGroup; Text text; public test1() { GridLayout gridLayout = new GridLayout(); gridLayout.numColumns=1; shell.setLayout(gridLayout); outerGroup = new Group(shell, SWT.NONE); GridData data = new GridData(1000,400); data.verticalSpan = 2; outerGroup.setLayoutData(data); gridLayout = new GridLayout(); gridLayout.numColumns=2; gridLayout.makeColumnsEqualWidth=true; outerGroup.setLayout(gridLayout); … } 即,当我减小窗口的大小时,它内部的组件应该根据它出现。

图像resize质量(Java)

我有一个开源应用程序,可以将照片上传到Facebook。 为了节省带宽,照片会在上传前自动resize(Facebook规定了最大尺寸限制)。 有些人抱怨照片质量,事实上你可以看到差异(对于一些演示图像,请参阅此问题 )。 所以我的问题是,在不降低质量的情况下缩小Java中的图像(即照片)的“最佳”方法是什么,或者至少在质量损失/伪影最小的情况下? 您可以在此处查看我当前的代码(通过此页面调整代码大小)。

在Java中保持纵横比的同时调整图像大小

我试图在java的内存中调整bufferdImage,但要保持图像的宽高比我有这样的东西,但这不是很好 int w = picture.getWidth(); int h = picture.getWidth(); int neww=w; int newh=h; int wfactor = w; int hfactor = h; if(w > DEFULT_PICTURE_WIDTH || h > DEFULT_PICTURE_HIGHT) { while(neww > DEFULT_PICTURE_WIDTH) { neww = wfactor /2; newh = hfactor /2; wfactor = neww; hfactor = newh; } } picture = Utils.resizePicture(picture,neww,newh);

如何调整包含svg图像的按钮

我想在按钮内放置一个svg图像,然后我希望能够将按钮的大小调整为任意大小。 首先,这是我在按钮内加载和放置svg图像的方法: SVGPath svg = new SVGPath(); svg.setContent(“M87.5,50.002C87.5,29.293,70.712,12.5,50,12.5c-20.712,0-37.5,16.793-37.5,37.502C12.5,70.712,29.288,87.5,50,87.5 c6.668,0,12.918-1.756,18.342-4.809c0.61-0.22,1.049-0.799,1.049-1.486c0-0.622-0.361-1.153-0.882-1.413l0.003-0.004l-6.529-4.002 L61.98,75.79c-0.274-0.227-0.621-0.369-1.005-0.369c-0.238,0-0.461,0.056-0.663,0.149l-0.014-0.012 C57.115,76.847,53.64,77.561,50,77.561c-15.199,0-27.56-12.362-27.56-27.559c0-15.195,12.362-27.562,27.56-27.562 c14.322,0,26.121,10.984,27.434,24.967C77.428,57.419,73.059,63,69.631,63c-1.847,0-3.254-1.23-3.254-3.957 c0-0.527,0.176-1.672,0.264-2.111l4.163-19.918l-0.018,0c0.012-0.071,0.042-0.136,0.042-0.21c0-0.734-0.596-1.33-1.33-1.33h-7.23 c-0.657,0-1.178,0.485-1.286,1.112l-0.025-0.001l-0.737,3.549c-1.847-3.342-5.629-5.893-10.994-5.893 c-10.202,0-19.877,9.764-19.877,21.549c0,8.531,5.101,14.775,13.632,14.775c4.75,0,9.587-2.727,12.665-7.035l0.088,0.527 c0.615,3.342,9.843,7.576,15.121,7.576c7.651,0,16.617-5.156,16.617-19.932l-0.022-0.009C87.477,51.13,87.5,50.569,87.5,50.002z M56.615,56.844c-1.935,2.727-5.101,5.805-9.763,5.805c-4.486,0-7.212-3.166-7.212-7.738c0-6.422,5.013-12.754,12.049-12.754 c3.958,0,6.245,2.551,7.124,4.486L56.615,56.844z”); Button button = new Button(); button.setGraphic(svg); 我已经尝试将SVGPath放在Group对象中,然后我缩放了Group,就像这样: Group graphics = new Group(); graphics.getChildren().add(svg); graphics.getTransforms().add(new Scale(0.2, 0.2, 0 , 10)); Button button = new Button(); button.setGraphic(graphics); 这确实改变了svg图像的大小。 问题是按钮的大小不会相应改变。 它的大小与图像从未重新缩放的大小相同。 如果我设置按钮的最大尺寸并不重要。 我只能让按钮更大,但不能更小。 关于在JavaFx中使用SVG图像的文档似乎非常有限,所以如果有人能帮助我,那将非常感激。 更新: @ItachiUchiha指出我可以使用setScaleX(..) and setScaleY(..)重新调整按钮,内部的svg图像将重新调整。 但是,这样做似乎并没有改变按钮的size属性。 这意味着包含按钮的窗格仍将占用相同的空间,就像按钮未重新缩放一样。 […]

为什么JComboBox会忽略PrototypeDisplayValue

与这两个post@iMohammad相关联, 使用JButton增加/减少textArea中的字体大小和单击JButton Java时更改字体样式 …,我面临着来自JComboBox的非常有趣的问题,方法是将setPrototypeDisplayValue作为参数传递对于JComboBox’s size在屏幕上JComboBox’s size 请问如何动态调整JComboBox大小取决于Font ,同样适用于我在sscce中尝试过的另一个JComponents import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ComboBoxFontChange extends JFrame { private static final long serialVersionUID = 1L; private JComboBox cbox = new JComboBox(); private JTextField tfield = new JTextField(“Change”); private JLabel label = new JLabel(“Cash”); private JButton button = new JButton(“++ Font”); private JTextField text; […]

可打印的打印BufferedImage大小不正确

所以我在这里尝试的是打印BufferedImage,一切正常,直到你看到结果。 结果很大,印刷量很大,并且在出于某种原因打印时不会扩大尺寸。 我使用((MM * DPI)/25,4)根据毫米的纸张尺寸计算正确的像素长度,但是当我将它打印到大的时候。 这是我为它写的代码: package frik.main; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.UIManager; import java.awt.event.*; import javax.swing.*; import frik.data.Config; import frik.utils.ImgUtil; public class Previewer implements Config, Printable, ActionListener{ private JFrame Frame; private […]