Tag: jframe

java JFrame中奇怪的空白区域

这是我的问题。 当我使用以下代码时: package xyz.lexium.giapb.ui; import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ConsoleWindow extends WindowAdapter implements WindowListener, ActionListener, Runnable { private JFrame frame; private JTextArea textArea; private Thread reader; private Thread reader2; private boolean quit; private final PipedInputStream pin = new PipedInputStream(); private final PipedInputStream pin2 = new PipedInputStream(); public ConsoleWindow() { frame […]

如何在Java中为框架设置图标?

我使用此语句来设置框架的图标: frame.setIconImage(Toolkit.getDefaultToolkit().getImage(“tictactoe.gif”)); 不幸的是,框架图标仍显示默认的java图标。 如何解决这个问题?

一个Runnable中的两个JFrame。 调用JFileChooser后,第一个JFrame在应用程序栏中消失

我正在尝试创建一个多窗口界面,ala GIMP。 其中一个允许用户加载图像,以显示在框架中。 因此,当程序加载时,所有窗口(现在两个,但我计划有三个)显示在应用程序栏中。 但是,当第二个*窗口调用JFileChooser时,它会在应用程序栏中消失( 但不会关闭 )。 但如果我+或+它仍会出现在那里。 当我单击“显示/隐藏所有Windows”按钮时,它也会再次出现在应用栏中。 从单个Runnable调用所有JFrame。 其他人遇到过这个问题? 我如何解决这个问题(即,始终在应用程序栏中显示所有窗口)? 谢谢! *我将它称为第二个窗口,因为它是第二个窗口,它是setVisibled为true。

在Java JFrame中显示Google日历

我在java jframe中显示谷歌日历时遇到问题。 编辑:我确实看到谷歌日历,但它有蓝色背景,这使得查看事件变得困难。 这是我的代码片段 temp是谷歌用户名。 private void getGoogleCalendar(){ googlepane=new JPanel(new BorderLayout()); String s=”https://www.google.com/calendar/b/0/htmlembed?src=groupboba@gmail.com&ctz=America/New_York&gsessionid=OK”; JEditorPane tp=new JEditorPane(); try { HTMLEditorKit kit = new HTMLEditorKit(); StyleSheet styles =kit.getStyleSheet(); styles.importStyleSheet(new URL(s)); kit.setStyleSheet(styles); kit.install(tp); tp.setContentType(“text/html”); tp.setEditorKit(kit); tp.addHyperlinkListener(this); tp.setEditable(false); tp.setPage(s); tp.setBackground(Color.white); } catch (IOException e) { e.printStackTrace(); } googlepane.add(tp, BorderLayout.CENTER); return; }

如何获得透明的JFrame?

当我尝试运行以获得透明框架时,它显示exception。 我的代码是: public class NewJFrame extends javax.swing.JFrame { public NewJFrame() { initComponents(); com.sun.awt.AWTUtilities.setWindowOpacity(this, 0.05f); } 例外情况是: Exception in thread “AWT-EventQueue-0” java.awt.IllegalComponentStateException: The frame is decorated at java.awt.Frame.setOpacity(Frame.java:960) at java.awt.Window$1.setOpacity(Window.java:4032) at com.sun.awt.AWTUtilities.setWindowOpacity(AWTUtilities.java:174) at test.NewJFrame.(NewJFrame.java:28) at test.NewJFrame$2.run(NewJFrame.java:115)

为什么我的JFrame不会响应鼠标和窗口的变化?

这是我的代码: import java.awt.event.*; import java.awt.*; import javax.swing.*; public class wind extends JFrame implements ComponentListener, MouseListener { JButton button; JLabel label; public wind() { // initialise instance variables setTitle(“My First Window!”); setSize(400, 200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); JPanel content = new JPanel(); content.setLayout(new FlowLayout()); content.addComponentListener(this); content.addMouseListener(this); label = new JLabel(“My First Window”); content.add(label); label.addComponentListener(this); button = new JButton(“Click […]

Java MVC多个JFrame

我正在用netbeans创建一个mvc java应用程序。 首先,在运行程序时,应该只显示2个按钮“Teacher”和“Student”。 当我click the teacher button ,它将引导我查看viewTeacher ,在那里我可以输入或编辑有关”Teacher”数据。 同样适用于学生按钮。 我已经完成了整个MVC,但我对第一个按钮感到confused : – 我应该制作更多1个视图吗? viewForm, viewTeacher, viewStudent. viewForm is the first 2 buttons appear: “Teacher” & “Student” 要么 – should i put all the codes inside viewForm and create viewTeacher & viewStudent form on other components?

Java没有其他类的响应

我有这个GUI程序,我试图基本上复制Windows CMD。 由于我在这个程序中有很多function,所以我决定将部分代码放在不同的类中。 但它没有回应。 if(command.size()0) { switch(command.get(0)) { case “dt”: getDateTime a = new getDateTime(); a.Start(); break; // other case(s) down below } } 这是geDateTime类 public class getDateTime { public static void Start() { Terminal t = new Terminal(); try { DateFormat dateFormat = new SimpleDateFormat(“dd/MM/yyyy HH:mm:ss”); Date date = new Date(); String s = […]

是否可以在JFrame上绘制图像或文本?

是否可以在不添加JPanel情况下在JFrame上绘图? 我重写paintComponents()但它没有显示任何内容。 @Override public void paintComponents(Graphics g) { super.paintComponents(g); g.drawString(“for test”, 10, 10); }

Swing – setResizable(true)使JFrame标题栏更高,窗口大小更小

如果有人将其标记为重复,我会自己做:我们之前有一个非常相对的问题: Java setResizable(false)改变窗口大小(swing) 没有解决方案适合我。 这是我的SSCCE: import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.plaf.nimbus.NimbusLookAndFeel; public class TitleHeightChange extends JFrame { private static final String lp = System.lineSeparator(); public TitleHeightChange() { begin(); } private void begin() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // […]