Questions tagged [Swing] (134)

0
answer

How to copy text to the clipboard using the key combination?

Hello. Write educational app translator tipo QTranslate only for Ubuntu. Tell me how it is possible to implement the functionality of copying text from any open window to the clipboard by his own combination of keys(such as Alt + Q)? Let's say I have one java class which creates a simple form with tekstowym field. How to m...
neoma asked March 30th 20 at 01:25
0
answer

As in Java Swing to display one component on top of another?

There is a window:class Window extends JFrame { int width = 1500; int height = 750; private JPanel mainPanel; private JPanel mapPanel; private JPanel pausePanel; Window() { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setLayout(null); setSize(width + 5, height + 28); setResizable(false); ...
jessica.Lak asked March 29th 20 at 20:46
0
answer

How in Java to get all custom JComponent from a frame?

I have a JComponent, which is the picture:public class JImage extends JComponent { private Image img = null; JImage () { } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.drawImage(this.getImage(), 0, 0, this.getSize().the width of this.getSize().he...
eudora.Daniel96 asked March 29th 20 at 20:23
1
answer

Why code doesn't work without else?

Why if else sout with the number not changingpublic class Main { static JFrame jFrame = getJFrame(); static int width = jFrame.getBounds().width; static int height = jFrame.getBounds().height; public static void main(String[] args) { JLabel labelx = new JLabel(); JLabel labely = new JLabel(); jFrame.add(labelx); jFra...
Webster asked March 29th 20 at 19:27
0
answer

Incorrectly set the window size in Java swing, what's the problem and what to do?

There are two classes. One describes a customized JFrame, the other creates an instance of it. I tried to set the window size to 1000х500 using setSize(1000,500). A blank window is created but has a size of workspace 985х450. Code below. Main class:public class Main { static Window window; public static void main(String[]...
wendy.Altenwerth84 asked March 27th 20 at 13:34
0
answer

How to make context menu in swing.ListCellRenderer for you RMB on an item?

How to make context menu in swing.ListCellRenderer for you RMB on an item ? JList list = new JList<>(CSlistModel); //public class CSRenderer extends JLabel implements ListCellRenderer SRenderer csRenderer = new CSRenderer(this); // list.'s setcellrenderer(csRenderer);
Billie.Collier42 asked March 25th 20 at 12:52
1
answer

Trouble displaying custom JComponent. What to do?

Tried to create a JImage class that inherits from JComponent and contains the picture. The application window starts but can not see the image. Code below. Main class:public class Test { public static void main(String[] args) { Window window = new Window(); } } Class frame:public class Window extends JFrame { public Wind...
linnie.Windler asked March 25th 20 at 12:05
1
answer

How to change the color of text in a JList when you press the button?

Write a simple ToDo List. You need to make it so that when you press the "Done" button, the text in the JList, became green Here is the code:import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; public class Window extends JFrame { pr...
Twila_Hettinger asked March 25th 20 at 11:28
1
answer

Question in Java — swing?

Good evening, induce me to believe, not for crutches, but the correctness of the implementation. In General, there is a picture of the keyboard(make below), I want to the indicator somehow looped the key on the picture in opredelnie time, and compared with what hit the user. I tried to create a grid around the picture using...
Connor64 asked March 24th 20 at 13:38
0
answer

Why doesn't the method intersects in a loop?

The bottom line is that there are 12 squares and it is necessary to determine whether it intersects at least one square from the list brush. Reason is determined correctly only 12, so the last square. The rest is 0, then there is no intersection. What could be the problem?public float[] checkKvadrat() { float[] kvadr = new...
Cyril.Kassulke asked March 24th 20 at 12:10